use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class ClientBusSelector method selectStrategy.
public String selectStrategy(WebServiceFeature... features) {
boolean createNewBus = false;
boolean tcclBoundBus = false;
boolean threadBus = false;
int count = 0;
if (features != null) {
for (WebServiceFeature f : features) {
final String className = f.getClass().getName();
if (UseNewBusFeature.class.getName().equals(className)) {
createNewBus = f.isEnabled();
count++;
} else if (UseTCCLBusFeature.class.getName().equals(className)) {
tcclBoundBus = f.isEnabled();
count++;
} else if (UseThreadBusFeature.class.getName().equals(className)) {
threadBus = f.isEnabled();
count++;
}
}
}
if (count > 1) {
throw Messages.MESSAGES.incompatibleJAXWSClientBusFeatureProvided();
}
String featureStrategy = null;
if (createNewBus) {
featureStrategy = NEW_BUS_STRATEGY;
} else if (tcclBoundBus) {
featureStrategy = TCCL_BUS_STRATEGY;
} else if (threadBus) {
featureStrategy = THREAD_BUS_STRATEGY;
}
return featureStrategy != null ? featureStrategy : sysPropStrategy;
}
use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.
the class JBWS2150TestCase method getEndpoint.
private ServiceIface getEndpoint(String wsdlLocation, String serviceName) throws Exception {
List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
if (isIntegrationCXF()) {
// Setting UseNewBusFeature as the tests here deploy / undeploy endpoints with different wsdl at the same URL
// so we need to avoid caching issues related to the WSDLManager in the CXF Bus.
// Service service = Service.create(new URL(wsdlLocation), new QName(NAMESPACE, serviceName), new UseNewBusFeature())
Class<?> clazz = Class.forName("org.jboss.wsf.stack.cxf.client.UseNewBusFeature");
features.add((WebServiceFeature) clazz.newInstance());
}
Service service = Service.create(new URL(wsdlLocation), new QName(NAMESPACE, serviceName), features.toArray(new WebServiceFeature[features.size()]));
QName portName = service.getPorts().next();
return service.getPort(portName, ServiceIface.class);
}
use of javax.xml.ws.WebServiceFeature in project tomee by apache.
the class JaxWsServiceReference method getObject.
public Object getObject() throws NamingException {
final String referenceClassName = referenceClass != null ? referenceClass.getName() : null;
final Set<PortAddress> portAddresses = getPortAddressRegistry().getPorts(id, serviceQName, referenceClassName);
// if we only have one address, use that address for the wsdl and the serviceQName
URL wsdlUrl = this.wsdlUrl;
QName serviceQName = this.serviceQName;
if (portAddresses.size() == 1) {
final PortAddress portAddress = portAddresses.iterator().next();
try {
wsdlUrl = new URL(portAddress.getAddress() + "?wsdl");
} catch (final MalformedURLException e) {
// no-op
}
serviceQName = portAddress.getServiceQName();
}
// add the port addresses to the portRefData
final Map<QName, PortRefData> portsByQName = new HashMap<>();
final List<PortRefData> ports = new ArrayList<>(portRefs.size() + portAddresses.size());
for (final PortRefData portRef : portRefs) {
final PortRefData port = new PortRefData(portRef);
if (port.getQName() != null) {
portsByQName.put(port.getQName(), port);
}
ports.add(port);
}
// add PortRefData for any portAddress not added above
for (final PortAddress portAddress : portAddresses) {
PortRefData port = portsByQName.get(portAddress.getPortQName());
if (port == null) {
port = new PortRefData();
port.setQName(portAddress.getPortQName());
port.setServiceEndpointInterface(portAddress.getServiceEndpointInterface());
port.getAddresses().add(portAddress.getAddress());
ports.add(port);
} else {
port.getAddresses().add(portAddress.getAddress());
if (port.getServiceEndpointInterface() == null) {
port.setServiceEndpointInterface(portAddress.getServiceEndpointInterface());
}
}
}
final WebServiceClientCustomizer customizer = SystemInstance.get().getComponent(WebServiceClientCustomizer.class);
final Properties configuration = properties == null ? new Properties() : properties;
ProviderWrapper.beforeCreate(ports, customizer, properties);
Service instance;
try {
instance = null;
if (Service.class.equals(serviceClass)) {
instance = Service.create(wsdlUrl, serviceQName);
} else {
try {
instance = serviceClass.getConstructor(URL.class, QName.class).newInstance(wsdlUrl, serviceQName);
} catch (final Throwable e) {
throw (NamingException) new NamingException("Could not instantiate jax-ws service class " + serviceClass.getName()).initCause(e);
}
}
} finally {
ProviderWrapper.afterCreate();
}
if (!handlerChains.isEmpty()) {
final HandlerResolver handlerResolver = new HandlerResolverImpl(handlerChains, injections, new InitialContext());
instance.setHandlerResolver(handlerResolver);
}
final Object port;
if (referenceClass != null && !Service.class.isAssignableFrom(referenceClass)) {
final WebServiceFeature[] features = customizer == null ? null : customizer.features(serviceQName, configuration);
// do port lookup
if (features == null || features.length == 0) {
port = instance.getPort(referenceClass);
} else {
port = instance.getPort(referenceClass, features);
}
} else {
// return service
port = instance;
}
// register the service data so it can be fetched when the service is passed over the EJBd protocol
final ServiceRefData serviceRefData = new ServiceRefData(id, serviceQName, serviceClass, portQName, referenceClass, wsdlUrl, handlerChains, portRefs);
ServiceRefData.putServiceRefData(port, serviceRefData);
return port;
}
use of javax.xml.ws.WebServiceFeature in project tomee by apache.
the class CxfEndpoint method configureService.
protected static JaxWsServiceFactoryBean configureService(final JaxWsServiceFactoryBean serviceFactory, final ServiceConfiguration configuration, final String prefix) {
final Properties beanConfig = configuration.getProperties();
if (beanConfig == null || beanConfig.isEmpty()) {
return serviceFactory;
}
final Collection<ServiceInfo> availableServices = configuration.getAvailableServices();
// databinding
final String databinding = beanConfig.getProperty(prefix + CxfUtil.DATABINDING);
if (databinding != null && !databinding.trim().isEmpty()) {
Object instance = ServiceInfos.resolve(availableServices, databinding);
if (instance == null) {
// maybe id == classname
try {
instance = Thread.currentThread().getContextClassLoader().loadClass(databinding).newInstance();
} catch (Exception e) {
// ignore
}
}
if (!DataBinding.class.isInstance(instance)) {
throw new OpenEJBRuntimeException(instance + " is not a " + DataBinding.class.getName() + ", please check configuration of service [id=" + databinding + "]");
}
serviceFactory.setDataBinding((DataBinding) instance);
}
final String wsFeatures = beanConfig.getProperty(prefix + "wsFeatures");
if (wsFeatures != null) {
final Collection<Object> instances = ServiceInfos.resolve(availableServices, wsFeatures.split(" *, *"));
if (instances != null && !instances.isEmpty()) {
final List<WebServiceFeature> features = new ArrayList<>(instances.size());
for (final Object i : instances) {
if (!WebServiceFeature.class.isInstance(i)) {
throw new IllegalArgumentException("Not a WebServiceFeature: " + i);
}
features.add(WebServiceFeature.class.cast(i));
}
serviceFactory.setWsFeatures(features);
}
}
return serviceFactory;
}
use of javax.xml.ws.WebServiceFeature in project Payara by payara.
the class WSServletContextListener method registerEndpoint.
private void registerEndpoint(WebServiceEndpoint endpoint, ServletContext servletContext) throws Exception {
ClassLoader classLoader = servletContext.getClassLoader();
WsUtil wsu = new WsUtil();
// Complete all the injections that are required
Class serviceEndpointClass = Class.forName(endpoint.getServletImplClass(), true, classLoader);
// Get the proper binding using BindingID
String givenBinding = endpoint.getProtocolBinding();
// TODO Rama
// if(endpoint.getWsdlExposed() != null) {
// wsdlExposed = Boolean.parseBoolean(endpoint.getWsdlExposed());
// }
// Get list of all wsdls and schema
SDDocumentSource primaryWsdl = null;
Collection docs = null;
if (endpoint.getWebService().hasWsdlFile()) {
URL pkgedWsdl = null;
try {
pkgedWsdl = servletContext.getResource('/' + endpoint.getWebService().getWsdlFileUri());
} catch (MalformedURLException e) {
logger.log(Level.SEVERE, LogUtils.CANNOT_LOAD_WSDL_FROM_APPLICATION, e.getMessage());
}
if (pkgedWsdl == null) {
pkgedWsdl = endpoint.getWebService().getWsdlFileUrl();
}
if (pkgedWsdl != null) {
primaryWsdl = SDDocumentSource.create(pkgedWsdl);
docs = wsu.getWsdlsAndSchemas(pkgedWsdl);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, LogUtils.CREATING_ENDPOINT_FROM_PACKAGED_WSDL, primaryWsdl.getSystemId().toString());
logger.log(Level.FINE, LogUtils.METADATA_DOCS);
for (Object source : docs) {
logger.log(Level.FINE, ((SDDocumentSource) source).getSystemId().toString());
}
}
}
}
// Create a Container to pass ServletContext and also inserting the pipe
JAXWSContainer container = new JAXWSContainer(servletContext, endpoint);
// Get catalog info
java.net.URL catalogURL = servletContext.getResource('/' + endpoint.getBundleDescriptor().getDeploymentDescriptorDir() + File.separator + "jax-ws-catalog.xml");
// Create Binding and set service side handlers on this binding
boolean mtomEnabled = wsu.getMtom(endpoint);
WSBinding binding = null;
// Only if MTOm is enabled create the Binding with the MTOMFeature
ArrayList<WebServiceFeature> wsFeatures = new ArrayList<WebServiceFeature>();
// Only if MTOm is enabled create the Binding with the MTOMFeature
if (mtomEnabled) {
int mtomThreshold = endpoint.getMtomThreshold() != null ? Integer.parseInt(endpoint.getMtomThreshold()) : 0;
MTOMFeature mtom = new MTOMFeature(true, mtomThreshold);
wsFeatures.add(mtom);
}
Addressing addressing = endpoint.getAddressing();
if (addressing != null) {
AddressingFeature addressingFeature = new AddressingFeature(addressing.isEnabled(), addressing.isRequired(), getResponse(addressing.getResponses()));
wsFeatures.add(addressingFeature);
}
RespectBinding rb = endpoint.getRespectBinding();
if (rb != null) {
RespectBindingFeature rbFeature = new RespectBindingFeature(rb.isEnabled());
wsFeatures.add(rbFeature);
}
if (endpoint.getValidateRequest() != null && Boolean.parseBoolean(endpoint.getValidateRequest())) {
// enable SchemaValidationFeature
wsFeatures.add(new SchemaValidationFeature());
}
if (endpoint.getStreamAttachments() != null && Boolean.parseBoolean(endpoint.getStreamAttachments())) {
// enable StreamingAttachmentsFeature
wsFeatures.add(new StreamingAttachmentFeature());
}
if (endpoint.getReliabilityConfig() != null) {
// TODO Revisit later after Metro provides generic method to pass partial configuration to Metro runtime.
// Only partial configuration is specified in webservices DD, but the information for creating complete RM feature should be gathered
// from wsdl policy, annotation or metro configuration file. For ex: RmProtocolVersion would be decided by policy assertion.
// For now, the feature would be constructed from default values, overriding any configuration specified in wsdl or metro configuration file..
ReliabilityConfig rxConfig = endpoint.getReliabilityConfig();
ReliableMessagingFeatureBuilder rmbuilder = new ReliableMessagingFeatureBuilder(RmProtocolVersion.getDefault());
if (rxConfig.getInactivityTimeout() != null) {
rmbuilder.sequenceInactivityTimeout(Long.parseLong(rxConfig.getInactivityTimeout().trim()));
}
if (endpoint.getHttpResponseBufferSize() != null) {
rmbuilder.destinationBufferQuota(Long.parseLong(endpoint.getHttpResponseBufferSize().trim()));
}
if (rxConfig.getBaseRetransmissionInterval() != null) {
rmbuilder.messageRetransmissionInterval(Long.parseLong(rxConfig.getBaseRetransmissionInterval().trim()));
}
if (rxConfig.getRetransmissionExponentialBackoff() != null) {
rmbuilder.retransmissionBackoffAlgorithm(Boolean.parseBoolean(rxConfig.getRetransmissionExponentialBackoff()) ? ReliableMessagingFeature.BackoffAlgorithm.EXPONENTIAL : ReliableMessagingFeature.BackoffAlgorithm.getDefault());
}
if (rxConfig.getAcknowledgementInterval() != null) {
rmbuilder.acknowledgementTransmissionInterval(Long.parseLong(rxConfig.getAcknowledgementInterval().trim()));
}
if (rxConfig.getSequenceExpiration() != null) {
logger.log(Level.INFO, LogUtils.CONFIGURATION_IGNORE_IN_WLSWS, new Object[] { endpoint.getEndpointName(), "<sequence-expiration>" });
}
if (rxConfig.getBufferRetryCount() != null) {
rmbuilder.maxMessageRetransmissionCount(Long.parseLong(rxConfig.getBufferRetryCount().trim()));
}
if (rxConfig.getBufferRetryDelay() != null) {
logger.log(Level.INFO, LogUtils.CONFIGURATION_IGNORE_IN_WLSWS, new Object[] { endpoint.getEndpointName(), "<buffer-retry-delay>" });
}
wsFeatures.add(rmbuilder.build());
} else {
if (endpoint.getHttpResponseBufferSize() != null) {
logger.log(Level.WARNING, LogUtils.CONFIGURATION_UNSUPPORTED_IN_WLSWS, new Object[] { endpoint.getEndpointName(), "<http-response-buffersize>" });
}
}
if (wsFeatures.size() > 0) {
binding = BindingID.parse(givenBinding).createBinding(wsFeatures.toArray(new WebServiceFeature[wsFeatures.size()]));
} else {
binding = BindingID.parse(givenBinding).createBinding();
}
wsu.configureJAXWSServiceHandlers(endpoint, givenBinding, binding);
// See if it is configured with JAX-WS extension InstanceResolver annotation like
// @com.sun.xml.ws.developer.servlet.HttpSessionScope or @com.sun.xml.ws.developer.Stateful
InstanceResolver ir = InstanceResolver.createFromInstanceResolverAnnotation(serviceEndpointClass);
// TODO - Implement 109 StatefulInstanceResolver ??
if (ir == null) {
// use our own InstanceResolver that does not call @PostConstuct method before
// @Resource injections have happened.
ir = new InstanceResolverImpl(serviceEndpointClass);
}
Invoker inv = ir.createInvoker();
WSEndpoint wsep = WSEndpoint.create(// The endpoint class
serviceEndpointClass, // we do not want JAXWS to process @HandlerChain
false, inv, // the service QName
endpoint.getServiceName(), // the port
endpoint.getWsdlPort(), // Our container with info on security/monitoring pipe
container, // Derive binding
binding, // primary WSDL
primaryWsdl, // Collection of imported WSDLs and schema
docs, catalogURL);
// Fix for 6852 Add the ServletAdapter which implements the BoundEndpoint
// container.addEndpoint(wsep);
// For web components, this will be relative to the web app
// context root. Make sure there is a leading slash.
String uri = endpoint.getEndpointAddressUri();
String urlPattern = uri.startsWith("/") ? uri : "/" + uri;
// The whole web app should have a single adapter list
// This is to enable JAXWS publish WSDLs with proper addresses
ServletAdapter adapter;
synchronized (this) {
ServletAdapterList list = (ServletAdapterList) servletContext.getAttribute("ADAPTER_LIST");
if (list == null) {
list = new ServletAdapterList();
servletContext.setAttribute("ADAPTER_LIST", list);
}
adapter = ServletAdapter.class.cast(list.createAdapter(endpoint.getName(), urlPattern, wsep));
container.addEndpoint(adapter);
}
registerEndpointUrlPattern(urlPattern, adapter);
}
Aggregations