Search in sources :

Example 1 with FactoryBeanListener

use of org.apache.cxf.service.factory.FactoryBeanListener in project fabric8 by jboss-fuse.

the class ManagedApiFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, final Bus bus) {
    if (provider instanceof Endpoint) {
        EndpointImpl endpointImpl = (EndpointImpl) provider;
        List<Feature> features = endpointImpl.getActiveFeatures();
        if (features == null) {
            features = new ArrayList<Feature>();
            features.add(this);
            endpointImpl.initializeActiveFeatures(features);
        } else {
            features.add(this);
        }
    } else if (provider instanceof Bus) {
        FactoryBeanListenerManager factoryBeanListenerManager = bus.getExtension(FactoryBeanListenerManager.class);
        if (factoryBeanListenerManager == null) {
            factoryBeanListenerManager = new FactoryBeanListenerManager(bus);
        }
        factoryBeanListenerManager.addListener(new FactoryBeanListener() {

            @Override
            public void handleEvent(Event arg0, AbstractServiceFactoryBean arg1, Object... arg2) {
                if (arg0.equals(Event.SERVER_CREATED) && (arg2[0] instanceof Server)) {
                    Server server = (Server) arg2[0];
                    initialize(server, bus);
                }
            }
        });
    } else {
        List<Feature> features = (List<Feature>) bus.getFeatures();
        if (features == null) {
            features = new ArrayList<Feature>();
            features.add(this);
        } else {
            features.add(this);
        }
    }
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) Bus(org.apache.cxf.Bus) MBeanServer(javax.management.MBeanServer) Server(org.apache.cxf.endpoint.Server) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) ArrayList(java.util.ArrayList) Feature(org.apache.cxf.feature.Feature) AbstractFeature(org.apache.cxf.feature.AbstractFeature) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager) Endpoint(org.apache.cxf.endpoint.Endpoint) ArrayList(java.util.ArrayList) List(java.util.List) FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener)

Example 2 with FactoryBeanListener

use of org.apache.cxf.service.factory.FactoryBeanListener in project fabric8 by fabric8io.

the class ManagedApiFeature method initialize.

@Override
public void initialize(final Bus bus) {
    FactoryBeanListenerManager factoryBeanListenerManager = bus.getExtension(FactoryBeanListenerManager.class);
    if (factoryBeanListenerManager == null) {
        factoryBeanListenerManager = new FactoryBeanListenerManager(bus);
    }
    factoryBeanListenerManager.addListener(new FactoryBeanListener() {

        @Override
        public void handleEvent(Event arg0, AbstractServiceFactoryBean arg1, Object... arg2) {
            if (arg0.equals(Event.SERVER_CREATED) && (arg2[0] instanceof Server)) {
                Server server = (Server) arg2[0];
                initialize(server, bus);
            }
        }
    });
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) Server(org.apache.cxf.endpoint.Server) FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager)

Example 3 with FactoryBeanListener

use of org.apache.cxf.service.factory.FactoryBeanListener in project fabric8 by jboss-fuse.

the class ManagedApiFeature method initialize.

@Override
public void initialize(final Bus bus) {
    FactoryBeanListenerManager factoryBeanListenerManager = bus.getExtension(FactoryBeanListenerManager.class);
    if (factoryBeanListenerManager == null) {
        factoryBeanListenerManager = new FactoryBeanListenerManager(bus);
    }
    factoryBeanListenerManager.addListener(new FactoryBeanListener() {

        @Override
        public void handleEvent(Event arg0, AbstractServiceFactoryBean arg1, Object... arg2) {
            if (arg0.equals(Event.SERVER_CREATED) && (arg2[0] instanceof Server)) {
                Server server = (Server) arg2[0];
                initialize(server, bus);
            }
        }
    });
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) MBeanServer(javax.management.MBeanServer) Server(org.apache.cxf.endpoint.Server) FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager)

Example 4 with FactoryBeanListener

use of org.apache.cxf.service.factory.FactoryBeanListener in project fabric8 by jboss-fuse.

