Search in sources :

Example 6 with FactoryBeanListener

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

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 7 with FactoryBeanListener

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

the class PolicyEngineImpl method setBus.

@Resource
public final void setBus(Bus b) {
    if (this.bus == b) {
        // avoid bus init twice through injection
        return;
    }
    bus = b;
    addBusInterceptors();
    FactoryBeanListenerManager fblm = bus.getExtension(FactoryBeanListenerManager.class);
    if (fblm != null) {
        for (FactoryBeanListener l : fblm.getListeners()) {
            if (l instanceof PolicyAnnotationListener) {
                return;
            }
        }
        fblm.addListener(new PolicyAnnotationListener(bus));
    }
}
Also used : FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager) Resource(javax.annotation.Resource)

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