[jboss-cvs] JBossAS SVN: r71799 - in projects/ejb3/branches/ejbthree1253/core/src: main/java/org/jboss/ejb3/iiop and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 8 13:01:11 EDT 2008


Author: ALRubinger
Date: 2008-04-08 13:01:10 -0400 (Tue, 08 Apr 2008)
New Revision: 71799

Added:
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyAccessType.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHandleRemoteImpl.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleRemoteImpl.java
Removed:
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteHandleImpl.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleImpl.java
Modified:
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/JndiProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/LocalProducerFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/ProducerFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/RemoteProducerFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/BaseServiceProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceLocalProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContextImpl.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxy.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessBeanContext.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/bank/TellerRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/ejbthree1122/unit/MultipleDefinitionsOfSameBusinessInterfaceUnitTestCase.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/HomedStatefulSession30Bean.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session21Bean.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session30Bean.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/unit/ReferenceTestCase.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
   projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java
Log:
[EJBTHREE-1253] Refactoring, extending EJBObject/EJBLocalObject removal to apply to Stateless JNDI Proxies

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/JndiProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/JndiProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/JndiProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -52,7 +52,7 @@
       {
          ProxyFactory factory = (ProxyFactory) nameCtx.lookup(factoryName);
          
-         Object proxy = factory.createProxy();
+         Object proxy = factory.createProxyBusiness();
          MarshalledValuePair marshalledProxy = new MarshalledValuePair(proxy);
          return marshalledProxy.get();
       }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -31,9 +31,9 @@
 {
    public Object createHomeProxy();
    
-   public Object createProxy();
+   public Object createProxyBusiness();
 
-   public Object createProxy(Object id);
+   public Object createProxyBusiness(Object id);
    
    public void start() throws Exception;
 

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/ProxyFactoryHelper.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -21,6 +21,8 @@
  */
 package org.jboss.ejb3;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.net.URI;
 import java.util.ArrayList;
@@ -833,6 +835,20 @@
       
       return clientBindUrl;
    }
+   
+   /**
+    * Create a Proxy Constructor for the specified interfaces, using the specified CL
+    * 
+    * @param interfaces
+    * @param cl
+    * @return
+    * @throws Exception
+    */
+   public static Constructor<?> createProxyConstructor(Class<?>[] interfaces, ClassLoader cl) throws Exception
+   {
+      Class<?> proxyClass = java.lang.reflect.Proxy.getProxyClass(cl, interfaces);
+      return proxyClass.getConstructor(InvocationHandler.class);
+   }
 
    public static String getHomeJndiName(EJBContainer container)
    {

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/iiop/IORFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -147,7 +147,7 @@
       }
    }
    
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       try
       {
@@ -163,7 +163,7 @@
       }
    }
    
-   public Object createProxy(Object id)
+   public Object createProxyBusiness(Object id)
    {
       try
       {
@@ -348,7 +348,7 @@
       Servant servant = new BeanCorbaServant(this, poaCurrent, container, interfaceDef, interfaceAnalysis);
       this.referenceFactory = servantRegistry.bind(getServantName(), servant, policies);
       
-      EJBObject corbaObj = (EJBObject) createProxy();
+      EJBObject corbaObj = (EJBObject) createProxyBusiness();
       
       rebind(ctx, getJndiName(), (org.omg.CORBA.Object) corbaObj);
       

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/LocalProducerFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/LocalProducerFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/LocalProducerFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -55,7 +55,7 @@
       }
    }
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       Class[] interfaces = {producer, ProducerObject.class};
 

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/ProducerFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/ProducerFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/ProducerFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -117,11 +117,11 @@
       throw new UnsupportedOperationException("producer can't have a home interface");
    }
    
-   public Object createProxy(Object id)
+   public Object createProxyBusiness(Object id)
    {
       if(id != null)
          throw new IllegalArgumentException("producer proxy must not have an id");
-      return createProxy();
+      return createProxyBusiness();
    }
    
    public void setContainer(Container container)

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/RemoteProducerFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/RemoteProducerFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/mdb/RemoteProducerFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -65,7 +65,7 @@
    {
    }
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       Class[] interfaces = {producer, ProducerObject.class};
 

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/BaseServiceProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/BaseServiceProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/BaseServiceProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -54,11 +54,11 @@
       throw new UnsupportedOperationException("service can't have a home interface");
    }
    
-   public Object createProxy(Object id)
+   public Object createProxyBusiness(Object id)
    {
       if(id != null)
          throw new IllegalArgumentException("service proxy must not have an id");
-      return createProxy();
+      return createProxyBusiness();
    }
    
    public void start() throws Exception
@@ -69,7 +69,7 @@
 
       try
       {
-         Util.rebind(container.getInitialContext(), jndiName, createProxy());
+         Util.rebind(container.getInitialContext(), jndiName, createProxyBusiness());
       } catch (NamingException e)
       {
          NamingException namingException = new NamingException("Could not bind service proxy factory for EJB container with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName);

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -123,13 +123,13 @@
    }
    
    @Override
-   protected ProxyFactory createProxyFactory(LocalBinding binding)
+   protected ProxyFactory getProxyFactory(LocalBinding binding)
    {
       return new ServiceLocalProxyFactory(this, binding);
    }
    
    @Override
-   protected RemoteProxyFactory createProxyFactory(RemoteBinding binding)
+   protected RemoteProxyFactory getProxyFactory(RemoteBinding binding)
    {
       // TODO Implement clustering
       return new ServiceRemoteProxyFactory(this, binding);
@@ -535,14 +535,14 @@
    {
       ServiceLocalProxyFactory factory = new ServiceLocalProxyFactory(this, binding);
 
-      return factory.createProxy(id);
+      return factory.createProxyBusiness(id);
    }
    
    public Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception
    {
       ServiceRemoteProxyFactory factory = new ServiceRemoteProxyFactory(this, binding);
 
-      return factory.createProxy(id);
+      return factory.createProxyBusiness(id);
    }
 
    private void registerManagementInterface()

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceLocalProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceLocalProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceLocalProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -57,7 +57,7 @@
       return uniqueInterfaces.toArray(new Class<?>[]{});
    }
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       try
       {

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -78,7 +78,7 @@
       super.start();
    }
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       try
       {

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -25,8 +25,13 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.Arrays;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.ejb.EJBException;
@@ -42,8 +47,10 @@
 
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.Ejb3Registry;
+import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyFactory;
 import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.proxy.EJBMetaDataImpl;
 import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
@@ -60,18 +67,28 @@
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(BaseSessionProxyFactory.class);
    
-   private SessionContainer container;
+   private SessionSpecContainer container;
    protected String containerGuid;
    protected String containerClusterUid;
    protected boolean isClustered = false;
    
+   /**
+    * Proxy Constructor for the Business Interfaces' Proxy
+    */
+   protected Constructor<?> businessProxyConstructor;
+   
+   /**
+    * Proxy Constructor for the EJBObject/EJBLocalObject Proxy
+    */
+   protected Constructor<?> ejb21ProxyConstructor; 
+   
    private static final String METHOD_PREFIX_EJB21_CREATE = "create";
    
    public BaseSessionProxyFactory()
    {
    }
    
-   protected BaseSessionProxyFactory(SessionContainer container)
+   protected BaseSessionProxyFactory(SessionSpecContainer container)
    {
       assert container != null : "container is null";
       
@@ -83,27 +100,249 @@
       throw new RuntimeException("NYI");
    }
    
-   protected void setContainer(SessionContainer container)
+   /**
+    * Creates the Proxy constructors
+    */
+   protected void createProxyConstructors() throws Exception
    {
+      // Obtain interfaces to be used in the proxies
+      Class<?>[] businessInterfaces = this.getInterfacesForBusinessProxy();
+      Class<?>[] ejb21Interfaces = this.getInterfacesForEjb21Proxy();
+      
+      // Obtain this bean class' CL
+      ClassLoader cl = this.getContainer().getBeanClass().getClassLoader();
+      
+      // Obtain and set the proxy constructors 
+      this.businessProxyConstructor = ProxyFactoryHelper.createProxyConstructor(businessInterfaces, cl);
+      this.ejb21ProxyConstructor = ProxyFactoryHelper.createProxyConstructor(ejb21Interfaces, cl);
+      
+      /* plain jdk 
+      Class<?> proxyClass = java.lang.reflect.Proxy.getProxyClass(getContainer().getBeanClass().getClassLoader(), interfaces);
+      final Class<?>[] constructorParams =
+              {InvocationHandler.class};
+      businessProxyConstructor = proxyClass.getConstructor(constructorParams);
+      
+      */
+      
+      /* javassist */
+      /*
+      proxyFactory = new javassist.util.proxy.ProxyFactory()
+      {
+         @Override
+         protected ClassLoader getClassLoader()
+         {
+            return container.getBeanClass().getClassLoader();
+         }
+      };
+      proxyFactory.setInterfaces(interfaces);
+      proxyFactory.setSuperclass(JavassistProxy.class);
+      proxyClass = proxyFactory.createClass();
+      proxyConstructor = proxyClass.getConstructor((Class[]) null);
+      */
+      
+      /* cglib */
+      /*
+      proxyClass = net.sf.cglib.proxy.Proxy.getProxyClass(container.getBeanClass().getClassLoader(), interfaces);
+      final Class[] constructorParams = {net.sf.cglib.proxy.InvocationHandler.class};
+      proxyConstructor = proxyClass.getConstructor(constructorParams);
+      */
+   }
+   
+   protected Object constructProxyBusiness(InvocationHandler handler)
+   {
+      // Return
+      return this.constructProxy(handler, SpecificationInterfaceType.EJB30_BUSINESS);
+   }
+   
+   protected Object constructEjb21Proxy(InvocationHandler handler)
+   {
+      // Return
+      return this.constructProxy(handler, SpecificationInterfaceType.EJB21);
+   }
+   
+   /**
+    * Construct a new Proxy of the specified type using the 
+    * specified handler as argument to the Constructor
+    * 
+    * @param handler
+    * @param specType
+    * @return
+    */
+   protected Object constructProxy(final InvocationHandler handler, SpecificationInterfaceType specType)
+   {
+      // Initialize
+      Object obj = null;
+
+      try
+      {
+         // Business Proxy
+         if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
+         {
+            obj = this.businessProxyConstructor.newInstance(handler);
+         }
+         // EJBObject/EJBLocalObject
+         else if (specType.equals(SpecificationInterfaceType.EJB21))
+         {
+            obj = this.ejb21ProxyConstructor.newInstance(handler);
+         }
+      }
+      catch (InstantiationException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (IllegalAccessException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (InvocationTargetException e)
+      {
+         Throwable t = e.getTargetException();
+         if (t instanceof RuntimeException)
+            throw (RuntimeException) t;
+         throw new RuntimeException(t);
+      }
+
+      // Ensure Proxy object was created
+      assert obj != null : "Proxy Object must not be null";
+
+      // Return
+      return obj;
+   }
+
+   
+   protected void setContainer(SessionSpecContainer container)
+   {
       this.container = container;
       this.containerGuid = Ejb3Registry.guid(container);
       this.containerClusterUid = Ejb3Registry.clusterUid(container);
       this.isClustered = container.isClustered();
    }
    
-   protected SessionContainer getContainer()
+   protected SessionSpecContainer getContainer()
    {
       if (container == null)
       {
-         container = (SessionContainer)Ejb3Registry.findContainer(containerGuid);
+         container = (SessionSpecContainer)Ejb3Registry.findContainer(containerGuid);
          
          if (container == null && isClustered)
-            container = (SessionContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
+            container = (SessionSpecContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
       }
       
       return container;
    }
    
+   /**
+    * Obtains interfaces to be used in the business proxy
+    * 
+    * @return
+    */
+   protected Class<?>[] getInterfacesForBusinessProxy()
+   {
+      return this.getInterfacesForProxy(this.getProxyAccessType(), SpecificationInterfaceType.EJB30_BUSINESS);
+   }
+   
+   /**
+    * Obtains interfaces to be used in the EJB21 proxy
+    * 
+    * @return
+    */
+   protected Class<?>[] getInterfacesForEjb21Proxy()
+   {
+      return this.getInterfacesForProxy(this.getProxyAccessType(), SpecificationInterfaceType.EJB21);
+   }
+   
+   /**
+    * Returns an array of interfaces to be used for the proxy;
+    * the proxy type will be dependent on 
+    * 
+    * @param business
+    * @return
+    */
+   private Class<?>[] getInterfacesForProxy(ProxyAccessType accessType, SpecificationInterfaceType specType)
+   {
+
+      // Initialize
+      Set<Class<?>> interfaces = new HashSet<Class<?>>();
+      SessionContainer container = this.getContainer();
+
+      // Initialize array of interfaces
+      Set<Class<?>> intfs = new HashSet<Class<?>>();
+
+      // If Local
+      if (accessType.equals(ProxyAccessType.LOCAL))
+      {
+
+         // If business
+         if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
+         {
+            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(container)));
+         }
+         // If EJBLocalObject
+         else
+         {
+            // Add local interfaces
+            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getLocalInterfaces(container)));
+            
+            // If no local interfaces, return
+            if (intfs.size() == 0)
+            {
+               return new Class<?>[]
+               {};
+            }
+            
+            // Add EJBLocalObject
+            intfs.add(EJBLocalObject.class);
+         }
+      }
+      // If remote
+      else
+      {
+         // If business
+         if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
+         {
+            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(container)));
+         }
+         // If EJBObject
+         else
+         {
+            // Add remote interfaces
+            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteInterfaces(container)));
+            
+            // If no remote interfaces, return
+            if(intfs.size()==0)
+            {
+               return new Class<?>[]{};
+            }
+            
+            // Add EJBObject
+            intfs.add(EJBObject.class);
+         }
+      }
+
+      // Add all interfaces
+      for (Class<?> interfaze : intfs)
+      {
+         interfaces.add(interfaze);
+      }
+      
+      // Ensure more than interface is defined
+      assert interfaces.size() > 0 : "At least one interface must be defined";
+
+      // Add JBossProxy
+      interfaces.add(JBossProxy.class);
+
+      // Return
+      return interfaces.toArray(new Class[]
+      {});
+   }
+   
+   /**
+    * Defines the access type for this Proxies created by this Factory
+    * 
+    * @return
+    */
+   protected abstract ProxyAccessType getProxyAccessType();
+   
    protected void setEjb21Objects(BaseSessionRemoteProxy proxy)
    {
       proxy.setHandle(this.createHandle());
@@ -297,9 +536,7 @@
       // Ensure EJB2.1 Home returns only local/remote interfaces
       this.validateHomeReturnsNoBusinessInterfaces(home);
    }
