[jboss-cvs] JBossAS SVN: r80774 - in projects/ejb3/trunk/core: src/main/java/org/jboss/ejb3/proxy and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 10 19:13:15 EST 2008


Author: ALRubinger
Date: 2008-11-10 19:13:15 -0500 (Mon, 10 Nov 2008)
New Revision: 80774

Added:
   projects/ejb3/trunk/core/src/test/resources/servicecontainer-beans.xml
Removed:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/service/
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/handler/service/
Modified:
   projects/ejb3/trunk/core/pom.xml
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/ProxyFactory.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
   projects/ejb3/trunk/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
   projects/ejb3/trunk/core/src/test/resources/org/jboss/ejb3/core/test/regression/ejbthree1253/remoteproxyfactoryregistry-beans.xml
Log:
[EJBTHREE-1573] Refactor ServiceContainer off old proxy mechanism and onto jboss-ejb3-proxy

Modified: projects/ejb3/trunk/core/pom.xml
===================================================================
--- projects/ejb3/trunk/core/pom.xml	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/pom.xml	2008-11-11 00:13:15 UTC (rev 80774)
@@ -376,13 +376,13 @@
     <dependency>
       <groupId>org.jboss.ejb3</groupId>
       <artifactId>jboss-ejb3-proxy</artifactId>
-      <version>1.0.0-Beta2</version>
+      <version>1.0.0-SNAPSHOT</version>
     </dependency>
     
     <dependency>
       <groupId>org.jboss.ejb3</groupId>
       <artifactId>jboss-ejb3-proxy-clustered</artifactId>
-      <version>1.0.0-Beta2</version>
+      <version>1.0.0-SNAPSHOT</version>
     </dependency>
    
     <dependency>

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/ProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/ProxyFactory.java	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/ProxyFactory.java	2008-11-11 00:13:15 UTC (rev 80774)
@@ -28,6 +28,7 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision$
  */
