[jbossws-commits] JBossWS SVN: r15066 - in stack/native/trunk/modules/core/src/main/java/org/jboss: ws/core/jaxws/handler and 2 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Oct 10 10:19:58 EDT 2011


Author: richard.opalka at jboss.com
Date: 2011-10-10 10:19:58 -0400 (Mon, 10 Oct 2011)
New Revision: 15066

Modified:
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeInstanceProvider.java
Log:
switch to Reference instead of Object

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java	2011-10-10 13:14:02 UTC (rev 15065)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/handler/HandlerChainBaseImpl.java	2011-10-10 14:19:58 UTC (rev 15066)
@@ -159,7 +159,7 @@
        final Handler handler;
        if (ep != null)
        {
-           handler = (Handler)ep.getInstanceProvider().getInstance(info.getHandlerClass().getName());
+           handler = (Handler)ep.getInstanceProvider().getInstance(info.getHandlerClass().getName()).getValue();
        }
        else
        {

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java	2011-10-10 13:14:02 UTC (rev 15065)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/HandlerResolverImpl.java	2011-10-10 14:19:58 UTC (rev 15066)
@@ -50,6 +50,7 @@
 import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
 import org.jboss.ws.metadata.umdm.ServiceMetaData;
 import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Reference;
 import org.jboss.wsf.spi.invocation.EndpointAssociation;
 import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
@@ -168,7 +169,7 @@
       try
       {
          // Load the handler class using the deployments top level CL
-         Handler<?> handler = getInstance(classLoader, className);
+         Handler<?> handler = getInstance(classLoader, className, injections);
 
          if (handler instanceof GenericHandler)
             ((GenericHandler)handler).setHandlerName(handlerName);
@@ -176,14 +177,6 @@
          if (handler instanceof GenericSOAPHandler)
             ((GenericSOAPHandler<?>)handler).setHeaders(soapHeaders);
 
-         if (injections != null)
-         {
-            Endpoint ep = EndpointAssociation.getEndpoint();
-            Context ctx = ep == null ? null : ep.getJNDIContext();
-            InjectionHelper.injectResources(handler, injections, ctx);
-         }
-         InjectionHelper.callPostConstructMethod(handler);
-
          addHandler(jaxwsMetaData, handler, type);
       }
       catch (RuntimeException rte)
@@ -196,18 +189,26 @@
       }
    }
 
-   private Handler<?> getInstance(final ClassLoader fallbackLoader, final String className) throws Exception
+   private Handler<?> getInstance(final ClassLoader fallbackLoader, final String className, InjectionsMetaData injections) throws Exception
    {
        final Endpoint ep = EndpointAssociation.getEndpoint();
        final Handler<?> handler;
        if (ep != null)
        {
-           handler = (Handler<?>)ep.getInstanceProvider().getInstance(className);
+           final Reference handlerReference = ep.getInstanceProvider().getInstance(className); 
+           handler = (Handler<?>)handlerReference.getValue();
+           if (!handlerReference.isInitialized() && injections != null)
+           {
+              Context ctx = ep == null ? null : ep.getJNDIContext();
+              InjectionHelper.injectResources(handler, injections, ctx);
+              InjectionHelper.callPostConstructMethod(handler);
+           }
        }
        else
        {
            final Class<?> hClass = fallbackLoader.loadClass(className);
            handler = (Handler<?>)hClass.newInstance();
+           InjectionHelper.callPostConstructMethod(handler);
        }
        return handler;
    }

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java	2011-10-10 13:14:02 UTC (rev 15065)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java	2011-10-10 14:19:58 UTC (rev 15066)
@@ -371,7 +371,7 @@
             {
                // create endpoint instance
                final Class<?> endpointImplClass = endpoint.getTargetBeanClass();
-               endpointImpl = endpoint.getInstanceProvider().getInstance(endpointImplClass.getName());
+               endpointImpl = endpoint.getInstanceProvider().getInstance(endpointImplClass.getName()).getValue();
                endpoint.addAttachment(Object.class, endpointImpl);
             }
             catch (Exception ex)

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeInstanceProvider.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeInstanceProvider.java	2011-10-10 13:14:02 UTC (rev 15065)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/NativeInstanceProvider.java	2011-10-10 14:19:58 UTC (rev 15066)
@@ -28,7 +28,9 @@
 
 import org.jboss.ws.WSException;
 import org.jboss.ws.api.util.BundleUtils;
+import org.jboss.ws.common.deployment.ReferenceFactory;
 import org.jboss.wsf.spi.deployment.InstanceProvider;
+import org.jboss.wsf.spi.deployment.Reference;
 
 /**
  * Native instance provider.
@@ -39,18 +41,18 @@
 
     private static final ResourceBundle bundle = BundleUtils.getBundle(NativeInstanceProvider.class);
     private final ClassLoader loader;
-    private final Map<String, Object> cache = new HashMap<String, Object>();
+    private final Map<String, Reference> cache = new HashMap<String, Reference>();
 
     NativeInstanceProvider(final ClassLoader loader)
     {
         this.loader = loader;
     }
 
-    public synchronized Object getInstance(final String className) {
-        Object instance = cache.get(className);
+    public synchronized Reference getInstance(final String className) {
+        Reference instance = cache.get(className);
         if (instance == null) {
             try {
-                instance = loader.loadClass(className).newInstance();
+                instance = ReferenceFactory.newUninitializedReference(loader.loadClass(className).newInstance());
                 cache.put(className, instance);
             } catch (Exception e) {
                 throw new WSException(BundleUtils.getMessage(bundle, "CANNOT_LOAD_CLASS",  className),  e);



More information about the jbossws-commits mailing list