Search in sources :

Example 16 with Feature

use of org.apache.cxf.feature.Feature in project cxf by apache.

the class AbstractSTSClient method createClient.

protected void createClient() throws BusException, EndpointException {
    if (client != null) {
        return;
    }
    if (wsdlLocation != null) {
        WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
        SourceDataBinding dataBinding = new SourceDataBinding();
        factory.setDataBinding(dataBinding);
        Service service = factory.create();
        service.setDataBinding(dataBinding);
        EndpointInfo ei = service.getEndpointInfo(endpointName);
        Endpoint endpoint = new EndpointImpl(bus, service, ei);
        client = new ClientImpl(bus, endpoint);
    } else if (location != null) {
        Endpoint endpoint = STSUtils.createSTSEndpoint(bus, namespace, null, location, soapVersion, policy, endpointName);
        client = new ClientImpl(bus, endpoint);
    } else {
        throw new TrustException(LOG, "NO_LOCATION");
    }
    client.getInFaultInterceptors().addAll(inFault);
    client.getInInterceptors().addAll(in);
    client.getOutInterceptors().addAll(out);
    client.getOutFaultInterceptors().addAll(outFault);
    if (tlsClientParameters != null) {
        HTTPConduit http = (HTTPConduit) client.getConduit();
        http.setTlsClientParameters(tlsClientParameters);
    }
    in = null;
    out = null;
    inFault = null;
    outFault = null;
    if (features != null) {
        for (Feature f : features) {
            f.initialize(client, bus);
        }
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Service(org.apache.cxf.service.Service) ClientImpl(org.apache.cxf.endpoint.ClientImpl) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) Feature(org.apache.cxf.feature.Feature)

Example 17 with Feature

use of org.apache.cxf.feature.Feature in project cxf by apache.

the class ReflectionServiceFactoryBean method buildServiceFromWSDL.

protected void buildServiceFromWSDL(String url) {
    sendEvent(Event.CREATE_FROM_WSDL, url);
    if (LOG.isLoggable(Level.INFO)) {
        LOG.info("Creating Service " + getServiceQName() + " from WSDL: " + url);
    }
    populateFromClass = false;
    WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName());
    boolean setEPName = true;
    if (features != null) {
        for (Feature f : features) {
            if (f.getClass().isAnnotationPresent(EvaluateAllEndpoints.class)) {
                setEPName = false;
            }
        }
    }
    if (setEPName) {
        // CXF will only evaluate this endpoint
        factory.setEndpointName(getEndpointName(false));
    }
    sendEvent(Event.WSDL_LOADED, factory.getDefinition());
    setService(factory.create());
    setServiceProperties();
    sendEvent(Event.SERVICE_SET, getService());
    EndpointInfo epInfo = getEndpointInfo();
    if (epInfo != null) {
        serviceConfigurations.add(new WSDLBasedServiceConfiguration(getEndpointInfo().getBinding()));
    }
    initializeWSDLOperations();
    Set<Class<?>> cls = getExtraClass();
    if (cls != null && !cls.isEmpty()) {
        for (ServiceInfo si : getService().getServiceInfos()) {
            si.setProperty(EXTRA_CLASS, cls);
        }
    }
    initializeDataBindings();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) Feature(org.apache.cxf.feature.Feature)

Example 18 with Feature

use of org.apache.cxf.feature.Feature in project camel by apache.

the class CxfRsEndpointWithProperties method testCxfRsBeanWithCamelPropertiesHolder.

@Test
public void testCxfRsBeanWithCamelPropertiesHolder() throws Exception {
    // get the camelContext from application context
    CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
    CxfRsEndpoint testEndpoint = camelContext.getEndpoint("cxfrs:bean:testEndpoint", CxfRsEndpoint.class);
    assertEquals("Got a wrong address", "http://localhost:9900/testEndpoint", testEndpoint.getAddress());
    List<Feature> features = testEndpoint.getFeatures();
    assertEquals("Single feature is expected", 1, features.size());
    Map<String, Object> endpointProps = testEndpoint.getProperties();
    assertEquals("Single endpoint property is expected", 1, endpointProps.size());
    assertEquals("Wrong property value", "aValue", endpointProps.get("aKey"));
    HttpGet get = new HttpGet(testEndpoint.getAddress());
    CloseableHttpClient httpclient = HttpClientBuilder.create().build();
    try {
        HttpResponse response = httpclient.execute(get);
        assertEquals(404, response.getStatusLine().getStatusCode());
    } finally {
        httpclient.close();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) Feature(org.apache.cxf.feature.Feature) Test(org.junit.Test)

Example 19 with Feature

use of org.apache.cxf.feature.Feature 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 20 with Feature

use of org.apache.cxf.feature.Feature in project fabric8 by jboss-fuse.

the class EnableJMXFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, 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 {
        List<Feature> features = (List<Feature>) bus.getFeatures();
        if (features == null) {
            features = new ArrayList<Feature>();
            features.add(this);
        } else {
            features.add(this);
        }
    }
}
Also used : Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) ArrayList(java.util.ArrayList) List(java.util.List) Feature(org.apache.cxf.feature.Feature) AbstractFeature(org.apache.cxf.feature.AbstractFeature)

Aggregations

Feature (org.apache.cxf.feature.Feature)37 ArrayList (java.util.ArrayList)16 Bus (org.apache.cxf.Bus)8 Endpoint (org.apache.cxf.endpoint.Endpoint)7 EndpointImpl (org.apache.cxf.endpoint.EndpointImpl)7 List (java.util.List)6 Server (org.apache.cxf.endpoint.Server)6 AbstractFeature (org.apache.cxf.feature.AbstractFeature)6 LoggingFeature (org.apache.cxf.feature.LoggingFeature)6 IOException (java.io.IOException)5 QName (javax.xml.namespace.QName)5 Interceptor (org.apache.cxf.interceptor.Interceptor)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)4 Message (org.apache.cxf.message.Message)4 AbstractServiceFactoryBean (org.apache.cxf.service.factory.AbstractServiceFactoryBean)4 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)3 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)3 FactoryBeanListener (org.apache.cxf.service.factory.FactoryBeanListener)3