the class SwaggerFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, final Bus bus) {
    if (!(provider instanceof Endpoint)) {
        FactoryBeanListenerManager factoryBeanListenerManager = bus.getExtension(FactoryBeanListenerManager.class);
        if (factoryBeanListenerManager == null) {
            factoryBeanListenerManager = new FactoryBeanListenerManager(bus);
        }
        factoryBeanListenerManager.addListener(new FactoryBeanListener() {

            @Override
            public void handleEvent(Event arg0, AbstractServiceFactoryBean arg1, Object... arg2) {
                if (arg0.equals(Event.SERVER_CREATED) && (arg2[0] instanceof Server)) {
                    Server server = (Server) arg2[0];
                    if (server.getEndpoint().getEndpointInfo().getBinding().getBindingId().equals("http://apache.org/cxf/binding/jaxrs")) {
                        initialize(server, bus);
                    }
                }
            }
        });
        return;
    }
    EndpointImpl endpointImpl = (EndpointImpl) provider;
    List<Feature> features = endpointImpl.getActiveFeatures();
    if (features == null) {
        features = new ArrayList<Feature>();
        features.add(this);
        endpointImpl.initializeActiveFeatures(features);
    } else {
        features.add(this);
    }
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) Endpoint(org.apache.cxf.endpoint.Endpoint) Server(org.apache.cxf.endpoint.Server) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener) Feature(org.apache.cxf.feature.Feature) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager)

Example 5 with FactoryBeanListener

use of org.apache.cxf.service.factory.FactoryBeanListener in project fabric8 by fabric8io.

the class ManagedApiFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, final Bus bus) {
    if (provider instanceof Endpoint) {
        EndpointImpl endpointImpl = (EndpointImpl) provider;
        List<Feature> features = endpointImpl.getActiveFeatures();
        if (features == null) {
            features = new ArrayList<Feature>();
            features.add(this);
            endpointImpl.initializeActiveFeatures(features);
        } else {
            features.add(this);
        }
    } else if (provider instanceof Bus) {
        FactoryBeanListenerManager factoryBeanListenerManager = bus.getExtension(FactoryBeanListenerManager.class);
        if (factoryBeanListenerManager == null) {
            factoryBeanListenerManager = new FactoryBeanListenerManager(bus);
        }
        factoryBeanListenerManager.addListener(new FactoryBeanListener() {

            @Override
            public void handleEvent(Event arg0, AbstractServiceFactoryBean arg1, Object... arg2) {
                if (arg0.equals(Event.SERVER_CREATED) && (arg2[0] instanceof Server)) {
                    Server server = (Server) arg2[0];
                    initialize(server, bus);
                }
            }
        });
    } else {
        List<Feature> features = (List<Feature>) bus.getFeatures();
        if (features == null) {
            features = new ArrayList<Feature>();
            features.add(this);
        } else {
            features.add(this);
        }
    }
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) ArrayList(java.util.ArrayList) Feature(org.apache.cxf.feature.Feature) AbstractFeature(org.apache.cxf.feature.AbstractFeature) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager) Endpoint(org.apache.cxf.endpoint.Endpoint) ArrayList(java.util.ArrayList) List(java.util.List) FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener)

Aggregations

FactoryBeanListener (org.apache.cxf.service.factory.FactoryBeanListener)7 FactoryBeanListenerManager (org.apache.cxf.service.factory.FactoryBeanListenerManager)7 Server (org.apache.cxf.endpoint.Server)6 AbstractServiceFactoryBean (org.apache.cxf.service.factory.AbstractServiceFactoryBean)6 Endpoint (org.apache.cxf.endpoint.Endpoint)4 EndpointImpl (org.apache.cxf.endpoint.EndpointImpl)4 Feature (org.apache.cxf.feature.Feature)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MBeanServer (javax.management.MBeanServer)2 Bus (org.apache.cxf.Bus)2 AbstractFeature (org.apache.cxf.feature.AbstractFeature)2 Resource (javax.annotation.Resource)1