+ at Deprecated
 public interface ProxyFactory
 {
    /**

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2008-11-11 00:13:15 UTC (rev 80774)
@@ -54,16 +54,19 @@
 import org.jboss.ejb.AllowedOperationsFlags;
 import org.jboss.ejb3.BeanContext;
 import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.annotation.LocalBinding;
 import org.jboss.ejb3.annotation.Management;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.annotation.Service;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
-import org.jboss.ejb3.proxy.ProxyFactory;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
+import org.jboss.ejb3.proxy.container.InvokableContext;
 import org.jboss.ejb3.proxy.factory.RemoteProxyFactory;
-import org.jboss.ejb3.proxy.factory.service.ServiceLocalProxyFactory;
-import org.jboss.ejb3.proxy.factory.service.ServiceRemoteProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.service.ServiceRemoteProxyFactory;
+import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
 import org.jboss.ejb3.session.SessionContainer;
 import org.jboss.ejb3.stateful.StatefulContainerInvocation;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
@@ -75,40 +78,49 @@
 import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
 import org.jboss.util.NotImplementedException;
 
+
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
  */
-public class ServiceContainer extends SessionContainer implements TimedObjectInvoker
+public class ServiceContainer extends SessionContainer implements TimedObjectInvoker, InvokableContext
 {
    ServiceMBeanDelegate delegate;
+
    Object singleton;
+
    BeanContext beanContext;
+
    MBeanServer mbeanServer;
+
    ObjectName delegateObjectName;
+
    private TimerService timerService;
+
    private Object mbean = new ServiceDelegateWrapper(this);
-   
+
    private Method timeoutMethod;
-   
+
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(ServiceContainer.class);
 
-   public ServiceContainer(MBeanServer server, ClassLoader cl, String beanClassName, String ejbName,
-                           Domain domain, Hashtable ctxProperties,
-                           Ejb3Deployment deployment, JBossServiceBeanMetaData beanMetaData) throws ClassNotFoundException
+   public ServiceContainer(MBeanServer server, ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+         Hashtable ctxProperties, Ejb3Deployment deployment, JBossServiceBeanMetaData beanMetaData)
+         throws ClassNotFoundException
    {
       super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
       this.mbeanServer = server;
-      
+
       initializeTimeoutMethod();
    }
 
    // TODO: integrate with StatelessContainer.callTimeout
    public void callTimeout(Timer timer) throws Exception
    {
-      if (timeoutMethod == null) throw new EJBException("No method has been annotated with @Timeout");
-      Object[] args = {timer};
+      if (timeoutMethod == null)
+         throw new EJBException("No method has been annotated with @Timeout");
+      Object[] args =
+      {timer};
       AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsFlags.IN_EJB_TIMEOUT);
       try
       {
@@ -116,7 +128,8 @@
       }
       catch (Throwable throwable)
       {
-         if (throwable instanceof Exception) throw (Exception) throwable;
+         if (throwable instanceof Exception)
+            throw (Exception) throwable;
          throw new RuntimeException(throwable);
       }
       finally
@@ -130,18 +143,40 @@
    {
       return new ServiceBeanContext(this, singleton);
    }
-   
+
    @Override
-   protected ProxyFactory getProxyFactory(LocalBinding binding)
+   @Deprecated
+   protected org.jboss.ejb3.proxy.factory.SessionProxyFactory getProxyFactory(LocalBinding binding)
    {
-      return new ServiceLocalProxyFactory(this, binding);
+     throw new NotImplementedException("@Service container is using old Proxy mechanism");
    }
-   
+
    @Override
    protected SessionProxyFactory getProxyFactory(RemoteBinding binding)
    {
-      throw new NotImplementedException(
-            "@Service does not yet use EJB3 Proxy Implementation, call 'getProxyFactoryForService' instead");
+      //TODO Should be obtained from JNDI Registrar, needs to be looked up by a @RemoteBinding key
+
+      /*
+       * In this implementation we just make a new Proxy Factory, for now
+       */
+
+      // Create
+      SessionProxyFactory factory = new ServiceRemoteProxyFactory(this.getName(), this.getName(), Ejb3Registry
+            .guid(this), (JBossServiceBeanMetaData) this.getMetaData(), this.getClassloader(), binding.clientBindUrl(),
+            this.getAdvisor(), binding.interceptorStack());
+
+      // Start the factory
+      try
+      {
+         factory.start();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Error in starting " + factory, e);
+      }
+
+      // Return
+      return factory;
    }
 
    /**
@@ -152,32 +187,42 @@
    @Deprecated
    public RemoteProxyFactory getProxyFactoryForService(RemoteBinding binding)
    {
-      // TODO Implement clustering
-      return new ServiceRemoteProxyFactory(this, binding);
+      throw new NotImplementedException(this + " is no longer using unsupported (legacy) proxy impl from ejb3-core");
    }
-   
+
    // TODO: integrate with StatelessContainer.initializeTimeout
    private void initializeTimeoutMethod()
    {
       JBossSessionBeanMetaData metaData = getMetaData();
       NamedMethodMetaData timeoutMethodMetaData = null;
-      if(metaData != null)
+      if (metaData != null)
          timeoutMethodMetaData = metaData.getTimeoutMethod();
       this.timeoutMethod = getTimeoutCallback(timeoutMethodMetaData, getBeanClass());
    }
-   
+
    public Serializable createSession(Class<?> initTypes[], Object initArgs[])
    {
-//      if((initTypes != null && initTypes.length > 0) || (initArgs != null && initArgs.length > 0))
-//         throw new IllegalArgumentException("service bean create method must take no arguments");
+      //      if((initTypes != null && initTypes.length > 0) || (initArgs != null && initArgs.length > 0))
+      //         throw new IllegalArgumentException("service bean create method must take no arguments");
       throw new UnsupportedOperationException("Service Containers have no Sessions");
    }
+   
+   /**
+    * Returns the name under which the JNDI Registrar for this container is bound
+    * 
+    * @return
+    */
+   protected String getJndiRegistrarBindName()
+   {
+      return isClustered() ? ClusteredObjectStoreBindings.CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE
+                           : ObjectStoreBindings.OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SERVICE;
+   }
 
    public Object getMBean()
    {
       return mbean;
    }
-   
+
    public Object getSingleton()
    {
       return singleton;
@@ -186,13 +231,13 @@
    public void create() throws Exception
    {
       super.create();
-      
+
       // EJBTHREE-655: fire up an instance for use as MBean delegate
       singleton = super.construct();
 
       // won't work, before starting the management interface MBean injection must have been done.
       //registerManagementInterface();
-      
+
       invokeOptionalMethod("create");
    }
 
@@ -226,21 +271,20 @@
       }
       return interfaces;
    }
-   
+
    protected void reinitialize()
    {
       super.reinitialize();
-      
+
       singleton = super.construct();
- 
+
       invokeOptionalMethod("create");
    }
-   
+
    @Override
    protected void lockedStart() throws Exception
    {
       super.lockedStart();
-      proxyDeployer.start();
 
       try
       {
@@ -253,23 +297,23 @@
 
          // TODO: EJBTHREE-655: shouldn't happen here, but in create
          registerManagementInterface();
-         
+
          TimerServiceFactory.getInstance().restoreTimerService(timerService);
-         
+
          invokeOptionalMethod("start");
       }
       catch (Exception e)
       {
-         e.printStackTrace();
+         log.error("Encountered an error in start of " + this.getMetaData().getEjbName(), e);
          this.lockedStop();
       }
    }
 
    @Override
    protected void lockedStop() throws Exception
-   {      
+   {
       invokeOptionalMethod("stop");
-      
+
       if (timerService != null)
       {
          TimerServiceFactory.getInstance().removeTimerService(timerService);
@@ -278,28 +322,20 @@
 
       // TODO: EJBTHREE-655: shouldn't happen here, but in destroy
       unregisterManagementInterface();
-      
+
       singleton = null;
       beanContext = null;
-      
+
       super.lockedStop();
-      
-      try
-      {
-         proxyDeployer.stop();
-      }
-      catch (Exception ignore)
-      {
-         log.debug("Proxy deployer stop failed", ignore);
-      }
+
    }
 
    public void destroy() throws Exception
    {
       invokeOptionalMethod("destroy");
-      
+
       //unregisterManagementInterface();
-      
+
       super.destroy();
    }
 
@@ -318,7 +354,7 @@
       assert timerService != null : "Timer Service not yet initialized";
       return timerService;
    }
-   
+
    /**
     * Invoke a method on the singleton without a specific security or transaction context.
     * 
@@ -358,7 +394,7 @@
       }
       */
    }
-   
+
    public void invokePostConstruct(BeanContext beanContext, Object[] params)
    {
       //Ignore
@@ -368,12 +404,12 @@
    {
       //Ignore
    }
-   
+
    public Object localInvoke(Object id, Method method, Object[] args, FutureHolder provider) throws Throwable
    {
       return localInvoke(method, args, provider);
    }
-   
+
    public Object localHomeInvoke(Method method, Object[] args) throws Throwable
    {
       // no home interface for Service beans
@@ -396,12 +432,12 @@
    public Object localInvoke(Method method, Object[] args, FutureHolder provider) throws Throwable
    {
       long start = System.currentTimeMillis();
-      
+
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
       try
       {
          invokeStats.callIn();
-         
+
          Thread.currentThread().setContextClassLoader(classloader);
          long hash = MethodHashing.calculateHash(method);
          MethodInfo info = getAdvisor().getMethodInfo(hash);
@@ -409,7 +445,7 @@
          {
             throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
          }
-         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info,null);
+         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, null);
          nextInvocation.setAdvisor(getAdvisor());
          nextInvocation.setArguments(args);
 
@@ -417,8 +453,10 @@
 
          if (provider != null)
          {
-            nextInvocation.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
-            nextInvocation.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.FUTURE_HOLDER, provider, PayloadKey.AS_IS);
+            nextInvocation.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH,
+                  AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
+            nextInvocation.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH,
+                  AsynchronousInterceptor.FUTURE_HOLDER, provider, PayloadKey.AS_IS);
          }
          return nextInvocation.invokeNext();
       }