-   
-   
-   
+     
    /**
     * Validates that any EJB2.1 Views associated with this ProxyFactory 
     * are valid

Added: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyAccessType.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyAccessType.java	                        (rev 0)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyAccessType.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.session;
+
+/**
+ * Defines access type (remote/local) for client view
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public enum ProxyAccessType {
+   REMOTE, LOCAL
+}

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/ProxyDeployer.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -23,6 +23,7 @@
 
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -83,7 +84,7 @@
             String factoryImplementationRegistryKey = binding.factory();
             if (factoryImplementationRegistryKey.equals(RemoteBindingDefaults.PROXY_FACTORY_DEFAULT))
             {
-               factory = container.createProxyFactory(binding);
+               factory = container.getProxyFactory(binding);
             }
             else
             {
@@ -98,7 +99,7 @@
 
       if (localBinding != null)
       {
-         ProxyFactory factory = container.createProxyFactory(localBinding);
+         ProxyFactory factory = container.getProxyFactory(localBinding);
          factory.start();
          proxyFactories.put(localBinding,factory);
       }
@@ -128,7 +129,7 @@
    
    public void initializeLocalBindingMetadata()
    {
-      localBinding = (LocalBinding) container.resolveAnnotation(LocalBinding.class);
+      localBinding = container.getAnnotation(LocalBinding.class);
       if (localBinding == null)
       {
          if (ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(container).length > 0)
@@ -151,10 +152,10 @@
    
    public void initializeRemoteBindingMetadata()
    {
-      remoteBindings = (RemoteBindings) container.resolveAnnotation(RemoteBindings.class);
+      remoteBindings = container.getAnnotation(RemoteBindings.class);
       if (remoteBindings == null)
       {
-         RemoteBinding binding = (RemoteBinding) container.resolveAnnotation(RemoteBinding.class);
+         RemoteBinding binding = container.getAnnotation(RemoteBinding.class);
          if (binding == null)
          {
             log.debug("no declared remote bindings for : " + container.getEjbName());
@@ -190,9 +191,9 @@
 
    public void stop() throws Exception
    {
-      for (int i = 0; i < proxyFactories.size(); i++)
+      Collection<ProxyFactory> proxyFactories = this.getProxyFactories().values();
+      for(ProxyFactory factory : proxyFactories)
       {
-         ProxyFactory factory = (ProxyFactory) proxyFactories.get(i);
          factory.stop();
       }
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -29,9 +29,9 @@
  * An instance of an enterprise bean link to its container.
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
  */
-public abstract class SessionBeanContext extends BaseContext<SessionContainer>
+public abstract class SessionBeanContext<T extends SessionContainer> extends BaseContext<T>
 {
    protected EJBContext ejbContext;
 
@@ -39,12 +39,12 @@
     * Must not break getInstance post condition!
     * @param container
     */
-   protected SessionBeanContext(SessionContainer container)
+   protected SessionBeanContext(T container)
    {
       super(container);
    }
    
-   protected SessionBeanContext(SessionContainer container, Object bean)
+   protected SessionBeanContext(T container, Object bean)
    {
       super(container, bean);
    }
@@ -53,7 +53,7 @@
    {
       if (ejbContext == null)
       {
-         SessionContextImpl bsc = new SessionContextImpl(this);
+         SessionContextImpl<T> bsc = new SessionContextImpl<T>(this);
          ejbContext = bsc;
       }
       return ejbContext;

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -55,7 +55,6 @@
 import org.jboss.ejb3.annotation.RemoteBindings;
 import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
-import org.jboss.ejb3.stateful.BaseStatefulRemoteProxyFactory;
 import org.jboss.ejb3.stateful.StatefulContainerInvocation;
 import org.jboss.ha.framework.server.HATarget;
 import org.jboss.logging.Logger;
@@ -89,35 +88,14 @@
    }
    
    /**
-    * @param id
-    * @return
-    * @throws Exception
-    * @deprecated       the binding on which this proxy is bound is unspecified
-    */
-   public Object createLocalProxy(Object id) throws Exception
-   {
-      LocalBinding binding = getAnnotation(LocalBinding.class);
-      return createLocalProxy(id, binding);
-   }
-   
-   /**
-    * Create a local proxy for an enterprise bean identified by id on a given binding.
+    * Returns a remote binding for this container
     * 
-    * @param id             the identifier of the enterprise bean (null for stateless)
-    * @param binding        the binding of the proxy
-    * @return               a proxy to an enterprise bean
-    * @throws Exception
-    */
-   public abstract Object createLocalProxy(Object id, LocalBinding binding) throws Exception;
-   
-   /**
-    * @param id
+    * @deprecated Non-deterministic, more than one binding may be specified 
+    * for this container
     * @return
-    * @throws Exception
-    * @deprecated       the binding on which this proxy is bound is unspecified
     */
    @Deprecated
-   public Object createRemoteProxy(Object id) throws Exception
+   protected RemoteBinding getRemoteBinding()
    {
       RemoteBinding binding = null;
       RemoteBindings bindings = getAnnotation(RemoteBindings.class);
@@ -126,17 +104,8 @@
       else
          binding = getAnnotation(RemoteBinding.class);
       
-      return createRemoteProxy(id, binding);
+      return binding;
    }
-   /**
-    * Create a remote proxy for an enterprise bean identified by id on a given binding.
-    * 
-    * @param id             the identifier of the enterprise bean (null for stateless)
-    * @param binding        the binding of the proxy
-    * @return               a proxy to an enterprise bean
-    * @throws Exception
-    */
-   public abstract Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception;
 
    protected ThreadLocalStack<InvokedMethod> invokedMethod = new ThreadLocalStack<InvokedMethod>();
 
@@ -151,7 +120,7 @@
     * Create a local proxy factory.
     * @return
     */
-   protected abstract ProxyFactory createProxyFactory(LocalBinding binding);
+   protected abstract ProxyFactory getProxyFactory(LocalBinding binding);
    
    /**
     * Create a remote proxy factory on the given binding.
@@ -159,7 +128,7 @@
     * @param binding
     * @return
     */
-   protected abstract RemoteProxyFactory createProxyFactory(RemoteBinding binding);
+   protected abstract RemoteProxyFactory getProxyFactory(RemoteBinding binding);
    
    public abstract InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable;
    
@@ -246,7 +215,7 @@
       }
       catch (Exception ignore)
       {
-         log.trace("Proxy deployer stop failed", ignore);
+         log.debug("Proxy deployer stop failed", ignore);
       }
       try
       {
@@ -254,7 +223,7 @@
       }
       catch (Exception ignore)
       {
-         log.trace("Dispatcher unregister target failed", ignore);
+         log.debug("Dispatcher unregister target failed", ignore);
       }
       super.stop();
    }
@@ -473,7 +442,7 @@
       Method unadvisedMethod = info.getUnadvisedMethod();
       if (unadvisedMethod.getName().equals("create"))
       {
-         Class[] initParameterTypes = {};
+         Class<?>[] initParameterTypes = {};
          Object[] initParameterValues = {};
          if (unadvisedMethod.getParameterTypes().length > 0)
          {
@@ -483,7 +452,7 @@
 
          Object id = createSession(initParameterTypes, initParameterValues);
          
-         Object proxy = factory.createProxy(id);
+         Object proxy = factory.createProxyBusiness(id);
 
          return proxy;
       }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContextImpl.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContextImpl.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionContextImpl.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -27,7 +27,9 @@
 import javax.xml.rpc.handler.MessageContext;
 
 import org.jboss.ejb3.EJBContextImpl;
+import org.jboss.ejb3.stateful.StatefulContainer;
 import org.jboss.ejb3.stateless.StatelessBeanContext;
+import org.jboss.ejb3.stateless.StatelessContainer;
 import org.jboss.logging.Logger;
 
 /**
@@ -36,12 +38,14 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class SessionContextImpl extends EJBContextImpl<SessionContainer, SessionBeanContext> implements SessionContext
+public class SessionContextImpl<J extends SessionContainer> extends EJBContextImpl<J, SessionBeanContext<J>>
+      implements
+         SessionContext
 {
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(SessionContextImpl.class);
    
-   public SessionContextImpl(SessionBeanContext beanContext)
+   public SessionContextImpl(SessionBeanContext<J> beanContext)
    {
       super(beanContext);
    }
@@ -62,7 +66,14 @@
          EJBLocalObject proxy = null;
          try
          {
-            proxy = (EJBLocalObject) container.createLocalProxy(id);
+            if (container instanceof StatefulContainer)
+            {
+               proxy = (EJBLocalObject) ((StatefulContainer) container).createProxyLocalEjb21(id);
+            }
+            else
+            {
+               proxy = (EJBLocalObject) ((StatelessContainer) container).createProxyLocalEjb21();
+            }
          }
          // Proxy does not implement EJBLocalObject
          catch (ClassCastException cce)
@@ -90,7 +101,14 @@
          EJBObject proxy = null;
          try
          {
-            proxy = (EJBObject) container.createRemoteProxy(id);
+            if (container instanceof StatefulContainer)
+            {
+               proxy = (EJBObject) ((StatefulContainer) container).createProxyRemoteEjb21(id);
+            }
+            else
+            {
+               proxy = (EJBObject) ((StatelessContainer) container).createProxyRemoteEjb21();
+            }
          }
          // Proxy does not implement EJBObject
          catch (ClassCastException cce)
@@ -109,7 +127,7 @@
       }
    }
    
-   public Class getInvokedBusinessInterface() throws IllegalStateException
+   public Class<?> getInvokedBusinessInterface() throws IllegalStateException
    {
       return container.getInvokedBusinessInterface();
    }

Added: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java	                        (rev 0)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.session;
+
+/**
+ * Context for Session Beans adhering to EJB3 Specification (SFSB, SLSB)
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class SessionSpecBeanContext<T extends SessionSpecContainer>
+      extends
+         SessionBeanContext<SessionSpecContainer>
+{
+
+   protected SessionSpecBeanContext(T container)
+   {
+      super(container);
+   }
+
+   protected SessionSpecBeanContext(T container, Object bean)
+   {
+      super(container, bean);
+   }
+
+}

Added: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java	                        (rev 0)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -0,0 +1,77 @@
+package org.jboss.ejb3.session;
+
+import java.util.Hashtable;
+
+import org.jboss.aop.Domain;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * SessionSpecContainer
+ * 
+ * A SessionContainer with support for Session Beans defined 
+ * specifically by the EJB3 Specification
+ * 
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class SessionSpecContainer extends SessionContainer
+{
+   
+   // Constructor
+   
+   public SessionSpecContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+         Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBeanMetaData beanMetaData)
+         throws ClassNotFoundException
+   {
+      super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
+   }
+   
+   /**
+    * Create a remote proxy (EJBObject) for an enterprise bean identified by id
+    * 
+    * @param id
+    * @return
+    * @throws Exception
+    */
+   public Object createProxyRemoteEjb21() throws Exception
+   {
+      RemoteBinding binding = this.getRemoteBinding();
+      return this.createProxyRemoteEjb21(binding);
+   }
+   
+   /**
+    * Create a remote proxy (EJBObject) for an enterprise bean identified by id on a given binding
+    * 
+    * @param id
+    * @param binding
+    * @return
+    * @throws Exception
+    */
+   public abstract Object createProxyRemoteEjb21(RemoteBinding binding) throws Exception;
+   
+   /**
+    * Create a local proxy (EJBLocalObject) for an enterprise bean identified by id
+    * 
+    * @param id
+    * @return
+    * @throws Exception
+    */
+   public Object createProxyLocalEjb21() throws Exception
+   {
+      LocalBinding binding = this.getAnnotation(LocalBinding.class);
+      return this.createProxyLocalEjb21(binding);
+   }
+   
+   /**
+    * Create a local proxy (EJBLocalObject) for an enterprise bean identified by id, with
+    * the specified LocalBinding
+    * 
+    * @param id
+    * @return
+    * @throws Exception
+    */
+   public abstract Object createProxyLocalEjb21(LocalBinding binding) throws Exception;
+}

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -24,15 +24,7 @@
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
 
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.NamingException;
@@ -40,14 +32,9 @@
 import javax.naming.Reference;
 import javax.naming.StringRefAddr;
 
