FileDocCategorySizeDatePackage
ResourceInjectorImpl.javaAPI DocGlassfish v2 API5251Fri May 04 22:36:10 BST 2007com.sun.enterprise.webservice

ResourceInjectorImpl

public class ResourceInjectorImpl extends com.sun.xml.ws.api.server.ResourceInjector
JAXWS Container call back to inject servlet endpoints

Fields Summary
private com.sun.enterprise.deployment.WebServiceEndpoint
endpoint
private com.sun.enterprise.ComponentInvocation
inv
private com.sun.enterprise.InvocationManager
invMgr
Constructors Summary
public ResourceInjectorImpl(com.sun.enterprise.deployment.WebServiceEndpoint ep)

        // 
        Switch theSwitch = Switch.getSwitch();
        invMgr = theSwitch.getInvocationManager();
        inv = invMgr.getCurrentInvocation();
        //
        endpoint = ep;
    
Methods Summary
public voidinject(com.sun.xml.ws.api.server.WSWebServiceContext context, java.lang.Object instance)


        try {
            // Set proper component context
            invMgr.preInvoke(inv);
            // Injection first
            new InjectionManagerImpl().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(wsc != null) {
                        wsc.setContextDelegate(context);
                    }
                }
            }
        } catch (InjectionException ie) {
            throw new WebServiceException(ie);
        } finally {
            invMgr.postInvoke(inv);
        }