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);
}
}
}
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();
}
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();
}
}
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);
}
}
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);
}
}
}
Aggregations