-import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.JndiProxyFactory;
 import org.jboss.ejb3.ProxyFactory;
-import org.jboss.ejb3.ProxyFactoryHelper;
-import org.jboss.ejb3.SpecificationInterfaceType;
-import org.jboss.ejb3.session.BaseSessionProxyFactory;
-import org.jboss.ejb3.session.BaseSessionRemoteProxy;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 import org.jboss.util.naming.Util;
 
@@ -64,22 +51,6 @@
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(BaseStatefulProxyFactory.class);
    
-   protected static enum ProxyAccessType{
-      REMOTE,LOCAL;
-   }
-
-//   protected Class proxyClass;
-   
-   /**
-    * Proxy Constructor for the Business Interfaces' Proxy
-    */
-   private Constructor<?> businessProxyConstructor;
-   
-   /**
-    * Proxy Constructor for the EJBObject/EJBLocalObject Proxy
-    */
-   private Constructor<?> ejb21ProxyConstructor; 
-   
 //   protected Context proxyFactoryContext;
    protected String jndiName;
 
@@ -93,7 +64,7 @@
       super();
    }
 
-   public BaseStatefulProxyFactory(SessionContainer container, String jndiName)
+   public BaseStatefulProxyFactory(SessionSpecContainer container, String jndiName)
    {
       super(container);
       
@@ -102,68 +73,6 @@
       this.jndiName = jndiName;
    }
    
-   protected Object constructBusinessProxy(InvocationHandler handler)
-   {
-      // Return
-      return this.constructProxy(handler, SpecificationInterfaceType.EJB30_BUSINESS);
-   }
-   
-   protected Object constructEjb21Proxy(InvocationHandler handler)
-   {
-      // Return
-      return this.constructProxy(handler, SpecificationInterfaceType.EJB21);
-   }
-   
-   /**
-    * Construct a new Proxy of the specified type using the 
-    * specified handler as argument to the Constructor
-    * 
-    * @param handler
-    * @param specType
-    * @return
-    */
-   private Object constructProxy(InvocationHandler handler, SpecificationInterfaceType specType)
-   {
-      // Initialize
-      Object obj = null;
-
-      try
-      {
-         // Business Proxy
-         if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
-         {
-            obj = this.businessProxyConstructor.newInstance(handler);
-         }
-         // EJBObject/EJBLocalObject
-         else if (specType.equals(SpecificationInterfaceType.EJB21))
-         {
-            obj = this.ejb21ProxyConstructor.newInstance(handler);
-         }
-      }
-      catch (InstantiationException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (InvocationTargetException e)
-      {
-         Throwable t = e.getTargetException();
-         if (t instanceof RuntimeException)
-            throw (RuntimeException) t;
-         throw new RuntimeException(t);
-      }
-
-      // Ensure Proxy object was created
-      assert obj != null : "Proxy Object must not be null";
-
-      // Return
-      return obj;
-   }
-
-   
    public void init() throws Exception
    {
       // Ensure EJB2.1 View is Complete
@@ -171,28 +80,7 @@
       
       // Create the Proxy Constructors
       this.createProxyConstructors();
-   }
-   
-   /**
-    * Creates the Proxy constructors
-    */
-   protected void createProxyConstructors() throws Exception
-   {
-      // Obtain interfaces to be used in the proxies
-      Class<?>[] businessInterfaces = this.getInterfacesForBusinessProxy();
-      Class<?>[] ejb21Interfaces = this.getInterfacesForEjb21Proxy();
-      
-      // Obtain this bean class' CL
-      ClassLoader cl = this.getContainer().getBeanClass().getClassLoader();
-      
-      // Create proxy classes
-      Class<?> businessProxyClass = java.lang.reflect.Proxy.getProxyClass(cl, businessInterfaces);
-      Class<?> ejb21ProxyClass = java.lang.reflect.Proxy.getProxyClass(cl, ejb21Interfaces);
-      
-      // Obtain and set the proxy constructors 
-      this.businessProxyConstructor = businessProxyClass.getConstructor(InvocationHandler.class);
-      this.ejb21ProxyConstructor = ejb21ProxyClass.getConstructor(InvocationHandler.class);
-   }
+   }   
 
    public void start() throws Exception
    {
@@ -216,107 +104,11 @@
          throw namingException;
       }
    }
-   
-   /**
-    * Obtains interfaces to be used in the business proxy
-    * 
-    * @return
-    */
-   protected Class<?>[] getInterfacesForBusinessProxy()
-   {
-      return this.getInterfacesForProxy(this.getProxyAccessType(), SpecificationInterfaceType.EJB30_BUSINESS);
-   }
-   
-   /**
-    * Obtains interfaces to be used in the EJB21 proxy
-    * 
-    * @return
-    */
-   protected Class<?>[] getInterfacesForEjb21Proxy()
-   {
-      return this.getInterfacesForProxy(this.getProxyAccessType(), SpecificationInterfaceType.EJB21);
-   }
-   
-   /**
-    * Returns an array of interfaces to be used for the proxy;
-    * the proxy type will be dependent on 
-    * 
-    * @param business
-    * @return
-    */
-   private Class<?>[] getInterfacesForProxy(ProxyAccessType accessType, SpecificationInterfaceType specType)
-   {
 
-      // Initialize
-      Set<Class<?>> interfaces = new HashSet<Class<?>>();
-      SessionContainer container = this.getContainer();
-
-      // Initialize array of interfaces
-      Set<Class<?>> intfs = new HashSet<Class<?>>();
-
-      // If Local
-      if (accessType.equals(ProxyAccessType.LOCAL))
-      {
-
-         // If business
-         if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
-         {
-            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(container)));
-         }
-         // If EJBLocalObject
-         else
-         {
-            // Add local interfaces
-            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getLocalInterfaces(container)));
-            
-            // Add EJBLocalObject
-            intfs.add(EJBLocalObject.class);
-         }
-      }
-      // If remote
-      else
-      {
-         // If business
-         if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
-         {
-            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(container)));
-         }
-         // If EJBObject
-         else
-         {
-            // Add remote interfaces
-            intfs.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteInterfaces(container)));
-            
-            // Add EJBObject
-            intfs.add(EJBObject.class);
-         }
-      }
-
-      // Add all interfaces
-      for (Class<?> interfaze : intfs)
-      {
-         interfaces.add(interfaze);
-      }
-
-      // Add JBossProxy
-      interfaces.add(JBossProxy.class);
-
-      // Return
-      return interfaces.toArray(new Class[]
-      {});
-   }
-
    public void stop() throws Exception
    {
       Util.unbind(getContainer().getInitialContext(), jndiName);
    }
-   
-   /**
-    * Defines the access type for this Proxies created by this Factory
-    * 
-    * @return
-    */
-   protected abstract ProxyAccessType getProxyAccessType();
 
    protected final void initializeJndiName() {};
    

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -9,7 +9,9 @@
 import org.jboss.ejb3.SpecificationInterfaceType;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
+import org.jboss.ejb3.session.ProxyAccessType;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.remoting.InvokerLocator;
 
 public abstract class BaseStatefulRemoteProxyFactory extends BaseStatefulProxyFactory implements RemoteProxyFactory
@@ -22,7 +24,7 @@
    private InvokerLocator locator;
    
    // Constructor
-   public BaseStatefulRemoteProxyFactory(SessionContainer container, RemoteBinding binding)
+   public BaseStatefulRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
       super(container, binding.jndiBinding());
       
@@ -61,13 +63,13 @@
             .getRemoteInterfaces(container));
    }
    
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       Object id = getContainer().createSession();
-      return this.createProxy(id);
+      return this.createProxyBusiness(id);
    }
    
-   public Object createProxy(Object id)
+   public Object createProxyBusiness(Object id)
    {
       return this.createProxy(id,SpecificationInterfaceType.EJB30_BUSINESS);
    }
@@ -78,6 +80,13 @@
    
    // Functional Methods 
    
+   protected boolean bindHomeAndBusinessTogether(SessionContainer container)
+   {
+      String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container);
+      String remoteBusinessJndiName = ProxyFactoryHelper.getRemoteBusinessJndiName(container);
+      return homeJndiName.equals(remoteBusinessJndiName);
+   }
+   
    Object createProxy(Object id,SpecificationInterfaceType type)
    {
       String stackName = this.getStackNameInterceptors();
@@ -97,32 +106,34 @@
       }
       else
       {
-         return this.constructBusinessProxy(proxy);
+         return this.constructProxyBusiness(proxy);
       }
    }
    
    @Override
-   protected StatefulRemoteHandleImpl createHandle()
+   protected StatefulHandleRemoteImpl createHandle()
    {
-      Object proxy = this.createProxyEjb21();
+      EJBObject proxy = this.createProxyEjb21();
       return this.createHandle(proxy);
    }
    
-   protected StatefulRemoteHandleImpl createHandle(Object proxy)
+   protected StatefulHandleRemoteImpl createHandle(EJBObject proxy)
    {
-      StatefulRemoteHandleImpl handle = new StatefulRemoteHandleImpl((EJBObject)proxy);
+      StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
       return handle;
    } 
    
-   public Object createProxyEjb21()
+   public EJBObject createProxyEjb21()
    {
       Object id = getContainer().createSession();
       return this.createProxyEjb21(id);
    }
    
-   public Object createProxyEjb21(Object id)
+   @SuppressWarnings("unchecked")
+   public <T extends EJBObject> T createProxyEjb21(Object id)
    {
-      return this.createProxy(id,SpecificationInterfaceType.EJB21);
+      // Cast explicitly to catch improper proxies
+      return (T)this.createProxy(id,SpecificationInterfaceType.EJB21);
    }
 
    // Accessors / Mutators

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -29,10 +29,10 @@
 import java.util.List;
 
 import javax.persistence.EntityManager;
+
 import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.session.SessionContainer;
-
 import org.jboss.ejb3.Ejb3Registry;
