Search in sources :

Example 1 with Jsonb

use of javax.json.bind.Jsonb in project meecrowave by apache.

the class MeecrowaveClientLifecycleListener method clientDestroyed.

@Override
public void clientDestroyed(final Client client) {
    try {
        final ClientProviderFactory cpf = ClientProviderFactory.class.cast(client.getEndpoint().get(ClientProviderFactory.class.getName()));
        final Collection<Object> invoke = Collection.class.cast(getReadersWriters.invoke(cpf));
        invoke.stream().map(p -> ProviderInfo.class.isInstance(p) ? ProviderInfo.class.cast(p).getProvider() : p).filter(p -> !ConfigurableBus.ConfiguredJsonbJaxrsProvider.class.isInstance(p) && JsonbJaxrsProvider.class.isInstance(p)).map(JsonbJaxrsProvider.class::cast).map(p -> {
            try {
                return ((AtomicReference<Jsonb>) delegate.get(p)).get();
            } catch (final IllegalAccessException e) {
                throw new IllegalStateException(e);
            }
        }).filter(Objects::nonNull).filter(JohnzonJsonb.class::isInstance).map(JohnzonJsonb.class::cast).distinct().forEach(jsonb -> CDI.current().select(JohnzonCdiExtension.class).get().untrack(jsonb));
    } catch (final RuntimeException re) {
        new LogFacade(MeecrowaveClientLifecycleListener.class.getName()).debug(re.getMessage(), re);
    } catch (final Exception re) {
        // reflection etc which shouldn't fail
        new LogFacade(MeecrowaveClientLifecycleListener.class.getName()).error(re.getMessage(), re);
    }
}
Also used : LogFacade(org.apache.meecrowave.logging.tomcat.LogFacade) Collection(java.util.Collection) CDI(javax.enterprise.inject.spi.CDI) Client(org.apache.cxf.endpoint.Client) ProviderFactory(org.apache.cxf.jaxrs.provider.ProviderFactory) Field(java.lang.reflect.Field) AtomicReference(java.util.concurrent.atomic.AtomicReference) Objects(java.util.Objects) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) ClientProviderFactory(org.apache.cxf.jaxrs.client.ClientProviderFactory) JohnzonCdiExtension(org.apache.johnzon.jsonb.cdi.JohnzonCdiExtension) ClientLifeCycleListener(org.apache.cxf.endpoint.ClientLifeCycleListener) JohnzonJsonb(org.apache.johnzon.jsonb.JohnzonJsonb) Jsonb(javax.json.bind.Jsonb) Method(java.lang.reflect.Method) JsonbJaxrsProvider(org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider) JsonbJaxrsProvider(org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider) ClientProviderFactory(org.apache.cxf.jaxrs.client.ClientProviderFactory) JohnzonJsonb(org.apache.johnzon.jsonb.JohnzonJsonb) JohnzonJsonb(org.apache.johnzon.jsonb.JohnzonJsonb) Jsonb(javax.json.bind.Jsonb) LogFacade(org.apache.meecrowave.logging.tomcat.LogFacade) ProviderInfo(org.apache.cxf.jaxrs.model.ProviderInfo) Objects(java.util.Objects) JohnzonCdiExtension(org.apache.johnzon.jsonb.cdi.JohnzonCdiExtension)

Aggregations

Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1 Objects (java.util.Objects)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CDI (javax.enterprise.inject.spi.CDI)1 Jsonb (javax.json.bind.Jsonb)1 Client (org.apache.cxf.endpoint.Client)1 ClientLifeCycleListener (org.apache.cxf.endpoint.ClientLifeCycleListener)1 ClientProviderFactory (org.apache.cxf.jaxrs.client.ClientProviderFactory)1 ProviderInfo (org.apache.cxf.jaxrs.model.ProviderInfo)1 ProviderFactory (org.apache.cxf.jaxrs.provider.ProviderFactory)1 JsonbJaxrsProvider (org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider)1 JohnzonJsonb (org.apache.johnzon.jsonb.JohnzonJsonb)1 JohnzonCdiExtension (org.apache.johnzon.jsonb.cdi.JohnzonCdiExtension)1 LogFacade (org.apache.meecrowave.logging.tomcat.LogFacade)1