if(adapter == null) {
try {
// Set webservice context here
// If the endpoint has a WebServiceContext with @Resource then
// that has to be used
Invocation tmpInv = new Invocation();
tmpInv.isWebService = true;
tmpInv.container = container;
tmpInv.transactionAttribute = Container.TX_NOT_INITIALIZED;
invManager.preInvoke(tmpInv);
EjbDescriptor ejbDesc = endpoint.getEjbComponentImpl();
Iterator<ResourceReferenceDescriptor> it = ejbDesc.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(ejbDesc.getEjbClassName().equals(target.getClassName())) {
matchingClassFound = true;
break;
}
}
if(!matchingClassFound) {
continue;
}
try {
javax.naming.InitialContext ic = new javax.naming.InitialContext();
wsCtxt = (WebServiceContextImpl) ic.lookup("java:comp/env/" + r.getName());
} catch (Throwable t) {
// Swallowed intentionally
}
}
}
if(wsCtxt == null) {
wsCtxt = new WebServiceContextImpl();
}
} catch (Throwable t) {
logger.severe("Cannot initialize endpoint " + endpoint.getName() + " : error is : " + t.getMessage());
return null;
} finally {
invManager.postInvoke(invManager.getCurrentInvocation());
}
}
}
}
if(doPreInvoke) {
// We need to split the preInvoke tasks into stages since handlers
// need access to java:comp/env and method authorization must take
// place before handlers are run. Note that the application
// classloader was set much earlier when the invocation first arrived
// so we don't need to set it here.
Invocation inv = new Invocation();
// Do the portions of preInvoke that don't need a Method object.
inv.isWebService = true;
inv.container = container;
inv.transactionAttribute = Container.TX_NOT_INITIALIZED;
// If the endpoint has at least one handler, method
// authorization will be performed by a container-provided handler
// before any application handler handleRequest methods are called.
// Otherwise, the ejb container will do the authorization.
inv.securityPermissions = Container.SEC_NOT_INITIALIZED;
// AS per latest spec change, the MessageContext object in WebSvcCtxt
// should be the same one as used in the ejb's interceptors'
inv.setContextData(wsCtxt);
// In all cases, the WebServiceInvocationHandler will do the
// remaining preInvoke tasks : getContext, preInvokeTx, etc.
invManager.preInvoke(inv);
}