+import org.jboss.ejb3.session.SessionSpecContainer;
 
 /**
  * Overrides superclass to not use MarshalledValue in externalization,
@@ -50,7 +50,7 @@
    private static final long serialVersionUID = 7835719320529968045L;
    
 
-   public NestedStatefulBeanContext(SessionContainer container, Object bean)
+   public NestedStatefulBeanContext(SessionSpecContainer container, Object bean)
    {
       super(container, bean);
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -34,7 +34,7 @@
 
 import org.jboss.aop.metadata.SimpleMetaData;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 
 /**
  * Proxy to a NestedStatefulBeanContext that can be independently passivated,
@@ -280,7 +280,7 @@
 //   }
 //
    @Override
-   public SessionContainer getContainer()
+   public SessionSpecContainer getContainer()
    {
       return getDelegate().getContainer();
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -42,8 +42,9 @@
 import org.jboss.ejb3.cache.Identifiable;
 import org.jboss.ejb3.cache.StatefulCache;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
-import org.jboss.ejb3.session.SessionBeanContext;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecBeanContext;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.tx.TxUtil;
 import org.jboss.serial.io.MarshalledObject;
 import org.jboss.tm.TxUtils;
@@ -59,7 +60,7 @@
  * 
  * @version $Revision$
  */
-public class StatefulBeanContext extends SessionBeanContext implements Identifiable, Serializable
+public class StatefulBeanContext extends SessionSpecBeanContext<SessionSpecContainer> implements Identifiable, Serializable
 {
    /** The serialVersionUID */
    private static final long serialVersionUID = -102470788178912606L;
@@ -140,7 +141,7 @@
     * @param container
     * @param beanMO
     */
-   protected StatefulBeanContext(SessionContainer container, MarshalledObject beanMO)
+   protected StatefulBeanContext(SessionSpecContainer container, MarshalledObject beanMO)
    {
       super(container);
       
@@ -158,7 +159,7 @@
     * @param container
     * @param bean
     */
-   protected StatefulBeanContext(SessionContainer container, Object bean)
+   protected StatefulBeanContext(SessionSpecContainer container, Object bean)
    {
       super(container, bean);
       
@@ -791,16 +792,16 @@
    }
 
    @Override
-   public SessionContainer getContainer()
+   public SessionSpecContainer getContainer()
    {
       if (container == null)
       {
-         container = (SessionContainer)Ejb3Registry.findContainer(containerGuid);
-          
+         container = (SessionSpecContainer) Ejb3Registry.findContainer(containerGuid);
+
          if (isClustered && container == null)
-            container = (SessionContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
+            container = (SessionSpecContainer) Ejb3Registry.getClusterContainer(containerClusterUid);
       }
-      
+
       return container;
    }
 

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -38,7 +38,9 @@
 import org.jboss.ejb3.remoting.LoadBalancePolicyNotRegisteredException;
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
 import org.jboss.ejb3.remoting.RemoteProxyFactoryRegistry;
+import org.jboss.ejb3.session.ProxyAccessType;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ha.client.loadbalance.FirstAvailable;
 import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
 import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
@@ -72,7 +74,7 @@
    private LoadBalancePolicy lbPolicy;
    private FamilyWrapper wrapper;
 
-   public StatefulClusterProxyFactory(SessionContainer container, RemoteBinding binding, Clustered clustered)
+   public StatefulClusterProxyFactory(SessionSpecContainer container, RemoteBinding binding, Clustered clustered)
    {
       super(container, binding);
       
@@ -170,7 +172,7 @@
       return StatefulClusterProxyFactory.STACK_NAME_CLUSTERED_STATEFUL_SESSION_CLIENT_INTERCEPTORS;
    }
 
-   public Object createProxy(Object id)
+   public Object createProxyBusiness(Object id)
    {
       throw new RuntimeException("NYI");
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -46,7 +46,6 @@
 import javax.ejb.RemoveException;
 import javax.ejb.TimerService;
 
-import org.jboss.aop.Dispatcher;
 import org.jboss.aop.Domain;
 import org.jboss.aop.InstanceAdvisor;
 import org.jboss.aop.MethodInfo;
@@ -77,6 +76,7 @@
 import org.jboss.ejb3.proxy.EJBMetaDataImpl;
 import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.injection.Injector;
 import org.jboss.injection.JndiPropertyInjector;
 import org.jboss.logging.Logger;
@@ -88,7 +88,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class StatefulContainer extends SessionContainer implements StatefulObjectFactory<StatefulBeanContext>
+public class StatefulContainer extends SessionSpecContainer implements StatefulObjectFactory<StatefulBeanContext>
 {
    private static final Logger log = Logger.getLogger(StatefulContainer.class);
 
@@ -115,23 +115,95 @@
    }
    
    @Override
-   protected ProxyFactory createProxyFactory(LocalBinding binding)
+   protected StatefulLocalProxyFactory getProxyFactory(LocalBinding binding)
    {
-      return new StatefulLocalProxyFactory(this, binding);
+      StatefulLocalProxyFactory factory = (StatefulLocalProxyFactory) this.proxyDeployer.getProxyFactory(binding);
+
+      if (factory == null)
+      {
+         factory = new StatefulLocalProxyFactory(this, binding);
+
+         try
+         {
+            factory.init();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+      
+      return factory;
    }
    
+   public Object createProxyLocalEjb21(Object id, LocalBinding binding) throws Exception
+   {
+      StatefulLocalProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21(id);
+   }
+   
+   public Object createProxyRemoteEjb21(Object id) throws Exception
+   {
+      RemoteBinding binding = this.getRemoteBinding();
+      return this.createProxyRemoteEjb21(id,binding);
+   }
+
+   public Object createProxyRemoteEjb21(Object id, RemoteBinding binding) throws Exception
+   { 
+      BaseStatefulRemoteProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21(id);
+   }
+   
+   public Object createProxyLocalEjb21(Object id) throws Exception
+   {
+      LocalBinding binding = this.getAnnotation(LocalBinding.class);
+      return this.createProxyLocalEjb21(id,binding);
+   }
+   
    @Override
-   protected BaseStatefulRemoteProxyFactory createProxyFactory(RemoteBinding binding)
+   public Object createProxyLocalEjb21(LocalBinding binding) throws Exception
    {
-      Clustered clustered = getAnnotation(Clustered.class);
-      if (clustered != null)
+      Object id = this.createSession();
+      return this.createProxyLocalEjb21(id,binding);
+   }
+
+   @Override
+   public Object createProxyRemoteEjb21(RemoteBinding binding) throws Exception
+   {
+      Object id = this.createSession();
+      return this.createProxyRemoteEjb21(id, binding);
+   }
+   
+   @Override
+   protected BaseStatefulRemoteProxyFactory getProxyFactory(RemoteBinding binding)
+   {
+      BaseStatefulRemoteProxyFactory factory = (BaseStatefulRemoteProxyFactory) this.proxyDeployer
+            .getProxyFactory(binding);
+
+      if (factory == null)
       {
-         return new StatefulClusterProxyFactory(this, binding, clustered);
+
+         Clustered clustered = getAnnotation(Clustered.class);
+         if (clustered != null)
+         {
+            factory = new StatefulClusterProxyFactory(this, binding, clustered);
+         }
+         else
+         {
+            factory = new StatefulRemoteProxyFactory(this, binding);
+         }
+         
+         try
+         {
+            factory.init();
+         }
+         catch(Exception e)
+         {
+            throw new RuntimeException(e);
+         }
       }
-      else
-      {
-         return new StatefulRemoteProxyFactory(this, binding);
-      }
+
+      return factory;
    }
    
    public void destroy(StatefulBeanContext obj)
@@ -723,7 +795,7 @@
          StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
          factory.init();
 
-         Object proxy = factory.createEjb21Proxy(initParameterTypes,
+         Object proxy = factory.createProxyEjb21(initParameterTypes,
                  initParameterValues);
 
          return proxy;
@@ -740,30 +812,28 @@
       }
    }
    
+   public Object createLocalProxy(Object id) throws Exception
+   {
+      return this.createLocalProxy(id, this.getAnnotation(LocalBinding.class));
+   }
+   
    public Object createLocalProxy(Object id, LocalBinding binding) throws Exception
    {
       StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory(this, binding);
       factory.init();
 
-      return factory.createProxy(id);
+      return factory.createProxyBusiness(id);
    }
    
    public Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception
    {
-      //      RemoteBinding binding = null;
-      //      RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
-      //      if (bindings != null)
-      //         binding = bindings.value()[0];
-      //      else
-      //         binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
-
       StatefulRemoteProxyFactory factory = new StatefulRemoteProxyFactory(this, binding);
       factory.init();
 
       if (id != null)
-         return factory.createProxy(id);
+         return factory.createProxyBusiness(id);
       else
-         return factory.createProxy();
+         return factory.createProxyBusiness();
    }
    
    public boolean isClustered()
@@ -876,11 +946,11 @@
          ProxyFactory proxyFactory = this.proxyDeployer.getProxyFactory(this.getAnnotation(RemoteBinding.class));;
          if (proxyFactory == null)
          {
-            proxyFactory = this.createProxyFactory(this.getAnnotation(RemoteBinding.class));
+            proxyFactory = this.getProxyFactory(this.getAnnotation(RemoteBinding.class));
          }
          BaseStatefulRemoteProxyFactory statefulRemoteProxyFactory = (BaseStatefulRemoteProxyFactory) proxyFactory;
          EJBObject proxy = (EJBObject) statefulRemoteProxyFactory.createProxyEjb21(newStatefulInvocation.getId());
-         StatefulRemoteHandleImpl handle = new StatefulRemoteHandleImpl(proxy);
+         StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
          InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
          return response;
       }
@@ -1025,11 +1095,11 @@
       {
          if (isRemote && factory instanceof StatefulRemoteProxyFactory)
          {
-            return ((StatefulRemoteProxyFactory) factory).createProxy(ctx.getId());
+            return ((StatefulRemoteProxyFactory) factory).createProxyBusiness(ctx.getId());
          }
          else if (!isRemote && factory instanceof StatefulLocalProxyFactory)
          {
-            return ((StatefulLocalProxyFactory) factory).createProxy(ctx.getId());
+            return ((StatefulLocalProxyFactory) factory).createProxyBusiness(ctx.getId());
          }
       }
       throw new IllegalStateException("Unable to create proxy for getBusinessObject as a proxy factory was not found");
@@ -1047,7 +1117,7 @@
       if(!(target instanceof Handle))
          throw new RemoveException("EJB 3 3.6.2.2: Session beans do not have a primary key");
       
-      StatefulRemoteHandleImpl handle = (StatefulRemoteHandleImpl) target;
+      StatefulHandleRemoteImpl handle = (StatefulHandleRemoteImpl) target;
 
       try
       {

Copied: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHandleRemoteImpl.java (from rev 71778, projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteHandleImpl.java)
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHandleRemoteImpl.java	                        (rev 0)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHandleRemoteImpl.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.stateful;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+
+import org.jboss.logging.Logger;
+
+/**
+ * An EJB stateful session bean handle.
+ *
+ * @author  <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author  <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="bill at burkecentral.com">Bill Burke</a>
+ * @author <a href="bdecoste at jboss.com">William DeCoste</a>
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a> 
+ * @version $Revision$
+ */
+public class StatefulHandleRemoteImpl implements Handle
+{
+   private static final Logger log = Logger.getLogger(StatefulHandleRemoteImpl.class);
+
+   /** Serial Version Identifier. */
+   static final long serialVersionUID = -6324520755180597156L;
+
+   // Instance Members
+
+   private EJBObject proxy;
+
+   // Constructor
+
+   public StatefulHandleRemoteImpl(EJBObject proxy)
+   {
+      this.proxy = proxy;
+   }
+
+   // Required Implementations
+
+   /**
+    * Handle implementation.
+    *
+    * Returns the proxy  
+    *
+    * @throws RemoteException 
+    */
+   public EJBObject getEJBObject() throws RemoteException
+   {
+      return this.proxy;
+   }
+}


Property changes on: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHandleRemoteImpl.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -70,7 +70,7 @@
    {
    }
 
-   public void setHandle(StatefulRemoteHandleImpl handle)
+   public void setHandle(StatefulHandleRemoteImpl handle)
    {
       this.handle = handle;
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -34,7 +34,9 @@
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.SpecificationInterfaceType;
 import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.session.ProxyAccessType;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.proxy.ejb.handle.StatefulHandleImpl;
 import org.jboss.util.NotImplementedException;
 import org.jboss.util.naming.Util;
@@ -58,7 +60,7 @@
       super();
    }
    
-   public StatefulLocalProxyFactory(SessionContainer container, LocalBinding binding)
+   public StatefulLocalProxyFactory(SessionSpecContainer container, LocalBinding binding)
    {
       super(container, binding.jndiBinding());
    }
@@ -134,11 +136,11 @@
       }
    }
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       SessionContainer sfsb = (SessionContainer) getContainer();
       Object id = sfsb.createSession();
-      return this.createProxy(id);
+      return this.createProxyBusiness(id);
    }
 
    public EJBLocalObject createProxyEjb21()
@@ -147,7 +149,7 @@
       return this.createProxyEjb21(id);
    }
 
-   public Object createProxy(Object id)
+   public Object createProxyBusiness(Object id)
    {
       return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS);
    }
