use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class CXFServiceObjectFactoryJAXWS method getObjectInstance.
public final Object getObjectInstance(UnifiedServiceRefMetaData serviceRef) {
try {
// class names
final String serviceImplClass = this.getServiceClassName(serviceRef);
final String targetClassName = this.getTargetClassName(serviceRef);
// class instances
final Class<?> serviceClass = this.getClass(serviceImplClass);
final Class<?> targetClass = this.getClass(targetClassName);
final Service serviceInstance;
BusFactory.setThreadDefaultBus(null);
final Bus bus = this.createNewBus(serviceRef);
try {
serviceInstance = this.instantiateService(serviceRef, serviceClass);
if (serviceRef.getHandlerChain() != null) {
serviceInstance.setHandlerResolver(new CXFHandlerResolverImpl(bus, serviceRef.getHandlerChain(), serviceInstance.getClass()));
}
// construct port
final boolean instantiatePort = targetClassName != null && !Service.class.isAssignableFrom(targetClass);
if (instantiatePort) {
final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
String forcedAddress = null;
// if there is no wsdlLocation, always use the local deployed endpoint address to initialize port
if (getWsdlURL(serviceRef, serviceClass) == null) {
final QName serviceQName = this.getServiceQName(serviceRef, serviceClass);
forcedAddress = serviceRef.getDeployedServiceAddress(serviceQName);
}
return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures, forcedAddress);
}
} finally {
BusFactory.setThreadDefaultBus(null);
}
return serviceInstance;
} catch (Exception ex) {
WSFException.rethrow("Cannot create service", ex);
}
return null;
}
use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class CXFServiceObjectFactoryJAXWS method getFeatures.
private List<WebServiceFeature> getFeatures(final UnifiedServiceRefMetaData serviceRef) {
List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
// configure @Addressing feature
if (serviceRef.isAddressingAnnotationSpecified()) {
final boolean enabled = serviceRef.isAddressingEnabled();
final boolean required = serviceRef.isAddressingRequired();
final String refResponses = serviceRef.getAddressingResponses();
AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
if ("ANONYMOUS".equals(refResponses))
responses = AddressingFeature.Responses.ANONYMOUS;
if ("NON_ANONYMOUS".equals(refResponses))
responses = AddressingFeature.Responses.NON_ANONYMOUS;
features.add(new AddressingFeature(enabled, required, responses));
}
// configure @MTOM feature
if (serviceRef.isMtomAnnotationSpecified()) {
final boolean enabled = serviceRef.isMtomEnabled();
final int threshold = serviceRef.getMtomThreshold();
features.add(new MTOMFeature(enabled, threshold));
}
// configure @RespectBinding feature
if (serviceRef.isRespectBindingAnnotationSpecified()) {
final boolean enabled = serviceRef.isRespectBindingEnabled();
features.add(new RespectBindingFeature(enabled));
}
return features;
}
use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class CXFServiceRefStubPropertyConfigurer method setWSFeature.
private void setWSFeature(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd) {
List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
if (prevFeatures != null) {
features.addAll(prevFeatures);
}
if (upcmd.isMtomEnabled()) {
if (upcmd.getMtomThreshold() > 0) {
features.add(new MTOMFeature(true, upcmd.getMtomThreshold()));
} else {
features.add(new MTOMFeature(true));
}
}
if (upcmd.isAddressingEnabled()) {
final String refResponses = upcmd.getAddressingResponses();
AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
if ("ANONYMOUS".equals(refResponses))
responses = AddressingFeature.Responses.ANONYMOUS;
if ("NON_ANONYMOUS".equals(refResponses))
responses = AddressingFeature.Responses.NON_ANONYMOUS;
features.add(new AddressingFeature(true, upcmd.isAddressingRequired(), responses));
}
serviceFactoryBean.setWsFeatures(features);
}
use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class ProviderImpl method createServiceDelegate.
@SuppressWarnings("rawtypes")
@Override
public ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName, Class serviceClass, WebServiceFeature... features) {
// check feature types
for (WebServiceFeature f : features) {
final String fName = f.getClass().getName();
if (!fName.startsWith("javax.xml.ws") && !fName.startsWith("org.jboss.ws")) {
throw Messages.MESSAGES.unknownFeature(f.getClass().getName());
}
}
final String busStrategy = ClientBusSelector.getInstance().selectStrategy(features);
ClassLoader origClassLoader = getContextClassLoader();
boolean restoreTCCL = false;
Bus orig = null;
try {
restoreTCCL = checkAndFixContextClassLoader(origClassLoader);
orig = BusFactory.getThreadDefaultBus(false);
Bus bus = getOrCreateBus(busStrategy, origClassLoader);
ServiceDelegate serviceDelegate = new JBossWSServiceImpl(bus, wsdlDocumentLocation, serviceName, serviceClass, features);
setDisableCacheSchema(bus);
return serviceDelegate;
} finally {
restoreThreadDefaultBus(busStrategy, orig);
if (restoreTCCL)
setContextClassLoader(origClassLoader);
}
}
use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class Helper method run.
public Integer run(final URL wsdlURL, final String strategyName, final int size, final int calls) {
final WebServiceFeature feature;
final String strategy;
if (strategyName != null) {
feature = convertToFeature(strategyName);
strategy = strategyName;
} else {
feature = null;
strategy = System.getProperty(Constants.JBWS_CXF_JAXWS_CLIENT_BUS_STRATEGY, null);
}
final BusCounter busCounter = new BusCounter();
final ThreadFactory threadFactory = new ThreadFactory() {
private AtomicInteger i = new AtomicInteger(0);
@Override
public Thread newThread(Runnable r) {
return new Thread(r, "JBWS3373-thread-" + i.getAndIncrement() + "-" + strategy);
}
};
ExecutorService es = Executors.newFixedThreadPool(size, threadFactory);
List<Client> clients = new ArrayList<Helper.Client>();
for (int i = 0; i < calls; i++) {
clients.add(new Client(wsdlURL, feature, busCounter));
}
int count = 0;
try {
List<Future<Boolean>> futures = es.invokeAll(clients);
for (Future<Boolean> f : futures) {
if (f.get()) {
count++;
}
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
es.shutdown();
}
if (count != calls) {
throw new RuntimeException((calls - count) + " client invocation(s) failed!");
}
return busCounter.getCount();
}
Aggregations