use of com.sun.enterprise.container.common.spi.util.InjectionManager 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 com.sun.enterprise.container.common.spi.util.InjectionManager 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 com.sun.enterprise.container.common.spi.util.InjectionManager 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 com.sun.enterprise.container.common.spi.util.InjectionManager in project Payara by payara.
the class ResourceInjectorImpl method inject.
public void inject(WSWebServiceContext context, Object instance) throws WebServiceException {
try {
// Set proper component context
invMgr.preInvoke(inv);
// Injection first
InjectionManager injManager = WebServiceContractImpl.getInstance().getInjectionManager();
injManager.injectInstance(instance);
// Set webservice context here
// If the endpoint has a WebServiceContext with @Resource then
// that has to be used
WebServiceContextImpl wsc = null;
WebBundleDescriptor bundle = (WebBundleDescriptor) endpoint.getBundleDescriptor();
Iterator<ResourceReferenceDescriptor> it = bundle.getResourceReferenceDescriptors().iterator();
while (it.hasNext()) {
ResourceReferenceDescriptor r = it.next();
if (r.isWebServiceContext()) {
Iterator<InjectionTarget> iter = r.getInjectionTargets().iterator();
boolean matchingClassFound = false;
while (iter.hasNext()) {
InjectionTarget target = iter.next();
if (endpoint.getServletImplClass().equals(target.getClassName())) {
matchingClassFound = true;
break;
}
}
if (!matchingClassFound) {
continue;
}
try {
javax.naming.InitialContext ic = new javax.naming.InitialContext();
wsc = (WebServiceContextImpl) ic.lookup("java:comp/env/" + r.getName());
} catch (Throwable t) {
// Do something here
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, LogUtils.EXCEPTION_THROWN, t);
}
}
if (wsc != null) {
wsc.setContextDelegate(context);
// needed to support isUserInRole() on WSC;
wsc.setServletName(bundle.getWebComponentDescriptors());
}
}
}
} catch (InjectionException ie) {
throw new WebServiceException(ie);
} finally {
invMgr.postInvoke(inv);
}
}
Aggregations