@@ -161,7 +163,7 @@
    private Object createProxy(Object id, SpecificationInterfaceType type)
    {
       StatefulLocalProxy proxy = new StatefulLocalProxy(this.getContainer(), id, vmid);
-      return type.equals(SpecificationInterfaceType.EJB30_BUSINESS) ? this.constructBusinessProxy(proxy) : this
+      return type.equals(SpecificationInterfaceType.EJB30_BUSINESS) ? this.constructProxyBusiness(proxy) : this
             .constructEjb21Proxy(proxy);
    }
    
@@ -172,7 +174,7 @@
       return this.createProxy(id, SpecificationInterfaceType.EJB30_BUSINESS);
    }
    
-   public Object createEjb21Proxy(Class<?>[] initTypes, Object[] initValues){
+   public Object createProxyEjb21(Class<?>[] initTypes, Object[] initValues){
       SessionContainer sfsb = (SessionContainer) getContainer();
       Object id = sfsb.createSession(initTypes, initValues);
       return this.createProxy(id, SpecificationInterfaceType.EJB21);

Deleted: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteHandleImpl.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteHandleImpl.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteHandleImpl.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.stateful;
-
-import java.rmi.RemoteException;
-
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-
-import org.jboss.logging.Logger;
-
-/**
- * An EJB stateful session bean handle.
- *
- * @author  <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author  <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="bill at burkecentral.com">Bill Burke</a>
- * @author <a href="bdecoste at jboss.com">William DeCoste</a>
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a> 
- * @version $Revision$
- */
-public class StatefulRemoteHandleImpl implements Handle
-{
-   private static final Logger log = Logger.getLogger(StatefulRemoteHandleImpl.class);
-
-   /** Serial Version Identifier. */
-   static final long serialVersionUID = -6324520755180597156L;
-
-   // Instance Members
-
-   private EJBObject proxy;
-
-   // Constructor
-
-   public StatefulRemoteHandleImpl(EJBObject proxy)
-   {
-      this.proxy = proxy;
-   }
-
-   // Required Implementations
-
-   /**
-    * Handle implementation.
-    *
-    * Returns the proxy  
-    *
-    * @throws RemoteException 
-    */
-   public EJBObject getEJBObject() throws RemoteException
-   {
-      return this.proxy;
-   }
-}

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxy.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxy.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxy.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -80,7 +80,7 @@
    {
    }
    
-   public void setHandle(StatefulRemoteHandleImpl handle)
+   public void setHandle(StatefulHandleRemoteImpl handle)
    {
       this.handle = handle;
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -23,7 +23,6 @@
 
 import java.lang.reflect.Proxy;
 
-import javax.ejb.EJBObject;
 import javax.ejb.RemoteHome;
 import javax.naming.NamingException;
 
@@ -40,6 +39,7 @@
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
 import org.jboss.ejb3.session.BaseSessionRemoteProxy;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.util.naming.Util;
@@ -60,17 +60,10 @@
    
    private static final String STACK_NAME_STATEFUL_SESSION_CLIENT_INTERCEPTORS = "StatefulSessionClientInterceptors";
 
-   public StatefulRemoteProxyFactory(SessionContainer container, RemoteBinding binding)
+   public StatefulRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
       super(container, binding);
    }
-   
-   protected boolean bindHomeAndBusinessTogether(SessionContainer container)
-   {
-      String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container);
-      String remoteBusinessJndiName = ProxyFactoryHelper.getRemoteBusinessJndiName(container);
-      return homeJndiName.equals(remoteBusinessJndiName);
-   }
 
    @Override
    public void start() throws Exception

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -21,23 +21,11 @@
  */
 package org.jboss.ejb3.stateless;
 
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import javassist.util.proxy.MethodHandler;
-import javassist.util.proxy.ProxyObject;
-
-import javax.naming.Context;
 import javax.naming.NamingException;
 
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.Container;
 import org.jboss.ejb3.ProxyFactory;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.ProxyAccessType;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 import org.jboss.util.naming.Util;
 
@@ -51,13 +39,9 @@
 {
    private static final Logger log = Logger.getLogger(BaseStatelessProxyFactory.class);
 
-//   protected Class proxyClass;
-//   protected Context proxyFactoryContext;
    protected String jndiName;
    
-   private Constructor proxyConstructor;
-   
-   public BaseStatelessProxyFactory(SessionContainer container, String jndiName)
+   public BaseStatelessProxyFactory(SessionSpecContainer container, String jndiName)
    {
       super(container);
       
@@ -93,121 +77,41 @@
    }
    */
    
-   /**
-    * Adapt the InvocationHandler to MethodHandler.
-    * 
-    * This is a named class because it implements both MethodHandler and Serializable.
-    */
-   private static class MethodHandlerAdapter implements MethodHandler, Serializable
-   {
-      private static final long serialVersionUID = 1L;
-      
-      private InvocationHandler delegate;
-      
-      private MethodHandlerAdapter(InvocationHandler delegate)
-      {
-         if(delegate == null)
-            throw new IllegalArgumentException("delegate must not be null");
-         this.delegate = delegate;
-      }
-      
-      public Object invoke(Object self, Method thisMethod, Method process, Object[] args) throws Throwable
-      {
-         return delegate.invoke(self, thisMethod, args);
-      }         
-   }
+//   /**
+//    * Adapt the InvocationHandler to MethodHandler.
+//    * 
+//    * This is a named class because it implements both MethodHandler and Serializable.
+//    */
+//   private static class MethodHandlerAdapter implements MethodHandler, Serializable
+//   {
+//      private static final long serialVersionUID = 1L;
+//      
+//      private InvocationHandler delegate;
+//      
+//      private MethodHandlerAdapter(InvocationHandler delegate)
+//      {
+//         if(delegate == null)
+//            throw new IllegalArgumentException("delegate must not be null");
+//         this.delegate = delegate;
+//      }
+//      
+//      public Object invoke(Object self, Method thisMethod, Method process, Object[] args) throws Throwable
+//      {
+//         return delegate.invoke(self, thisMethod, args);
+//      }         
+//   }
    
-   /**
-    * Hide the fact that I'm now using javassist.
-    * 
-    * @param handler    a JDK proxy InvocationHandler
-    * @return           a true proxy
-    */
-   protected Object constructProxy(final InvocationHandler handler)
-   {
-      try
-      {
-         /* plain jdk */
-         Object args[] = { handler };
-         Object proxy = proxyConstructor.newInstance(args);
-         
-         /* javassist */
-         /*
-         MethodHandler realHandler = new MethodHandlerAdapter(handler);
-//         ProxyObject proxy = (ProxyObject) proxyConstructor.newInstance((Object[]) null);
-//         proxy.setHandler(realHandler);
-         JavassistProxy proxy = (JavassistProxy) proxyConstructor.newInstance((Object[]) null);
-         proxy.setMethodHandler(realHandler);
-         JavassistProxy.pokeInterfaces(proxy, getInterfaces());
-         */
-         
-         /* cglib */
-         /*
-         Object args[] = { new CGLibInvocationHandlerAdapter(handler) };
-         Object proxy = proxyConstructor.newInstance(args);
-         */
-         
-         return proxy;
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (InstantiationException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getTargetException());
-      }
-   }
    
-   public final Object createProxy(Object id)
+   public final Object createProxyBusiness(Object id)
    {
       assert id == null : "stateless bean must not have an id";
-      return createProxy();
+      return createProxyBusiness();
    }
    
    public void init() throws Exception
    {
-      initializeJndiName();
-      Class<?>[] interfaces = getInterfaces();
+      this.createProxyConstructors();
       this.validateEjb21Views();
-      
-      
-      /* plain jdk */
-      Class<?> proxyClass = java.lang.reflect.Proxy.getProxyClass(getContainer().getBeanClass().getClassLoader(), interfaces);
-      final Class<?>[] constructorParams =
-              {InvocationHandler.class};
-      proxyConstructor = proxyClass.getConstructor(constructorParams);
-      
-      /* javassist */
-      /*
-      proxyFactory = new javassist.util.proxy.ProxyFactory()
-      {
-         @Override
-         protected ClassLoader getClassLoader()
-         {
-            return container.getBeanClass().getClassLoader();
-         }
-      };
-      proxyFactory.setInterfaces(interfaces);
-      proxyFactory.setSuperclass(JavassistProxy.class);
-      proxyClass = proxyFactory.createClass();
-      proxyConstructor = proxyClass.getConstructor((Class[]) null);
-      */
-      
-      /* cglib */
-      /*
-      proxyClass = net.sf.cglib.proxy.Proxy.getProxyClass(container.getBeanClass().getClassLoader(), interfaces);
-      final Class[] constructorParams = {net.sf.cglib.proxy.InvocationHandler.class};
-      proxyConstructor = proxyClass.getConstructor(constructorParams);
-      */
    }
 
    /* for debugging purposes * /
@@ -229,7 +133,7 @@
    {
       init();
 
-      Object proxy = createProxy();
+      Object proxy = createProxyBusiness();
       //describeClass(proxy.getClass());
       bindProxy(proxy);
    }
@@ -238,13 +142,11 @@
    {
       Util.unbind(getContainer().getInitialContext(), jndiName);
    }
-
-   protected abstract Class<?>[] getInterfaces();
    
    protected abstract void validateEjb21Views();
+   
+   protected abstract ProxyAccessType getProxyAccessType();
 
-   protected final void initializeJndiName() {};
-
    protected void bindProxy(Object proxy) throws NamingException
    {
       try
@@ -253,7 +155,9 @@
          Util.rebind(getContainer().getInitialContext(), jndiName, proxy);
       } catch (NamingException e)
       {
-         NamingException namingException = new NamingException("Could not bind stateless proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName);
+         NamingException namingException = new NamingException("Could not bind stateless proxy with ejb name "
+               + getContainer().getEjbName() + " into JNDI under jndiName: "
+               + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName);
          namingException.setRootCause(e);
          throw namingException;
       }

Added: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java	                        (rev 0)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -0,0 +1,134 @@
+package org.jboss.ejb3.stateless;
+
+import javax.ejb.EJBObject;
+import javax.ejb.RemoteHome;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceStack;
+import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.remoting.RemoteProxyFactory;
+import org.jboss.ejb3.session.ProxyAccessType;
+import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
+import org.jboss.remoting.InvokerLocator;
+
+public abstract class BaseStatelessRemoteProxyFactory extends BaseStatelessProxyFactory implements RemoteProxyFactory
+{
+   
+   // Instance Members
+   
+   private RemoteBinding binding;
+   
+   private InvokerLocator locator;
+   
+   // Constructor
+   public BaseStatelessRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
+   {
+      super(container, binding.jndiBinding());
+      
+      this.binding = binding;
+      
+      try
+      {
+         String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(this.getBinding());
+         this.locator = new InvokerLocator(clientBindUrl);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   // Required Implementations
+
+   @Override
+   protected final ProxyAccessType getProxyAccessType()
+   {
+      return ProxyAccessType.REMOTE;
+   }  
+   
+   @Override
+   protected final void validateEjb21Views()
+   {
+      // Obtain Container
+      SessionContainer container = this.getContainer();
+      
+      // Obtain @RemoteHome
+      RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
+
+      // Ensure that if EJB 2.1 Components are defined, they're complete
+      this.validateEjb21Views(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
+            .getRemoteInterfaces(container));
+   }
+   
+   // Specifications
+   
+   abstract String getStackNameInterceptors();
+   
+   // Functional Methods 
+   
+   protected boolean bindHomeAndBusinessTogether(SessionContainer container)
+   {
+      String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container);
+      String remoteBusinessJndiName = ProxyFactoryHelper.getRemoteBusinessJndiName(container);
+      return homeJndiName.equals(remoteBusinessJndiName);
+   }
+   
+   public Object createProxyBusiness()
+   {
+      return this.createProxy(SpecificationInterfaceType.EJB30_BUSINESS);
+   }
+   
+   public Object createProxy(SpecificationInterfaceType type)
+   {
+      String stackName = this.getStackNameInterceptors();
+      if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
+      {
+         stackName = binding.interceptorStack();
+      }
+      AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
+      StatelessRemoteProxy proxy = new StatelessRemoteProxy(getContainer(),
+            stack.createInterceptors(getContainer().getAdvisor(), null), locator);
+      
+      if(type.equals(SpecificationInterfaceType.EJB21))
+      {
+         return this.constructEjb21Proxy(proxy);
+      }
+      else
+      {
+         return this.constructProxyBusiness(proxy);
+      }
+   }
+   
+   @Override
+   protected final StatelessHandleRemoteImpl createHandle()
+   {
+      EJBObject proxy = this.createProxyEjb21();
+      StatelessHandleRemoteImpl handle = new StatelessHandleRemoteImpl(proxy);
+      return handle;
+   }
+   
+   @SuppressWarnings("unchecked")
+   public <T extends EJBObject> T createProxyEjb21()
+   {
+      // Cast explicitly to catch improper proxies
+      return (T)this.createProxy(SpecificationInterfaceType.EJB21);
+   }
+
+   // Accessors / Mutators
+   
+   RemoteBinding getBinding()
+   {
+      assert this.binding!=null : "RemoteBinding has not been initialized";
+      return this.binding;
+   }
+   
+   InvokerLocator getLocator()
+   {
+      assert this.locator!=null : "InvokerLocator has not been initialized"; 
+      return this.locator;
+   }
+
+}

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessBeanContext.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessBeanContext.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessBeanContext.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -21,11 +21,8 @@
  */
 package org.jboss.ejb3.stateless;
 
-import javax.xml.ws.WebServiceContext;
-
-import org.jboss.ejb3.BaseContext;
-import org.jboss.ejb3.session.SessionBeanContext;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecBeanContext;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.injection.lang.reflect.BeanProperty;
 
 
@@ -35,12 +32,12 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class StatelessBeanContext extends SessionBeanContext
+public class StatelessBeanContext extends SessionSpecBeanContext<SessionSpecContainer>
 {
    private javax.xml.rpc.handler.MessageContext jaxrpcMessageContext;
    private BeanProperty webServiceContextProperty;
    
-   protected StatelessBeanContext(SessionContainer container, Object bean)
+   protected StatelessBeanContext(SessionSpecContainer container, Object bean)
    {
       super(container, bean);
    }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -33,6 +33,7 @@
 import org.jboss.aspects.remoting.FamilyWrapper;
 import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
 import org.jboss.ejb3.annotation.Clustered;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.annotation.defaults.ClusteredDefaults;
@@ -40,6 +41,7 @@
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
 import org.jboss.ejb3.remoting.RemoteProxyFactoryRegistry;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
 import org.jboss.ha.client.loadbalance.RandomRobin;
 import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
@@ -56,11 +58,13 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class StatelessClusterProxyFactory extends BaseStatelessProxyFactory  
+public class StatelessClusterProxyFactory extends BaseStatelessRemoteProxyFactory  
    implements RemoteProxyFactory, DistributedReplicantManager.ReplicantListener
 {
    private static final Logger log = Logger.getLogger(StatelessClusterProxyFactory.class);
 
+   private static final String STACK_NAME_CLUSTERED_STATELESS_SESSION_CLIENT_INTERCEPTORS = "ClusteredStatelessSessionClientInterceptors";
+   
    private RemoteBinding binding;
    private Clustered clustered;
    private InvokerLocator locator;
@@ -71,9 +75,9 @@
    private FamilyWrapper wrapper;
    private Object proxy;
 
-   public StatelessClusterProxyFactory(SessionContainer container, RemoteBinding binding, Clustered clustered)
+   public StatelessClusterProxyFactory(SessionSpecContainer container, RemoteBinding binding, Clustered clustered)
    {
-      super(container, binding.jndiBinding());
+      super(container, binding);
       
       assert clustered != null : "clustered is null";
       
@@ -81,42 +85,6 @@
       this.clustered = clustered;
    }
 
-   protected Class<?>[] getInterfaces()
-   {
-      // Initialize
-      Set<Class<?>> interfaces = new HashSet<Class<?>>();
-      
-      // Obtain remote and business remote interfaces
-      Class<?>[] remoteAndBusinessRemoteInterfaces = ProxyFactoryHelper
-            .getRemoteAndBusinessRemoteInterfaces(getContainer());
-      
-      // Add all remote and business remotes
-      for(Class<?> interfaze : remoteAndBusinessRemoteInterfaces)
-      {
-         interfaces.add(interfaze);
-      }
-      
-      // Add JBossProxy
-      interfaces.add( JBossProxy.class);
-      
-      // Return
-      return interfaces.toArray(new Class[]{});
-   }
-   
-   protected void validateEjb21Views()
-   { 
-      // Obtain Container
-      SessionContainer container = this.getContainer();
-      
-      // Obtain @RemoteHome
-      RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
-
-      // Ensure that if EJB 2.1 Components are defined, they're complete
-      this.validateEjb21Views(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
-            .getRemoteInterfaces(container));
-
-   }
-
    public void start() throws Exception
    {
       String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
@@ -165,10 +133,10 @@
       ((StatelessContainer) getContainer()).getClusterFamilies().remove(proxyFamilyName);
    }
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
       Object containerId = getContainer().getObjectName().getCanonicalName();
-      String stackName = "ClusteredStatelessSessionClientInterceptors";
+      String stackName = this.getStackNameInterceptors();
       if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
       {
          stackName = binding.interceptorStack();
@@ -180,18 +148,10 @@
       */
       String partitionName = ((StatelessContainer) getContainer()).getPartitionName();
       
-      proxy = constructProxy(new StatelessClusteredProxy(getContainer(), stack.createInterceptors(getContainer().getAdvisor(), null), 
-            wrapper, lbPolicy, partitionName));
+      proxy = constructProxy(new StatelessClusteredProxy(getContainer(), stack.createInterceptors(getContainer()
+            .getAdvisor(), null), wrapper, lbPolicy, partitionName), SpecificationInterfaceType.EJB30_BUSINESS);
       return proxy;
    }
-
-   protected StatelessHandleImpl createHandle()
-   {
-      StatelessHandleImpl handle = new StatelessHandleImpl();
-      handle.jndiName = binding.jndiBinding();
- 
-      return handle;
-   }
    
    public synchronized void replicantsChanged (String key, 
          List newReplicants, 
@@ -213,4 +173,10 @@
          log.error(e);
       }
    }
+
+   @Override
+   String getStackNameInterceptors()
+   {
+      return StatelessClusterProxyFactory.STACK_NAME_CLUSTERED_STATELESS_SESSION_CLIENT_INTERCEPTORS;
+   }
 }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -26,7 +26,11 @@
 import java.util.Hashtable;
 import java.util.Map;
 
-import javax.ejb.*;
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.Handle;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
 import javax.naming.NamingException;
 
 import org.jboss.aop.Domain;
@@ -41,31 +45,27 @@
 import org.jboss.ejb3.BeanContextLifecycleCallback;
 import org.jboss.ejb3.EJBContainerInvocation;
 import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.ProxyFactory;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.annotation.Clustered;
 import org.jboss.ejb3.annotation.LocalBinding;
 import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.RemoteBindings;
-import org.jboss.ejb3.remoting.RemoteProxyFactory;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.ejb3.stateful.BaseStatefulRemoteProxyFactory;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
+import org.jboss.injection.lang.reflect.BeanProperty;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
 import org.jboss.proxy.ejb.handle.HomeHandleImpl;
 import org.jboss.proxy.ejb.handle.StatelessHandleImpl;
-import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
-import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.invocation.ExtensibleWebServiceContext;
+import org.jboss.wsf.spi.invocation.InvocationType;
 import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
-import org.jboss.wsf.spi.invocation.InvocationType;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
+import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
 
 
 /**
@@ -74,7 +74,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class StatelessContainer extends SessionContainer
+public class StatelessContainer extends SessionSpecContainer
   implements TimedObjectInvoker, ServiceEndpointContainer
 {
    private static final Logger log = Logger.getLogger(StatelessContainer.class);
@@ -98,23 +98,77 @@
    }
    
    @Override
-   protected ProxyFactory createProxyFactory(LocalBinding binding)
+   protected StatelessLocalProxyFactory getProxyFactory(LocalBinding binding)
    {
-      return new StatelessLocalProxyFactory(this, binding);
+      StatelessLocalProxyFactory factory = (StatelessLocalProxyFactory) this.proxyDeployer.getProxyFactory(binding);
+
+      if (factory == null)
+      {
+         factory = new StatelessLocalProxyFactory(this, binding);
+         try
+         {
+            factory.init();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+      return factory;
    }
    
    @Override
-   protected RemoteProxyFactory createProxyFactory(RemoteBinding binding)
+   protected BaseStatelessRemoteProxyFactory getProxyFactory(RemoteBinding binding)
    {
-      Clustered clustered = getAnnotation(Clustered.class);
-      if(clustered != null)
-         return new StatelessClusterProxyFactory(this, binding, clustered);
-      else
-         return new StatelessRemoteProxyFactory(this, binding);
+      BaseStatelessRemoteProxyFactory factory = (BaseStatelessRemoteProxyFactory) this.proxyDeployer
+            .getProxyFactory(binding);
+
+      if (factory == null)
+      {
+         Clustered clustered = getAnnotation(Clustered.class);
+         if (clustered != null)
+            factory = new StatelessClusterProxyFactory(this, binding, clustered);
+         else
+            factory = new StatelessRemoteProxyFactory(this, binding);
+         
+         try
+         {
+            factory.init();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+
+      return factory;
    }
    
-   public Object createSession(Class initTypes[], Object initArgs[])
+   /**
+    * Create a local proxy (EJBLocalObject) for an enterprise bean identified by id, with
+    * the specified LocalBinding
+    * 
+    * @param id
+    * @return
+    * @throws Exception
+    */
+   @Override
+   public Object createProxyLocalEjb21(LocalBinding binding) throws Exception
    {
+      StatelessLocalProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21();
+   }
+   
+   @Override
+   public Object createProxyRemoteEjb21(RemoteBinding binding) throws Exception
+   {
+      BaseStatelessRemoteProxyFactory proxyFactory = this.getProxyFactory(binding);
+      return proxyFactory.createProxyEjb21();
+   }
+   
+   public Object createSession(Class<?> initTypes[], Object initArgs[])
+   {
       if((initTypes != null && initTypes.length > 0) || (initArgs != null && initArgs.length > 0))
          throw new IllegalArgumentException("stateless bean create method must take no arguments (EJB3 4.5)");
       // a stateless bean has no sessions
@@ -368,7 +422,7 @@
       if (unadvisedMethod.getName().equals("getHandle"))
       {
          StatelessHandleImpl handle = null;
-         RemoteBinding remoteBindingAnnotation = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
          if (remoteBindingAnnotation != null)
             handle = new StatelessHandleImpl(remoteBindingAnnotation.jndiBinding());
 
@@ -382,7 +436,7 @@
       {
          HomeHandleImpl homeHandle = null;
 
-         RemoteBinding remoteBindingAnnotation = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+         RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
          if (remoteBindingAnnotation != null)
             homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
 
@@ -406,14 +460,13 @@
    {
       if (method.getName().equals("create"))
       {
-         LocalBinding binding = (LocalBinding) resolveAnnotation(LocalBinding.class);
+         LocalBinding binding = this.getAnnotation(LocalBinding.class);
          
          // FIXME: why this binding? Could be another one. (there is only one local binding, but that's another bug)
          
-         StatelessLocalProxyFactory factory = new StatelessLocalProxyFactory(this, binding);
-         factory.init();
+         StatelessLocalProxyFactory factory = this.getProxyFactory(binding);
 
-         Object proxy = factory.createProxy();
+         Object proxy = factory.createProxyEjb21();
 
          return proxy;
       }
@@ -422,52 +475,17 @@
          return null;
       }
    }
-   
-   public Object createLocalProxy(Object id, LocalBinding binding) throws Exception
-   {
-      StatelessLocalProxyFactory factory = new StatelessLocalProxyFactory(this, binding);
-      factory.init();
 
-      Object proxy = factory.createProxy();
-
-      return proxy;
-   }
-   
-   public Object createRemoteProxy(Object id, RemoteBinding binding) throws Exception
-   {
-//      RemoteBinding binding = null;
-//
-//      RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
-//      if (bindings != null)
-//         binding = bindings.value()[0];
-//      else
-//         binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
-
-      StatelessRemoteProxyFactory factory = new StatelessRemoteProxyFactory(this, binding);
-      factory.init();
-
-      return factory.createProxy();
-   }
-
    protected Object invokeHomeMethod(MethodInfo info, MethodInvocation invocation) throws Throwable
    {
       Method unadvisedMethod = info.getUnadvisedMethod();
       if (unadvisedMethod.getName().equals("create"))
       {
-         RemoteBinding binding = null;
-
-         RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
-         if (bindings != null)
-            binding = bindings.value()[0];
-         else
-            binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
-
-         // FIXME: why this binding? Better select the proper one.
+         RemoteBinding binding = this.getRemoteBinding();
          
-         StatelessRemoteProxyFactory factory = new StatelessRemoteProxyFactory(this, binding);
-         factory.init();
-
-         return factory.createProxy();
+         BaseStatelessRemoteProxyFactory factory = this.getProxyFactory(binding);
+         
+         return factory.createProxyEjb21();
       }
       else // remove
       {

Deleted: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleImpl.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleImpl.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleImpl.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.stateless;
-
-import java.rmi.RemoteException;
-import java.rmi.ServerException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.io.ObjectStreamField;
-import java.io.ObjectInputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.ejb.Handle;
-import javax.ejb.EJBObject;
-import javax.ejb.EJBHome;
-
-import org.jboss.ejb3.InitialContextFactory;
-import org.jboss.naming.NamingContextFactory;
-
-/**
- * An EJB stateless session bean handle.
- *
- * @author  <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class StatelessHandleImpl
-      implements Handle
-{
-   /** Serial Version Identifier. */
-   static final long serialVersionUID = 3811452873535097661L;
-   private static final ObjectStreamField[] serialPersistentFields =
-      new ObjectStreamField[]
-   {
-      new ObjectStreamField("jndiName", String.class),
-      new ObjectStreamField("jndiEnv", Hashtable.class)
-   };
-
-   /** The JNDI name of the home inteface binding */
-   public String jndiName;
-   /** The JNDI env in effect when the home handle was created */
-   private Hashtable jndiEnv;
-
-   // Constructors --------------------------------------------------
-
-   public StatelessHandleImpl()
-   {
-      
-   }
-   
-   /**
-    * Construct a <tt>StatelessHandleImpl</tt>.
-    *
-    * @param handle    The initial context handle that will be used
-    *                  to restore the naming context or null to use
-    *                  a fresh InitialContext object.
-    * @param name      JNDI name.
-    */
-   public StatelessHandleImpl(String jndiName)
-   {
-      this.jndiName = jndiName;
-      this.jndiEnv = (Hashtable) NamingContextFactory.lastInitialContextEnv.get();
-   }
-
-   // Public --------------------------------------------------------
-
-   public EJBObject getEJBObject() throws RemoteException
-   {
-      try
-      {
-         InitialContext ic = InitialContextFactory.getInitialContext(jndiEnv);
-    
-         Proxy proxy = (Proxy) ic.lookup(jndiName);
-
-         return (EJBObject) proxy;
-      }
-      catch (Throwable t)
-      {
-         t.printStackTrace();
-         throw new RemoteException("Error during getEJBObject", t);
-      }
-   }
-
-   /**
-    * @return the jndi name
-    */
-   public String getJNDIName()
-   {
-      return jndiName;
-   }
-
-   private void readObject(ObjectInputStream ois)
-      throws IOException, ClassNotFoundException
-   {
-      ObjectInputStream.GetField getField = ois.readFields();
-      jndiName = (String) getField.get("jndiName", null);
-      jndiEnv = (Hashtable) getField.get("jndiEnv", null);
-   }
-
-   private void writeObject(ObjectOutputStream oos)
-      throws IOException
-   {
-      ObjectOutputStream.PutField putField = oos.putFields();
-      putField.put("jndiName", jndiName);
-      putField.put("jndiEnv", jndiEnv);
-      oos.writeFields();
-   }
-}

Copied: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleRemoteImpl.java (from rev 71778, projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleImpl.java)
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleRemoteImpl.java	                        (rev 0)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleRemoteImpl.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.stateless;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+
+/**
+ * An EJB stateless session bean handle.
+ *
+ * @author  <a href="mailto:marc.fleury at jboss.org">Marc Fleury</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class StatelessHandleRemoteImpl
+      implements Handle
+{
+   /** Serial Version Identifier. */
+   static final long serialVersionUID = 3811452873535097661L;
+   
+   private EJBObject proxy;
+
+   // Constructors --------------------------------------------------
+
+   public StatelessHandleRemoteImpl()
+   {
+      
+   }
+   
+   /**
+    * Construct a <tt>StatelessHandleImpl</tt>.
+    *
+    * @param handle    The initial context handle that will be used
+    *                  to restore the naming context or null to use
+    *                  a fresh InitialContext object.
+    * @param name      JNDI name.
+    */
+   public StatelessHandleRemoteImpl(EJBObject proxy)
+   {
+      this.proxy = proxy;
+   }
+
+   // Public --------------------------------------------------------
+
+   public EJBObject getEJBObject() throws RemoteException
+   {
+      return this.proxy;
+   }
+}


Property changes on: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessHandleRemoteImpl.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -21,17 +21,15 @@
  */
 package org.jboss.ejb3.stateless;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
+import javax.ejb.EJBLocalObject;
 import javax.ejb.LocalHome;
 
 import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.SpecificationInterfaceType;
 import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.ProxyAccessType;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 import org.jboss.util.naming.Util;
 
@@ -46,47 +44,17 @@
 {
    private static final Logger log = Logger.getLogger(StatelessLocalProxyFactory.class);
    
-   public StatelessLocalProxyFactory(SessionContainer container, LocalBinding binding)
+   public StatelessLocalProxyFactory(SessionSpecContainer container, LocalBinding binding)
    {
       super(container, binding.jndiBinding());
    }
-
-   protected Class<?>[] getInterfaces()
+   
+   @Override
+   protected ProxyAccessType getProxyAccessType()
    {
-      EJBContainer statelessContainer = this.getContainer();
-      LocalHome localHome = statelessContainer.getAnnotation(LocalHome.class);
-
-      boolean bindTogether = false;
-
-      if (localHome != null && bindHomeAndBusinessTogether(statelessContainer))
-         bindTogether = true;
-
-      // Obtain all local interfaces
-      Set<Class<?>> localInterfaces = new HashSet<Class<?>>();
-      localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(getContainer())));
-
-      // Ensure local interfaces defined
-      if (localInterfaces.size() > 0)
-      {
-         // Add JBossProxy
-         localInterfaces.add(JBossProxy.class);
-
-         // If binding along w/ home, add home
-         if (bindTogether)
-         {
-            localInterfaces.add(localHome.value());
-         }
-      }
-      else
-      {
-         // No remote interfaces defined, log warning
-         log.warn("[EJBTHREE-933] NPE when deploying web service beans");
-      }
-
-      // Return
-      return localInterfaces.toArray(new Class<?>[]
-      {});
+      return ProxyAccessType.LOCAL;
    }
+
    
    protected void validateEjb21Views(){
       
@@ -109,7 +77,7 @@
    {
       super.start();
       EJBContainer statelessContainer = (EJBContainer) getContainer();
-      LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
+      LocalHome localHome = statelessContainer.getAnnotation(LocalHome.class);
       if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
          Class<?>[] interfaces = {localHome.value()};
@@ -123,8 +91,8 @@
    public void stop() throws Exception
    {
       super.stop();
-      EJBContainer statelessContainer = (EJBContainer) getContainer();
-      LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
+      SessionSpecContainer statelessContainer = this.getContainer();
+      LocalHome localHome = statelessContainer.getAnnotation(LocalHome.class);
       if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
          Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()));
@@ -132,42 +100,30 @@
    }
 
 
-   public Object createProxy()
+   public Object createProxyBusiness()
    {
-      /*
-      try
-      {
-         Object[] args = {new StatelessLocalProxy(container)};
-         return proxyConstructor.newInstance(args);
-      }
-      catch (InstantiationException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getTargetException());  //To change body of catch statement use Options | File Templates.
-      }
-      */
-      return constructProxy(new StatelessLocalProxy(getContainer()));
+      return this.constructProxyBusiness(new StatelessLocalProxy(getContainer()));
    }
-
-   protected StatelessHandleImpl createHandle()
+   
+   @SuppressWarnings("unchecked")
+   public <T extends EJBLocalObject> T createProxyEjb21()
    {
-      StatelessHandleImpl handle = new StatelessHandleImpl();
-      LocalBinding remoteBinding = (LocalBinding) getContainer().resolveAnnotation(LocalBinding.class);
-      if (remoteBinding != null)
-         handle.jndiName = remoteBinding.jndiBinding();
-
-      return handle;
+      return (T)this.createProxy(SpecificationInterfaceType.EJB21);
    }
+   
+   private Object createProxy(SpecificationInterfaceType type)
+   {
+      StatelessLocalProxy proxy = new StatelessLocalProxy(this.getContainer());
+      return type.equals(SpecificationInterfaceType.EJB30_BUSINESS) ? this.constructProxyBusiness(proxy) : this
+            .constructEjb21Proxy(proxy);
+   }
 
+   @Override
+   protected StatelessHandleRemoteImpl createHandle()
+   {
+      // Local beans have no Handle
+      //TODO Rework the contract such that this method does not need to be
+      // defined for local proxy factories
+      return null;
+   }
 }

Modified: projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -21,24 +21,18 @@
  */
 package org.jboss.ejb3.stateless;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
 import javax.ejb.RemoteHome;
 import javax.naming.NamingException;
 
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.advice.AdviceStack;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
 import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.naming.Util;
 
 
 /**
@@ -47,88 +41,32 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class StatelessRemoteProxyFactory extends BaseStatelessProxyFactory implements RemoteProxyFactory
+public class StatelessRemoteProxyFactory extends BaseStatelessRemoteProxyFactory implements RemoteProxyFactory
 {
    private static final Logger log = Logger.getLogger(StatelessRemoteProxyFactory.class);
+   
+   private static final String STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS = "StatelessSessionClientInterceptors";
 
-   protected RemoteBinding binding;
-   protected InvokerLocator locator;
-
-   public StatelessRemoteProxyFactory(SessionContainer container, RemoteBinding binding)
+   public StatelessRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
-      super(container, binding.jndiBinding());
-      
-      this.binding = binding;
+      super(container, binding);
    }
-
-   protected Class<?>[] getInterfaces()
-   {
-      SessionContainer container = this.getContainer();
-      RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
-
-      boolean bindTogether = false;
-
-      if (remoteHome != null && bindHomeAndBusinessTogether(container))
-         bindTogether = true;
-
-      // Obtain all remote interfaces
-      Set<Class<?>> remoteInterfaces = new HashSet<Class<?>>();
-      remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(getContainer())));
-
-      // Ensure remote interfaces defined
-      if (remoteInterfaces.size() > 0)
-      {
-         // Add JBossProxy
-         remoteInterfaces.add(JBossProxy.class);
-
-         // If binding along w/ home, add home
-         if (bindTogether)
-         {
-            remoteInterfaces.add(remoteHome.value());
-         }
-      }
-      else
-      {
-         // No remote interfaces defined, log warning
-         log.warn("[EJBTHREE-933] NPE when deploying web service beans");
-      }
-
-      // Return
-      return remoteInterfaces.toArray(new Class<?>[]
-      {});
-   }
    
-   protected void validateEjb21Views()
+   protected boolean bindHomeAndBusinessTogether(SessionSpecContainer container)
    {
-      // Obtain Container
-      EJBContainer container = this.getContainer();
-
-      // Obtain @RemoteHome
-      RemoteHome remoteHome = container.getAnnotation(RemoteHome.class);
-
-      // Ensure that if EJB 2.1 Components are defined, they're complete
-      this.validateEjb21Views(remoteHome == null ? null : remoteHome.value(), ProxyFactoryHelper
-            .getRemoteInterfaces(container));
-   }
-   
-   protected boolean bindHomeAndBusinessTogether(EJBContainer container)
-   {
       return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteBusinessJndiName(container));
    }
 
    public void init() throws Exception
    {
       super.init();
-      String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
-      locator = new InvokerLocator(clientBindUrl);
    }
 
    public void start() throws Exception
    {
       super.start();
-      EJBContainer statelessContainer = (EJBContainer) getContainer();
-      RemoteHome remoteHome = (RemoteHome) statelessContainer.resolveAnnotation(RemoteHome.class);
-      if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
+      RemoteHome remoteHome = this.getContainer().getAnnotation(RemoteHome.class);
+      if (remoteHome != null && !bindHomeAndBusinessTogether(this.getContainer()))
       {
          Object homeProxy = createHomeProxy(remoteHome.value());
          String jndiName = ProxyFactoryHelper.getHomeJndiName(getContainer());
@@ -150,29 +88,21 @@
    public void stop() throws Exception
    {
       super.stop();
-      EJBContainer statelessContainer = (EJBContainer) getContainer();
-      RemoteHome remoteHome = (RemoteHome) statelessContainer.resolveAnnotation(RemoteHome.class);
+      SessionSpecContainer statelessContainer = this.getContainer();
+      RemoteHome remoteHome = this.getContainer().getAnnotation(RemoteHome.class);
       if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
          Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()));
       }
    }
 
-   protected StatelessHandleImpl createHandle()
+   public Object createHomeProxy(Class<?> homeInterface)
    {
-      StatelessHandleImpl handle = new StatelessHandleImpl();
-      RemoteBinding remoteBinding = (RemoteBinding) getContainer().resolveAnnotation(RemoteBinding.class);
-      if (remoteBinding != null)
-         handle.jndiName = remoteBinding.jndiBinding() ;
-
-      return handle;
-   }
-
-   public Object createHomeProxy(Class homeInterface)
-   {
       try
       {
-         String stackName = "StatelessSessionClientInterceptors";
+         String stackName = this.getStackNameInterceptors();
+         RemoteBinding binding = this.getBinding();
+         InvokerLocator locator = this.getLocator();
          if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
          {
             stackName = binding.interceptorStack();
@@ -181,27 +111,19 @@
          StatelessRemoteProxy proxy = new StatelessRemoteProxy(getContainer(),
                stack.createInterceptors(getContainer().getAdvisor(), null), locator);
          setEjb21Objects(proxy);
-         Class[] interfaces = {homeInterface};
+         Class<?>[] interfaces = {homeInterface};
          return java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(), interfaces, proxy);
       }
       catch (IllegalArgumentException e)
       {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
+         throw new RuntimeException(e);
       }
    }
 
-   public Object createProxy()
+   @Override
+   String getStackNameInterceptors()
    {
-      String stackName = "StatelessSessionClientInterceptors";
-      if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
-      {
-         stackName = binding.interceptorStack();
-      }
-      AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-      StatelessRemoteProxy proxy = new StatelessRemoteProxy(getContainer(),
-            stack.createInterceptors(getContainer().getAdvisor(), null), locator);
-      setEjb21Objects(proxy);
-      return constructProxy(proxy);
+      return StatelessRemoteProxyFactory.STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS;
    }
 
 }

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/bank/TellerRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/bank/TellerRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/bank/TellerRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -22,7 +22,7 @@
 package org.jboss.ejb3.test.bank;
 
 import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 
 /**
@@ -35,20 +35,8 @@
 {
    private static final Logger log = Logger.getLogger(TellerRemoteProxyFactory.class);
    
-   public TellerRemoteProxyFactory(SessionContainer container, RemoteBinding binding)
+   public TellerRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
       super(container, binding);
    }
-
-   protected Class[] getInterfaces()
-   {
-      Class[] remoteInterfaces = super.getInterfaces();
-
-      Class[] interfaces = new Class[remoteInterfaces.length + 1];
-
-      System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
-      interfaces[remoteInterfaces.length] = org.jboss.ejb3.test.bank.ProxyFactoryInterface.class;
-
-      return interfaces;
-   }
 }

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/ejbthree1122/unit/MultipleDefinitionsOfSameBusinessInterfaceUnitTestCase.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/ejbthree1122/unit/MultipleDefinitionsOfSameBusinessInterfaceUnitTestCase.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/ejbthree1122/unit/MultipleDefinitionsOfSameBusinessInterfaceUnitTestCase.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -100,22 +100,14 @@
 
    // Internal Helper Methods
 
-   private void internalTestRemoteView(String jndiName)
+   private void internalTestRemoteView(String jndiName) throws Exception
    {
       // Initialize
       TestRemoteBusinessInterface test = null;
 
       // Lookup
-      try
-      {
-         test = (TestRemoteBusinessInterface) this.getInitialContext().lookup(
-               jndiName);
-      }
-      catch (Throwable t)
-      {
-         log.error(t);
-         JBossTestCase.fail(t.getMessage());
-      }
+      test = (TestRemoteBusinessInterface) this.getInitialContext().lookup(jndiName);
+      
       // Ensure lookup succeeds; bean is deployed
       JBossTestCase.assertNotNull(test);
 
@@ -131,21 +123,14 @@
       }
    }
 
-   private void internalTestLocalView(String remoteDelegateJndiName)
+   private void internalTestLocalView(String remoteDelegateJndiName) throws Exception
    {
       // Initialize
       TestRemoteBusinessInterface test = null;
 
       // Lookup
-      try
-      {
-         test = (TestRemoteBusinessInterface) this.getInitialContext().lookup(remoteDelegateJndiName);
-      }
-      catch (Throwable t)
-      {
-         log.error(t);
-         JBossTestCase.fail(t.getMessage());
-      }
+      test = (TestRemoteBusinessInterface) this.getInitialContext().lookup(remoteDelegateJndiName);
+      
       // Ensure lookup succeeds; bean is deployed
       JBossTestCase.assertNotNull(test);
 

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/HomedStatefulSession30Bean.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/HomedStatefulSession30Bean.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/HomedStatefulSession30Bean.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -30,8 +30,6 @@
 import javax.ejb.Stateful;
 import javax.naming.InitialContext;
 
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.logging.Logger;
 
 /**
@@ -43,8 +41,6 @@
 @LocalHome(StatefulSession30LocalHome.class)
 @Local({LocalStatefulSession30Business.class,LocalStatefulSession30.class})
 @Remote(StatefulSession30.class)
- at RemoteBinding(jndiBinding = "HomedStatefulSession30Remote")
- at LocalBinding(jndiBinding = "HomedLocalStatefulSession30")
 public class HomedStatefulSession30Bean implements java.io.Serializable
 {
    

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session21Bean.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session21Bean.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session21Bean.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -23,7 +23,6 @@
 
 import javax.ejb.SessionContext;
 import javax.naming.InitialContext;
-import javax.naming.NamingEnumeration;
 
 import org.jboss.ejb3.Container;
 import org.jboss.logging.Logger;
@@ -45,7 +44,6 @@
    {
       try {
          InitialContext jndiContext = new InitialContext();
-         
          Session30 session = (Session30)jndiContext.lookup(Container.ENC_CTX_NAME + "/env/Session30");
          return session.access();
       } catch (Exception e)

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session30Bean.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session30Bean.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/Session30Bean.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -48,7 +48,7 @@
 @RemoteHome(Session30Home.class)
 @LocalHome(Session30LocalHome.class)
 @LocalHomeBinding(jndiBinding = Session30LocalHome.JNDI_NAME_SESSION_30)
- at EJBs({@EJB(name="injected", beanInterface=org.jboss.ejb3.test.reference21_30.Session21.class, beanName="Session21")})
+ at EJBs({@EJB(name="injected", beanInterface=org.jboss.ejb3.test.reference21_30.Session21Home.class, beanName="Session21")})
 
 public class Session30Bean implements Session30RemoteBusiness, LocalSession30Business
 {
@@ -63,7 +63,8 @@
    {
       try {
          InitialContext jndiContext = new InitialContext();
-         Session21 session = (Session21)jndiContext.lookup(Container.ENC_CTX_NAME + "/env/injected");
+         Session21Home sessionHome = (Session21Home) jndiContext.lookup(Container.ENC_CTX_NAME + "/env/injected");
+         Session21 session = sessionHome.create();
          return session.access();
       } catch (Exception e)
       {

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/unit/ReferenceTestCase.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/unit/ReferenceTestCase.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/reference21_30/unit/ReferenceTestCase.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -32,6 +32,7 @@
 import junit.framework.Test;
 
 import org.jboss.ejb3.test.reference21_30.Session21;
+import org.jboss.ejb3.test.reference21_30.Session21Home;
 import org.jboss.ejb3.test.reference21_30.Session30;
 import org.jboss.ejb3.test.reference21_30.Session30Home;
 import org.jboss.ejb3.test.reference21_30.Session30RemoteBusiness;
@@ -62,7 +63,8 @@
    {
       InitialContext jndiContext = new InitialContext();
       
-      Session21 session = (Session21)jndiContext.lookup("Session21Remote");
+      Session21Home home = (Session21Home)jndiContext.lookup("Session21/home");
+      Session21 session = home.create();
       String access = session.access();
       assertEquals("Session21", access);
       access = session.access30();
@@ -73,7 +75,8 @@
    {
       InitialContext jndiContext = new InitialContext();
  
-      Session30 session = (Session30) jndiContext.lookup("Session30Remote");
+      Session30Home sessionHome = (Session30Home) jndiContext.lookup("Session30/home");
+      Session30 session = sessionHome.create();
       String access = session.access();
       assertEquals("Session30", access);
       access = session.access21();

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/stateful/StatefulRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -22,7 +22,7 @@
 package org.jboss.ejb3.test.stateful;
 
 import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 
 /**
@@ -36,21 +36,8 @@
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(StatefulRemoteProxyFactory.class);
    
-   public StatefulRemoteProxyFactory(SessionContainer container, RemoteBinding binding)
+   public StatefulRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
       super(container, binding);
    }
-
-   @Override
-   protected Class<?>[] getInterfacesForBusinessProxy()
-   {
-      Class<?>[] remoteInterfaces = super.getInterfacesForBusinessProxy();
-
-      Class<?>[] interfaces = new Class[remoteInterfaces.length + 1];
-
-      System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
-      interfaces[remoteInterfaces.length] = org.jboss.ejb3.test.stateful.ProxyFactoryInterface.class;
-
-      return interfaces;
-   }
 }

Modified: projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java	2008-04-08 16:28:41 UTC (rev 71798)
+++ projects/ejb3/branches/ejbthree1253/core/src/test/java/org/jboss/ejb3/test/statefulproxyfactoryoverride/StatefulRemoteProxyFactory.java	2008-04-08 17:01:10 UTC (rev 71799)
@@ -22,7 +22,7 @@
 package org.jboss.ejb3.test.statefulproxyfactoryoverride;
 
 import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.logging.Logger;
 
 /**
@@ -35,22 +35,9 @@
 {
    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(StatefulRemoteProxyFactory.class);
-   
-   public StatefulRemoteProxyFactory(SessionContainer container, RemoteBinding binding)
+
+   public StatefulRemoteProxyFactory(SessionSpecContainer container, RemoteBinding binding)
    {
       super(container, binding);
    }
-
-   @Override
-   protected Class<?>[] getInterfacesForBusinessProxy()
-   {
-      Class<?>[] remoteInterfaces = super.getInterfacesForBusinessProxy();
-
-      Class<?>[] interfaces = new Class[remoteInterfaces.length + 1];
-
-      System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
-      interfaces[remoteInterfaces.length] = org.jboss.ejb3.test.statefulproxyfactoryoverride.ProxyFactoryInterface.class;
-
-      return interfaces;
-   }
 }




More information about the jboss-cvs-commits mailing list