use of javax.xml.ws.handler.Handler in project Payara by payara.
the class WSServletContextListener method contextDestroyed.
@Override
public void contextDestroyed(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
synchronized (this) {
ServletAdapterList list = (ServletAdapterList) servletContext.getAttribute("ADAPTER_LIST");
if (list != null) {
for (ServletAdapter x : list) {
x.getEndpoint().dispose();
for (Handler handler : x.getEndpoint().getBinding().getHandlerChain()) {
try {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
InjectionManager injManager = wscImpl.getInjectionManager();
injManager.destroyManagedObject(handler);
} catch (InjectionException e) {
logger.log(Level.WARNING, LogUtils.DESTORY_ON_HANDLER_FAILED, new Object[] { handler.getClass(), x.getEndpoint().getServiceName(), e.getMessage() });
continue;
}
}
}
servletContext.removeAttribute("ADAPTER_LIST");
}
JAXWSAdapterRegistry.getInstance().removeAdapter(contextRoot);
/*
Fix for bug 3932/4052 since the x.getEndpoint().dispose is being
called above we do not need to call this explicitly
try {
(new WsUtil()).doPreDestroy(endpoint, classLoader);
} catch (Throwable t) {
logger.log(Level.WARNING, "@PreDestroy lifecycle call failed for service"
+ endpoint.getName(), t);
}*/
}
JAXWSServletModule.destroy(contextRoot);
}
use of javax.xml.ws.handler.Handler in project Payara by payara.
the class WebServiceEjbEndpointRegistry method unregisterEndpoint.
@Override
public void unregisterEndpoint(String endpointAddressUri) {
EjbRuntimeEndpointInfo endpoint = null;
synchronized (webServiceEjbEndpoints) {
String uriRaw = endpointAddressUri;
String uri = (uriRaw.charAt(0) == '/') ? uriRaw.substring(1) : uriRaw;
ServletAdapterList list = adapterListMap.get(uri);
if (list != null) {
// since we are using the uri in the adapterListMap
for (ServletAdapter x : list) {
x.getEndpoint().dispose();
for (Handler handler : x.getEndpoint().getBinding().getHandlerChain()) {
try {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
if (wscImpl.getInvocationManager().getCurrentInvocation() != null) {
InjectionManager injManager = wscImpl.getInjectionManager();
injManager.destroyManagedObject(handler);
}
} catch (InjectionException e) {
logger.log(Level.WARNING, LogUtils.DESTORY_ON_HANDLER_FAILED, new Object[] { handler.getClass(), x.getEndpoint().getServiceName(), e.getMessage() });
continue;
}
}
}
// Fix for issue 9523
adapterListMap.remove(uri);
}
endpoint = (EjbRuntimeEndpointInfo) webServiceEjbEndpoints.remove(uri);
regenerateEjbContextRoots();
}
if (endpoint == null) {
return;
}
// notify the monitoring layers that an endpoint is destroyed
WebServiceEngineImpl engine = WebServiceEngineImpl.getInstance();
engine.removeHandler(endpoint.getEndpoint());
}
use of javax.xml.ws.handler.Handler in project Payara by payara.
the class WsUtil method configureJAXWSClientHandlers.
public void configureJAXWSClientHandlers(javax.xml.ws.Service svcClass, ServiceReferenceDescriptor desc) {
// Create a resolver and get all ports for the Service
HandlerResolverImpl resolver = new HandlerResolverImpl();
Set<String> roles = new HashSet();
Iterator<QName> ports = svcClass.getPorts();
// Set handler chain for each port of this service
while (ports.hasNext()) {
QName nextPort = ports.next();
LinkedList handlerChainList = desc.getHandlerChain();
for (Iterator<WebServiceHandlerChain> i = handlerChainList.iterator(); i.hasNext(); ) {
WebServiceHandlerChain hc = i.next();
// that the handlers are for this service and this port
if (!patternsMatch(hc, desc.getServiceName(), nextPort, null)) {
continue;
}
// Decide for what all protocols this handler should be applied
ArrayList<String> protocols = new ArrayList<String>();
if (hc.getProtocolBindings() == null) {
// No protocol bindings given in descriptor; apply this handler
// for all protocols
protocols.add(HTTPBinding.HTTP_BINDING);
protocols.add(SOAPBinding.SOAP11HTTP_BINDING);
protocols.add(SOAPBinding.SOAP12HTTP_BINDING);
protocols.add(SOAPBinding.SOAP11HTTP_MTOM_BINDING);
protocols.add(SOAPBinding.SOAP12HTTP_MTOM_BINDING);
} else {
// protocols specified; handlers are for only these protocols
String specifiedProtocols = hc.getProtocolBindings();
if ((specifiedProtocols.indexOf(HTTPBinding.HTTP_BINDING) != -1) || (specifiedProtocols.indexOf(WebServiceEndpoint.XML_TOKEN) != -1)) {
protocols.add(HTTPBinding.HTTP_BINDING);
}
if ((specifiedProtocols.indexOf(SOAPBinding.SOAP11HTTP_BINDING) != -1) || (specifiedProtocols.indexOf(WebServiceEndpoint.SOAP11_TOKEN) != -1)) {
protocols.add(SOAPBinding.SOAP11HTTP_BINDING);
}
if ((specifiedProtocols.indexOf(SOAPBinding.SOAP12HTTP_BINDING) != -1) || (specifiedProtocols.indexOf(WebServiceEndpoint.SOAP12_TOKEN) != -1)) {
protocols.add(SOAPBinding.SOAP12HTTP_BINDING);
}
if ((specifiedProtocols.indexOf(SOAPBinding.SOAP11HTTP_MTOM_BINDING) != -1) || (specifiedProtocols.indexOf(WebServiceEndpoint.SOAP11_MTOM_TOKEN) != -1)) {
protocols.add(SOAPBinding.SOAP11HTTP_MTOM_BINDING);
}
if ((specifiedProtocols.indexOf(SOAPBinding.SOAP12HTTP_MTOM_BINDING) != -1) || (specifiedProtocols.indexOf(WebServiceEndpoint.SOAP12_MTOM_TOKEN) != -1)) {
protocols.add(SOAPBinding.SOAP12HTTP_MTOM_BINDING);
}
}
// Iterate through all handlers that have been configured
List<WebServiceHandler> handlersList = hc.getHandlers();
// than the current port
for (WebServiceHandler thisOne : handlersList) {
Collection portNames = thisOne.getPortNames();
if (!portNames.isEmpty() && !portNames.contains(nextPort.getLocalPart())) {
handlersList.remove(thisOne);
}
}
// Now you have the handlers that need to be added; process them
List<Handler> handlerInfo = processConfiguredHandlers(handlersList, roles);
// one set for each protocol
for (Iterator<String> s = protocols.iterator(); s.hasNext(); ) {
javax.xml.ws.handler.PortInfo portInfo;
portInfo = new PortInfoImpl(BindingID.parse(s.next()), nextPort, desc.getServiceName());
resolver.setHandlerChain(portInfo, handlerInfo);
}
}
}
// Now that processing of all handlers is over, set HandlerResolver for
// the service
svcClass.setHandlerResolver(resolver);
// XXX TODO : What to do with soap roles on client side ?
}
use of javax.xml.ws.handler.Handler in project Payara by payara.
the class WsUtil method processConfiguredHandlers.
private List<Handler> processConfiguredHandlers(List<WebServiceHandler> handlersList, Set<String> roles) {
List<Handler> handlerChain = new ArrayList<Handler>();
for (WebServiceHandler h : handlersList) {
Handler handler = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
// Get Handler Class instance
Class handlerClass;
try {
handlerClass = Class.forName(h.getHandlerClass(), true, loader);
} catch (Throwable t) {
String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.HANDLER_UNABLE_TO_ADD), h.getHandlerClass());
logger.log(Level.SEVERE, msg, t);
continue;
}
// perform injection
try {
WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
InjectionManager injManager = wscImpl.getInjectionManager();
// PostConstruct is invoked by createManagedObject as well
handler = (Handler) injManager.createManagedObject(handlerClass);
} catch (InjectionException e) {
logger.log(Level.SEVERE, LogUtils.HANDLER_INJECTION_FAILED, new Object[] { h.getHandlerClass(), e.getMessage() });
continue;
}
// Add soap-roles
Collection<String> rolesColl = h.getSoapRoles();
roles.addAll(rolesColl);
// Add this handler to the mail list
handlerChain.add(handler);
}
return handlerChain;
}
use of javax.xml.ws.handler.Handler in project Payara by payara.
the class HandlerResolverImpl method getHandlerChain.
public List<Handler> getHandlerChain(PortInfo info) {
Iterator<PortInfo> piSet = chainMap.keySet().iterator();
List<Handler> chain = null;
while (piSet.hasNext()) {
PortInfo next = piSet.next();
PortInfoImpl tmp = new PortInfoImpl(BindingID.parse(info.getBindingID()), info.getPortName(), info.getServiceName());
if (tmp.equals(next)) {
chain = chainMap.get(next);
break;
}
}
if (chain == null) {
chain = new ArrayList<Handler>();
}
return chain;
}
Aggregations