@@ -430,34 +468,34 @@
             long elapsed = end - start;
             invokeStats.updateStats(method, elapsed);
          }
-         
+
          invokeStats.callOut();
-         
+
          Thread.currentThread().setContextClassLoader(oldLoader);
       }
    }
-
-   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
+   
+   public InvocationResponse dynamicInvoke(Invocation invocation) throws Throwable
    {
       long start = System.currentTimeMillis();
-      
+
       ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
       StatefulContainerInvocation newSi = null;
-      
+
       MethodInvocation si = (MethodInvocation) invocation;
       MethodInfo info = getAdvisor().getMethodInfo(si.getMethodHash());
       Method method = info.getUnadvisedMethod();
       try
       {
          invokeStats.callIn();
-         
+
          Thread.currentThread().setContextClassLoader(classloader);
-         
+
          if (info == null)
          {
             throw new RuntimeException("Could not resolve beanClass method from proxy call");
          }
-         newSi = new StatefulContainerInvocation(info,null);
+         newSi = new StatefulContainerInvocation(info, null);
          newSi.setArguments(si.getArguments());
          newSi.setMetaData(si.getMetaData());
          newSi.setAdvisor(getAdvisor());
@@ -473,7 +511,8 @@
          {
             return marshallException(invocation, throwable, newSi.getResponseContextInfo());
          }
-         InvocationResponse response = SessionContainer.marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
+         InvocationResponse response = SessionContainer.marshallResponse(invocation, rtn, newSi
+               .getResponseContextInfo());
 
          return response;
       }
@@ -485,22 +524,30 @@
             long elapsed = end - start;
             invokeStats.updateStats(method, elapsed);
          }
-         
+
          invokeStats.callOut();
-         
+
          Thread.currentThread().setContextClassLoader(oldLoader);
       }
    }
 
+   @Deprecated
+   public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
+   {
+      log.warn("This call to dynamicInvoke(Object target, Invocation invocation) is "
+            + "@Deprecated, should be using dynamicInvoke(Invocation invocation)");
+      return this.dynamicInvoke(invocation);
+   }
+
    protected void initBeanContext() throws RuntimeException
    {
       if (beanContext == null)
       {
-         synchronized(singleton)
+         synchronized (singleton)
          {
             if (beanContext == null)
             {
-               beanContext  = createBeanContext();
+               beanContext = createBeanContext();
                beanContext.initialiseInterceptorInstances();
             }
          }
@@ -511,7 +558,7 @@
    {
       return beanContext;
    }
-   
+
    @Override
    protected StatefulContainerInvocation populateInvocation(StatefulContainerInvocation invocation)
    {
@@ -540,14 +587,13 @@
 
    // Dynamic MBean implementation --------------------------------------------------
 
-   public Object getAttribute(String attribute) throws AttributeNotFoundException,
-                                                       MBeanException, ReflectionException
+   public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
    {
       return delegate.getAttribute(attribute);
    }
 
-   public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
-                                                        InvalidAttributeValueException, MBeanException, ReflectionException
+   public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException,
+         MBeanException, ReflectionException
    {
       delegate.setAttribute(attribute);
    }
@@ -562,9 +608,23 @@
       return delegate.setAttributes(attributes);
    }
 
-   public Object invoke(String actionName, Object params[], String signature[])
-           throws MBeanException, ReflectionException
+   /**
+    * @see InvokableContext
+    */
+   public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
    {
+      // Extract reflection properties
+      String[] signature = method.getArgumentTypes();
+      String methodName = method.getName();
+
+      // Pass along to overloaded implementation
+      return this.invoke(methodName, args, signature);
+   }
+   
+   public Object invoke(String actionName, Object params[], String signature[]) throws MBeanException,
+         ReflectionException
+   {
+      assert delegate != null : "MBean delegate was null, cannot perform invocation";
       return delegate.invoke(actionName, params, signature);
    }
 
@@ -575,29 +635,26 @@
 
    public Object createLocalProxy(Object id, LocalBinding binding) throws Exception
    {
-      ServiceLocalProxyFactory factory = new ServiceLocalProxyFactory(this, binding);
+      throw new NotImplementedException(this + " is using unsupported legacy Proxy implementation");
+   }
 
-      return factory.createProxyBusiness(id);
-   }
-   
+   @Deprecated
    public Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception
    {
-      ServiceRemoteProxyFactory factory = new ServiceRemoteProxyFactory(this, binding);
-
-      return factory.createProxyBusiness(id);
+      throw new NotImplementedException(this + " is no longer using unsupported (legacy) proxy impl from ejb3-core");
    }
 
    private void registerManagementInterface()
    {
       try
       {
-         Management annotation = (Management)resolveAnnotation(Management.class);
+         Management annotation = (Management) resolveAnnotation(Management.class);
 
          Class intf = null;
          if (annotation != null)
             intf = annotation.value();
 
-         if (intf ==null)
+         if (intf == null)
          {
             Class[] interfaces = this.getBeanClass().getInterfaces();
             int interfaceIndex = 0;
@@ -616,13 +673,15 @@
                mbeanServer = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
 
             if (mbeanServer == null)
-               throw new RuntimeException("There is a @Management interface on " + ejbName + " but the MBeanServer has not been initialized for it");
+               throw new RuntimeException("There is a @Management interface on " + ejbName
+                     + " but the MBeanServer has not been initialized for it");
 
-            Service service = (Service)resolveAnnotation(Service.class);
+            Service service = (Service) resolveAnnotation(Service.class);
 
             String objname = service.objectName();
-            delegateObjectName = (objname == null || objname.equals("")) ?
-                            new ObjectName(getObjectName().getCanonicalName() + ",type=ManagementInterface") : new ObjectName(service.objectName());
+            delegateObjectName = (objname == null || objname.equals("")) ? new ObjectName(getObjectName()
+                  .getCanonicalName()
+                  + ",type=ManagementInterface") : new ObjectName(service.objectName());
 
             delegate = new ServiceMBeanDelegate(mbeanServer, this, intf, delegateObjectName);
 
@@ -630,25 +689,27 @@
          }
          else
          {
-            Service service = (Service)resolveAnnotation(Service.class);
+            Service service = (Service) resolveAnnotation(Service.class);
             if (service.xmbean().length() > 0)
             {
                if (mbeanServer == null)
                   mbeanServer = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
 
                if (mbeanServer == null)
-                  throw new RuntimeException(ejbName + "is defined as an XMBean, but the MBeanServer has not been initialized for it");
+                  throw new RuntimeException(ejbName
+                        + "is defined as an XMBean, but the MBeanServer has not been initialized for it");
 
                String objname = service.objectName();
-               delegateObjectName = (objname == null || objname.equals("")) ?
-                               new ObjectName(getObjectName().getCanonicalName() + ",type=ManagementInterface") : new ObjectName(service.objectName());
+               delegateObjectName = (objname == null || objname.equals("")) ? new ObjectName(getObjectName()
+                     .getCanonicalName()
+                     + ",type=ManagementInterface") : new ObjectName(service.objectName());
 
                delegate = new ServiceMBeanDelegate(mbeanServer, this, service.xmbean(), delegateObjectName);
 
                getDeployment().getKernelAbstraction().installMBean(delegateObjectName, getDependencyPolicy(), delegate);
             }
          }
-         
+
       }
       catch (Exception e)
       {
@@ -663,7 +724,7 @@
          getDeployment().getKernelAbstraction().uninstallMBean(delegateObjectName);
       }
    }
-   
+
    protected void removeHandle(Handle handle)
    {
       throw new RuntimeException("Don't do this");

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-11-11 00:13:15 UTC (rev 80774)
@@ -51,17 +51,19 @@
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.Ejb3Module;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.annotation.LocalBinding;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.annotation.RemoteBindings;
 import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.proxy.ProxyFactory;
+import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.proxy.ProxyUtils;
 import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
 import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
 import org.jboss.ejb3.proxy.factory.SessionProxyFactory;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
 import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.ejb3.stateful.StatefulContainerInvocation;
 import org.jboss.ha.framework.server.HATarget;
@@ -79,7 +81,13 @@
 {
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(SessionContainer.class);
+   
+   // ------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
 
+   private JndiSessionRegistrarBase jndiRegistrar;
+
    protected ProxyDeployer proxyDeployer;
    private Map<String, HATarget> clusterFamilies;
    
@@ -114,7 +122,7 @@
     * Create a local proxy factory.
     * @return
     */
-   protected abstract ProxyFactory getProxyFactory(LocalBinding binding);
+   protected abstract SessionProxyFactory getProxyFactory(LocalBinding binding);
    
    /**
     * Create a remote proxy factory on the given binding.
@@ -155,9 +163,22 @@
    {
       super.lockedStart();
       this.registerWithAopDispatcher();
-      
-      //TODO Remove
-      //      proxyDeployer.start();
+
+      // Obtain registrar
+      JndiSessionRegistrarBase registrar = this.getJndiRegistrar();
+
+      // Bind all appropriate references/factories to Global JNDI for Client access, if a JNDI Registrar is present
+      if (registrar != null)
+      {
+         String guid = Ejb3Registry.guid(this);
+         registrar.bindEjb(this.getInitialContext(), this.getMetaData(), this.getClassloader(), this.getObjectName()
+               .getCanonicalName(), guid, this.getAdvisor());
+      }
+      else
+      {
+         log.warn("No " + JndiSessionRegistrarBase.class.getSimpleName()
+               + " was found; byassing binding of Proxies to " + this.getName() + " in Global JNDI.");
+      }
    }
    
    /**
@@ -189,15 +210,7 @@
 
    protected void lockedStop() throws Exception
    {
-      //TODO Remove
-//      try
-//      {
-//         proxyDeployer.stop();
-//      }
-//      catch (Exception ignore)
-//      {
-//         log.debug("Proxy deployer stop failed", ignore);
-//      }
+
       try
       {
          Dispatcher.singleton.unregisterTarget(getObjectName().getCanonicalName());
@@ -206,6 +219,17 @@
       {
          log.debug("Dispatcher unregister target failed", ignore);
       }
+      
+      // Deregister with Remoting
+      Dispatcher.singleton.unregisterTarget(this.getName());
+
+      // Unbind applicable JNDI Entries
+      JndiSessionRegistrarBase jndiRegistrar = this.getJndiRegistrar();
+      if (jndiRegistrar != null)
+      {
+         jndiRegistrar.unbindEjb(this.getInitialContext(), this.getMetaData());
+      }
+      
       super.lockedStop();
    }
 
@@ -247,7 +271,70 @@
       return virtualMethods;
    }
    
+   // --------------------------------------------------------------------------------||
+   // Contracts ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+
+   /**
+    * Returns the name under which the JNDI Registrar for this container is bound
+    * 
+    * @return
+    */
+   protected abstract String getJndiRegistrarBindName();
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the JndiSessionRegistrarBase from MC, null if not found
+    * 
+    * @return
+    */
+   protected JndiSessionRegistrarBase getJndiRegistrar()
+   {
+      // If defined already, use it
+      if (this.jndiRegistrar != null)
+      {
+         return this.jndiRegistrar;
+      }
+
+      // Initialize
+      String jndiRegistrarBindName = this.getJndiRegistrarBindName();
+
+      // Obtain Registrar
+      Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
+
+      // Lookup
+      Object obj = null;
+      try
+      {
+         obj = registrar.lookup(jndiRegistrarBindName);
+         this.setJndiRegistrar(jndiRegistrar);
+      }
+      // If not installed, warn and return null
+      catch (NotBoundException e)
+      {
+         log.warn("No " + JndiSessionRegistrarBase.class.getName()
+               + " was found installed in the ObjectStore (Registry) at " + jndiRegistrarBindName);
+         return null;
+
+      }
+
+      // Cast
+      JndiSessionRegistrarBase jndiRegistrar = (JndiSessionRegistrarBase) obj;
+
+      // Return
+      return jndiRegistrar;
+   }
+
+   public void setJndiRegistrar(JndiSessionRegistrarBase jndiRegistrar)
+   {
+      this.jndiRegistrar = jndiRegistrar;
+   }
    
+   
 //   /**
 //    * Obtains a List of all methods handled by the bean class
 //    * 

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java	2008-11-11 00:13:15 UTC (rev 80774)
@@ -1,51 +1,37 @@
 package org.jboss.ejb3.session;
 
-import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
 
+import javax.ejb.EJB;
 import javax.ejb.EJBLocalObject;
 import javax.ejb.EJBObject;
 import javax.ejb.Handle;
 import javax.ejb.RemoveException;
 import javax.ejb.SessionContext;
 
-import org.jboss.aop.Advisor;
 import org.jboss.aop.Dispatcher;
 import org.jboss.aop.Domain;
 import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.proxy.ClassProxy;
 import org.jboss.aop.util.MethodHashing;
 import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.ThreadLocalStack;
 import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.LocalHomeBinding;
 import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.RemoteBindings;
-import org.jboss.ejb3.annotation.RemoteHomeBinding;
 import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.proxy.container.InvokableContext;
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
 import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
 import org.jboss.ejb3.proxy.handler.session.stateful.StatefulProxyInvocationHandlerBase;
-import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
 import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
 import org.jboss.ejb3.stateful.StatefulContainer;
 import org.jboss.ejb3.stateful.StatefulContainerInvocation;
-import org.jboss.ejb3.stateful.StatefulInstanceInterceptor;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
 import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
 import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
 
@@ -75,12 +61,6 @@
    protected static ThreadLocalStack<SerializableMethod> invokedMethod = new ThreadLocalStack<SerializableMethod>();
 
    // ------------------------------------------------------------------------------||
-   // Instance Members -------------------------------------------------------------||
-   // ------------------------------------------------------------------------------||
-
-   private JndiSessionRegistrarBase jndiRegistrar;
-
-   // ------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------||
    // ------------------------------------------------------------------------------||
 
@@ -429,8 +409,8 @@
       assert factory instanceof SessionProxyFactory : "Specified factory " + factory.getClass().getName()
             + " is not of type " + SessionProxyFactory.class.getName() + " as required by "
             + StatefulContainer.class.getName() + ", but was instead " + factory;
-      SessionProxyFactory sessionFactory = null;
-      sessionFactory = SessionProxyFactory.class.cast(factory);
+      SessionSpecProxyFactory sessionFactory = null;
+      sessionFactory = SessionSpecProxyFactory.class.cast(factory);
 
       // Create Proxy
       Object proxy = sessionFactory.createProxyEjb2x();
@@ -623,22 +603,6 @@
       log.info("Starting " + this);
 
       super.lockedStart();
-
-      // Obtain registrar
-      JndiSessionRegistrarBase registrar = this.getJndiRegistrar();
-
-      // Bind all appropriate references/factories to Global JNDI for Client access, if a JNDI Registrar is present
-      if (registrar != null)
-      {
-         String guid = Ejb3Registry.guid(this);
-         registrar.bindEjb(this.getInitialContext(), this.getMetaData(), this.getClassloader(), this.getObjectName()
-               .getCanonicalName(), guid, this.getAdvisor());
-      }
-      else
-      {
-         log.warn("No " + JndiSessionRegistrarBase.class.getSimpleName()
-               + " was found; byassing binding of Proxies to " + this.getName() + " in Global JNDI.");
-      }
    }
 
    /**
@@ -650,79 +614,5 @@
       log.info("Stopping " + this);
 
       super.lockedStop();
-
-      // Deregister with Remoting
-      Dispatcher.singleton.unregisterTarget(this.getName());
-
-      // Unbind applicable JNDI Entries
-      JndiSessionRegistrarBase jndiRegistrar = this.getJndiRegistrar();
-      if (jndiRegistrar != null)
-      {
-         jndiRegistrar.unbindEjb(this.getInitialContext(), this.getMetaData());
-      }
-
    }
-
-   // --------------------------------------------------------------------------------||
-   // Contracts ----------------------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-
-   /**
-    * Returns the name under which the JNDI Registrar for this container is bound
-    * 
-    * @return
-    */
-   protected abstract String getJndiRegistrarBindName();
-
-   // --------------------------------------------------------------------------------||
-   // Accessors / Mutators -----------------------------------------------------------||
-   // --------------------------------------------------------------------------------||
-
-   /**
-    * Obtains the JndiSessionRegistrarBase from MC, null if not found
-    * 
-    * @return
-    */
-   protected JndiSessionRegistrarBase getJndiRegistrar()
-   {
-      // If defined already, use it
-      if (this.jndiRegistrar != null)
-      {
-         return this.jndiRegistrar;
-      }
-
-      // Initialize
-      String jndiRegistrarBindName = this.getJndiRegistrarBindName();
-
-      // Obtain Registrar
-      Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
-
-      // Lookup
-      Object obj = null;
-      try
-      {
-         obj = registrar.lookup(jndiRegistrarBindName);
-         this.setJndiRegistrar(jndiRegistrar);
-      }
-      // If not installed, warn and return null
-      catch (NotBoundException e)
-      {
-         log.warn("No " + JndiSessionRegistrarBase.class.getName()
-               + " was found installed in the ObjectStore (Registry) at " + jndiRegistrarBindName);
-         return null;
-
-      }
-
-      // Cast
-      JndiSessionRegistrarBase jndiRegistrar = (JndiSessionRegistrarBase) obj;
-
-      // Return
-      return jndiRegistrar;
-   }
-
-   public void setJndiRegistrar(JndiSessionRegistrarBase jndiRegistrar)
-   {
-      this.jndiRegistrar = jndiRegistrar;
-   }
 }

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-11-11 00:13:15 UTC (rev 80774)
@@ -65,6 +65,7 @@
 import org.jboss.ejb3.proxy.container.InvokableContext;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
 import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionProxyFactoryBase;
 import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionRemoteProxyFactory;
 import org.jboss.ejb3.proxy.factory.stateless.StatelessLocalProxyFactory;
@@ -203,7 +204,7 @@
    @Override
    public Object createProxyRemoteEjb21(RemoteBinding binding, String businessInterfaceType) throws Exception
    {
-      SessionProxyFactory proxyFactory = this.getProxyFactory(binding);
+      SessionSpecProxyFactory proxyFactory = (SessionSpecProxyFactory) this.getProxyFactory(binding);
       return proxyFactory.createProxyEjb2x();
    }
    

Modified: projects/ejb3/trunk/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml	2008-11-11 00:13:15 UTC (rev 80774)
@@ -324,6 +324,16 @@
         org.jboss.ejb3.proxy.objectfactory.session.stateful.StatefulSessionProxyObjectFactory
       </parameter>
     </constructor>
+  </bean>  
+  
+  <!-- @Service JNDI Registrar -->
+  <bean name="org.jboss.ejb3.JndiRegistrar.Session.ServiceJndiRegistrar"
+    class="org.jboss.ejb3.proxy.jndiregistrar.JndiServiceRegistrar">
+    <constructor>
+      <parameter>
+        org.jboss.ejb3.proxy.objectfactory.session.service.ServiceProxyObjectFactory
+      </parameter>
+    </constructor>
   </bean>
    
   <bean name="org.jboss.ejb3.ProxyClusteringRegistry"

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java	2008-11-11 00:13:15 UTC (rev 80774)
@@ -129,6 +129,7 @@
 
       deploy("namingserver-beans.xml");
       deploy("transactionmanager-beans.xml");
+      deploy("servicecontainer-beans.xml");
       deploy("statefulcontainer-beans.xml");
       deploy("statelesscontainer-beans.xml");
       deploy("connector-beans.xml");

Modified: projects/ejb3/trunk/core/src/test/resources/org/jboss/ejb3/core/test/regression/ejbthree1253/remoteproxyfactoryregistry-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/org/jboss/ejb3/core/test/regression/ejbthree1253/remoteproxyfactoryregistry-beans.xml	2008-11-11 00:10:31 UTC (rev 80773)
+++ projects/ejb3/trunk/core/src/test/resources/org/jboss/ejb3/core/test/regression/ejbthree1253/remoteproxyfactoryregistry-beans.xml	2008-11-11 00:13:15 UTC (rev 80774)
@@ -21,7 +21,7 @@
             <!-- ServiceRemoteProxyFactory -->
             <entry>
                <key>ServiceRemoteProxyFactory</key>
-               <value>org.jboss.ejb3.proxy.factory.service.ServiceRemoteProxyFactory</value>
+               <value>org.jboss.ejb3.proxy.factory.session.service.ServiceRemoteProxyFactory</value>
             </entry>
             <!-- StatefulClusterProxyFactory -->
             <entry>

Added: projects/ejb3/trunk/core/src/test/resources/servicecontainer-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/servicecontainer-beans.xml	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/resources/servicecontainer-beans.xml	2008-11-11 00:13:15 UTC (rev 80774)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!-- @Service JNDI Registrar -->
+  <bean name="org.jboss.ejb3.JndiRegistrar.Session.ServiceJndiRegistrar"
+    class="org.jboss.ejb3.proxy.jndiregistrar.JndiServiceRegistrar">
+    <constructor>
+      <parameter>
+        org.jboss.ejb3.proxy.objectfactory.session.service.ServiceProxyObjectFactory
+      </parameter>
+    </constructor>
+  </bean>
+  
+</deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list