[jboss-cvs] JBossAS SVN: r64585 - in branches/Branch_4_2/ejb3: src/main/org/jboss/ejb3 and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 14 16:19:01 EDT 2007


Author: bdecoste
Date: 2007-08-14 16:19:01 -0400 (Tue, 14 Aug 2007)
New Revision: 64585

Added:
   branches/Branch_4_2/ejb3/src/resources/test-configs/localfromremote2/conf/jndi.properties
Modified:
   branches/Branch_4_2/ejb3/build-test.xml
   branches/Branch_4_2/ejb3/build.xml
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
Log:
[EJBTHREE-1019] StatefulLocalProxyFactory is Externalizable - no more NonSerialableFactory

Modified: branches/Branch_4_2/ejb3/build-test.xml
===================================================================
--- branches/Branch_4_2/ejb3/build-test.xml	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/build-test.xml	2007-08-14 20:19:01 UTC (rev 64585)
@@ -2812,6 +2812,22 @@
 	  <copy file="${build.lib}/stateless-test.jar" tofile="${build.lib}/stateless-test.ejb3"/>
    </target>
    
+   <target name="defaultremotebindings"
+      description="Builds all jar files."
+      depends="compile-classes">
+
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/defaultremotebindings-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/defaultremotebindings/*.class"/>
+         </fileset>
+         <fileset dir="${resources}/test/defaultremotebindings">
+            <include name="*.xml"/>
+         </fileset>
+      </jar>
+   </target>
+   
    <target name="localfromremote"
       description="Builds all jar files."
       depends="compile-classes">
@@ -3309,7 +3325,7 @@
 	  </copy>
    </target>
    
-   <target name="jars" depends="localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
+   <target name="jars" depends="defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921,
       ejbthree959, ejbthree963, ejbthree994, ejbthree1023, ejbthree1025,
@@ -3736,6 +3752,9 @@
          <param name="test" value="stateless"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="defaultremotebindings"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="concurrentnaming"/>
       </antcall>
       <antcall target="test" inheritRefs="true">

Modified: branches/Branch_4_2/ejb3/build.xml
===================================================================
--- branches/Branch_4_2/ejb3/build.xml	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/build.xml	2007-08-14 20:19:01 UTC (rev 64585)
@@ -339,10 +339,10 @@
             <include name="org/jboss/ejb3/stateful/StatefulRemoteInvocation.class"/>
             <include name="org/jboss/ejb3/ProxyUtils.class"/>
             <include name="org/jboss/ejb3/**/*Proxy.class"/>
-            <!--exclude name="org/jboss/ejb3/**/*LocalProxy.class"/-->
             <include name="org/jboss/ejb3/**/*HandleImpl.class"/>
-            <include name="org/jboss/ejb3/Container.class"/>
-            <include name="org/jboss/ejb3/*ProxyFactory.class"/>
+            <include name="org/jboss/ejb3/*Container.class"/>
+         	<include name="org/jboss/ejb3/stateful/StatefulContainer.class"/>
+            <include name="org/jboss/ejb3/**/*ProxyFactory.class"/>
             <include name="org/jboss/ejb3/proxy/**/*.class"/>
             <include name="org/jboss/ejb3/*ServiceServer*.class"/>
             <include name="org/jboss/ejb3/*KernelAbstraction*.class"/>

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -51,7 +51,7 @@
    public static InitialContext getInitialContext() throws NamingException
    {
       InitialContext jndiContext;
-      
+       
       if (props == null)
       {
          if (baseInitialContext == null)

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -48,7 +48,7 @@
       String factoryName = (String) ref.get(FACTORY).getContent();
      
       try
-      {
+      {         
          ProxyFactory factory = (ProxyFactory) nameCtx.lookup(factoryName);
          Object proxy = factory.createProxy();
          MarshalledValuePair marshalledProxy = new MarshalledValuePair(proxy);

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -32,6 +32,8 @@
 import javax.naming.Reference;
 import javax.naming.StringRefAddr;
 import javax.naming.spi.ObjectFactory;
+
+import org.jboss.logging.Logger;
 import org.jboss.naming.Util;
 
 /**
@@ -50,6 +52,8 @@
 public class NonSerializableFactory implements ObjectFactory
 {
    private static Map wrapperMap = Collections.synchronizedMap(new HashMap());
+   
+   private static final Logger log = Logger.getLogger(NonSerializableFactory.class);
 
    public static void unbind(Context ctx, String strName) throws NamingException
    {
@@ -100,7 +104,8 @@
       Reference ref = (Reference) obj;
       RefAddr addr = ref.get("nns");
       String key = (String) addr.getContent();
-      return wrapperMap.get(key);
+      Object o = wrapperMap.get(key);
+      return o;
    }
 // --- End ObjectFactory interface methods
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -21,19 +21,26 @@
  */
 package org.jboss.ejb3.session;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+
+import javax.ejb.EJBException;
 import javax.ejb.EJBMetaData;
 import javax.ejb.Handle;
 import javax.ejb.HomeHandle;
 import javax.ejb.Remote;
 import javax.ejb.RemoteHome;
 import org.jboss.annotation.ejb.RemoteBinding;
-import org.jboss.aop.Advisor;
 import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.ProxyFactory;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.logging.Logger;
-import org.jboss.util.StringPropertyReplacer;
 import org.jboss.ejb3.proxy.EJBMetaDataImpl;
 import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
 
@@ -43,12 +50,17 @@
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  * @version $Revision$
  */
-public abstract class BaseSessionProxyFactory implements ProxyFactory
+public abstract class BaseSessionProxyFactory implements ProxyFactory, Externalizable
 {
    private static final Logger log = Logger.getLogger(BaseSessionProxyFactory.class);
    
-   protected Container container;
-   protected Advisor advisor;
+   private transient Container container;
+   protected String containerGuid;
+   protected String containerClusterUid;
+   protected boolean isClustered = false;
+   protected String jndiName;
+   protected Class proxyClass;
+   protected transient Constructor proxyConstructor;
   
    public Object createHomeProxy()
    {
@@ -58,9 +70,24 @@
    public void setContainer(Container container)
    {
       this.container = container;
-      this.advisor = (Advisor) container;
+      this.containerGuid = Ejb3Registry.guid(container);
+      this.containerClusterUid = Ejb3Registry.clusterUid(container);
+      this.isClustered = container.isClustered();
    }
    
+   protected Container getContainer()
+   {
+      if (container == null)
+      {
+         container = Ejb3Registry.findContainer(containerGuid);
+         
+         if (container == null && isClustered)
+            container = Ejb3Registry.getClusterContainer(containerClusterUid);
+      }
+      
+      return container;
+   }
+   
    protected void setEjb21Objects(BaseSessionRemoteProxy proxy)
    {
       proxy.setHandle(getHandle());
@@ -68,17 +95,15 @@
       proxy.setEjbMetaData(getEjbMetaData());
    }
    
-   abstract protected Handle getHandle();
-   
    protected HomeHandle getHomeHandle()
    {
-      EJBContainer ejbContainer = (EJBContainer)container;
+      EJBContainer ejbContainer = (EJBContainer)getContainer();
       
       HomeHandleImpl homeHandle = null;
       
       RemoteBinding remoteBindingAnnotation = (RemoteBinding)ejbContainer.resolveAnnotation(RemoteBinding.class);
       if (remoteBindingAnnotation != null)
-         homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(container));
+         homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(getContainer()));
       
       return homeHandle;
    }
@@ -90,7 +115,7 @@
       Class pkClass = Object.class;
       HomeHandleImpl homeHandle = null;
       
-      EJBContainer ejbContainer = (EJBContainer)container;
+      EJBContainer ejbContainer = (EJBContainer)getContainer();
       
       Remote remoteAnnotation = (Remote)ejbContainer.resolveAnnotation(Remote.class);
       if (remoteAnnotation != null)
@@ -106,4 +131,44 @@
       
       return metadata;
    }
+   
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      containerGuid = in.readUTF();
+      containerClusterUid = in.readUTF();
+      isClustered = in.readBoolean();
+      jndiName = in.readUTF();
+      proxyClass = (Class)in.readObject();
+      
+      try
+      {
+         if (getContainer() == null)
+            throw new EJBException("Invalid (i.e. remote) invocation of local interface (null container) for " + containerGuid);
+         else
+         {
+            Class[] interfaces = getInterfaces();
+            Class proxyClass = java.lang.reflect.Proxy.getProxyClass(getContainer().getBeanClass().getClassLoader(), interfaces);
+            final Class[] constructorParams = {InvocationHandler.class};
+            proxyConstructor = proxyClass.getConstructor(constructorParams);
+         }
+         
+      }
+      catch (NoSuchMethodException e)
+      {
+         throw new RuntimeException("Unable to read Externalized proxy " + e);
+      }
+   }
+
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      out.writeUTF(containerGuid);
+      out.writeUTF(containerClusterUid);
+      out.writeBoolean(isClustered);
+      out.writeUTF(jndiName);
+      out.writeObject(proxyClass);
+   }
+   
+   protected abstract Class[] getInterfaces();
+   
+   abstract protected Handle getHandle();
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/BaseStatefulProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -21,6 +21,9 @@
  */
 package org.jboss.ejb3.stateful;
 
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import javax.naming.Context;
@@ -43,19 +46,14 @@
 public abstract class BaseStatefulProxyFactory extends org.jboss.ejb3.session.BaseSessionProxyFactory implements ProxyFactory
 {
    private static final Logger log = Logger.getLogger(BaseStatefulProxyFactory.class);
-
-   protected Class proxyClass;
-   protected Constructor proxyConstructor;
-   protected Context proxyFactoryContext;
-   protected String jndiName;
-
+   
    public static final String PROXY_FACTORY_NAME = "StatefulProxyFactory";
 
    public void init() throws Exception
    {
       initializeJndiName();
       Class[] interfaces = getInterfaces();
-      Class proxyClass = java.lang.reflect.Proxy.getProxyClass(container.getBeanClass().getClassLoader(), interfaces);
+      Class proxyClass = java.lang.reflect.Proxy.getProxyClass(getContainer().getBeanClass().getClassLoader(), interfaces);
       final Class[] constructorParams =
               {InvocationHandler.class};
       proxyConstructor = proxyClass.getConstructor(constructorParams);
@@ -64,8 +62,7 @@
    public void start() throws Exception
    {
       init();
-
-      Context ctx = container.getInitialContext();
+      Context ctx = getContainer().getInitialContext();
       Name name = ctx.getNameParser("").parse(jndiName);
       ctx = Util.createSubcontext(ctx, name.getPrefix(name.size() - 1));
       String atom = name.get(name.size() - 1);
@@ -76,7 +73,7 @@
          Util.rebind(ctx, atom, ref);
       } catch (NamingException e)
       {
-         NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
+         NamingException namingException = new NamingException("Could not bind stateful proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + ctx.getNameInNamespace() + "/" + atom);
          namingException.setRootCause(e);
          throw namingException;
       }
@@ -84,10 +81,18 @@
 
    public void stop() throws Exception
    {
-      Util.unbind(container.getInitialContext(), jndiName);
+      Util.unbind(getContainer().getInitialContext(), jndiName);
    }
+   
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      super.readExternal(in);
+   }
 
-   protected abstract Class[] getInterfaces();
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      super.writeExternal(out);     
+   }
 
    protected abstract void initializeJndiName();
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -80,7 +80,7 @@
 
    protected Class[] getInterfaces()
    {
-      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
+      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(getContainer());
       Class[] interfaces = new Class[remoteInterfaces.length + 1];
       System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
       interfaces[remoteInterfaces.length] = JBossProxy.class;
@@ -89,21 +89,21 @@
 
    protected void initializeJndiName()
    {
-      jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
+      jndiName = ProxyFactoryHelper.getRemoteJndiName(getContainer(), binding);
    }
 
    public void start() throws Exception
    {
       String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
       locator = new InvokerLocator(clientBindUrl);
-      Clustered clustered = (Clustered) advisor.resolveAnnotation(Clustered.class);
+      Clustered clustered = (Clustered) ((Advisor)getContainer()).resolveAnnotation(Clustered.class);
       if (clustered == null) throw new RuntimeException("Could not find @Clustered annotation.  Cannot deploy.");
-      String partitionName = ((StatefulContainer) container).getPartitionName();
-      proxyFamilyName = ((StatefulContainer) container).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
-      HAPartition partition = (HAPartition) container.getInitialContext().lookup("/HAPartition/" + partitionName);
+      String partitionName = ((StatefulContainer) getContainer()).getPartitionName();
+      proxyFamilyName = ((StatefulContainer) getContainer()).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
+      HAPartition partition = (HAPartition) getContainer().getInitialContext().lookup("/HAPartition/" + partitionName);
       hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
       ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
-      ((StatefulContainer) container).getClusterFamilies().put(proxyFamilyName, hatarget);
+      ((StatefulContainer) getContainer()).getClusterFamilies().put(proxyFamilyName, hatarget);
       if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(LoadBalancePolicy.class))
       {
          lbPolicy = new FirstAvailable();
@@ -124,10 +124,10 @@
       Object factoryProxy = Remoting.createPojiProxy(targetId, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
       try
       {
-         Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
+         Util.rebind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
       } catch (NamingException e)
       {
-         NamingException namingException = new NamingException("Could not bind stateful cluster proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
+         NamingException namingException = new NamingException("Could not bind stateful cluster proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
          namingException.setRootCause(e);
          throw namingException;
       }
@@ -146,8 +146,8 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         String partitionName = ((StatefulContainer) container).getPartitionName();
-         Object[] args = {new StatefulClusteredProxy(container, stack.createInterceptors((Advisor) container, null), 
+         String partitionName = ((StatefulContainer) getContainer()).getPartitionName();
+         Object[] args = {new StatefulClusteredProxy(getContainer(), stack.createInterceptors((Advisor) getContainer(), null), 
                                                      wrapper, lbPolicy, partitionName)};
          
          return proxyConstructor.newInstance(args);
@@ -180,15 +180,15 @@
       Dispatcher.singleton.unregisterTarget(getTargetId());
       hatarget.destroy();
       drm.unregisterListener(proxyFamilyName, this);
-      ((StatefulContainer) container).getClusterFamilies().remove(proxyFamilyName);
-      Util.unbind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME);
+      ((StatefulContainer) getContainer()).getClusterFamilies().remove(proxyFamilyName);
+      Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
       super.stop();
    }
    
    protected StatefulHandleImpl getHandle()
    {
       StatefulHandleImpl handle = new StatefulHandleImpl();
-      RemoteBinding remoteBinding = (RemoteBinding)advisor.resolveAnnotation(RemoteBinding.class);
+      RemoteBinding remoteBinding = (RemoteBinding)((Advisor)getContainer()).resolveAnnotation(RemoteBinding.class);
       if (remoteBinding != null)
          handle.jndiName = remoteBinding.jndiBinding();
  
@@ -201,7 +201,7 @@
    protected String getTargetId()
    {
       assert jndiName != null : "jndiName is null";      
-      String partition = ((StatefulContainer) container).getPartitionName();
+      String partition = ((StatefulContainer) getContainer()).getPartitionName();
       return jndiName + PROXY_FACTORY_NAME + "@" + partition;
    }
    

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -21,18 +21,25 @@
  */
 package org.jboss.ejb3.stateful;
 
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.lang.reflect.InvocationTargetException;
 import java.rmi.dgc.VMID;
 
+import javax.ejb.EJBException;
 import javax.ejb.LocalHome;
 import javax.naming.NamingException;
 import org.jboss.annotation.ejb.LocalBinding;
+import org.jboss.aop.Advisor;
+import org.jboss.ejb3.Container;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.NonSerializableFactory;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.logging.Logger;
+import org.jboss.naming.Util;
 
 
 /**
@@ -51,7 +58,7 @@
    {
       Class[] interfaces;
       
-      StatefulContainer statefulContainer = (StatefulContainer) container;
+      StatefulContainer statefulContainer = (StatefulContainer) getContainer();
       LocalHome localHome = (LocalHome) statefulContainer.resolveAnnotation(LocalHome.class);
       
       boolean bindTogether = false;
@@ -59,7 +66,7 @@
       if (localHome != null && bindHomeAndBusinessTogether(statefulContainer))
          bindTogether = true;
       
-      Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(container);
+      Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(getContainer());
       if (bindTogether)
          interfaces = new Class[localInterfaces.length + 3];
       else
@@ -82,45 +89,50 @@
 
    protected void initializeJndiName()
    {
-      jndiName = ProxyFactoryHelper.getLocalJndiName(container);
+      jndiName = ProxyFactoryHelper.getLocalJndiName(getContainer());
    }
+   
+   public VMID getVMID()
+   {
+      return vmid;
+   }
 
    public void start() throws Exception
    {
       super.start();
-
+      
       try
       {
-         NonSerializableFactory.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, this);
+         Util.rebind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME, this);
       }
       catch (NamingException e)
       {
-         NamingException namingException = new NamingException("Could not bind stateful local proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
+         NamingException namingException = new NamingException("Could not bind stateful local proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
          namingException.setRootCause(e);
          throw namingException;
       }
 
-      StatefulContainer statefulContainer = (StatefulContainer) container;
-      LocalHome localHome = (LocalHome) ((EJBContainer) container).resolveAnnotation(LocalHome.class);
+      StatefulContainer statefulContainer = (StatefulContainer) getContainer();
+      LocalHome localHome = (LocalHome) ((EJBContainer) getContainer()).resolveAnnotation(LocalHome.class);
       if (localHome != null  && !bindHomeAndBusinessTogether(statefulContainer))
       {
          Class[] interfaces = {localHome.value()};
-         Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(container.getBeanClass().getClassLoader(),
-                                                                     interfaces, new StatefulLocalHomeProxy(container));
-         NonSerializableFactory.rebind(container.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(container), homeProxy);
+         Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(),
+                                                                     interfaces, new StatefulLocalHomeProxy(getContainer()));
+         Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()), homeProxy);
       }
    }
 
    public void stop() throws Exception
    {
       super.stop();
-      NonSerializableFactory.unbind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME);
+      Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
       
-      StatefulContainer statefulContainer = (StatefulContainer) container;
-      LocalHome localHome = (LocalHome) ((EJBContainer) container).resolveAnnotation(LocalHome.class);
+      StatefulContainer statefulContainer = (StatefulContainer) getContainer();
+      LocalHome localHome = (LocalHome) ((EJBContainer) getContainer()).resolveAnnotation(LocalHome.class);
       if (localHome != null  && !bindHomeAndBusinessTogether(statefulContainer))
       {
-         NonSerializableFactory.unbind(container.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(container));
+         Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()));
       }
    }
 
@@ -128,11 +140,11 @@
    {
       try
       {
-         StatefulContainer sfsb = (StatefulContainer) container;
+         StatefulContainer sfsb = (StatefulContainer) getContainer();
          StatefulBeanContext ctx = sfsb.getCache().create();
          ctx.setInUse(false);
          Object id = ctx.getId();
-         Object[] args = {new StatefulLocalProxy(container, id, vmid)};
+         Object[] args = {new StatefulLocalProxy(getContainer(), id, vmid)};
          return proxyConstructor.newInstance(args);
       }
       catch (InstantiationException e)
@@ -157,8 +169,8 @@
    {
       try
       {
-         StatefulContainer sfsb = (StatefulContainer) container;
-         Object[] args = {new StatefulLocalProxy(container, id, vmid)};
+         StatefulContainer sfsb = (StatefulContainer) getContainer();
+         Object[] args = {new StatefulLocalProxy(getContainer(), id, vmid)};
          return proxyConstructor.newInstance(args);
       }
       catch (InstantiationException e)
@@ -182,9 +194,9 @@
    {
       try
       {
-         StatefulContainer sfsb = (StatefulContainer) container;
+         StatefulContainer sfsb = (StatefulContainer) getContainer();
          Object id = sfsb.createSession(initTypes, initValues);
-         Object[] args = {new StatefulLocalProxy(container, id, vmid)};
+         Object[] args = {new StatefulLocalProxy(getContainer(), id, vmid)};
          return proxyConstructor.newInstance(args);
       }
       catch (InstantiationException e)
@@ -208,10 +220,22 @@
    protected StatefulHandleImpl getHandle()
    {
       StatefulHandleImpl handle = new StatefulHandleImpl();
-      LocalBinding remoteBinding = (LocalBinding) advisor.resolveAnnotation(LocalBinding.class);
+      LocalBinding remoteBinding = (LocalBinding) ((Advisor)getContainer()).resolveAnnotation(LocalBinding.class);
       if (remoteBinding != null)
          handle.jndiName = remoteBinding.jndiBinding();
 
       return handle;
    }
+   
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      super.readExternal(in);
+      vmid = (VMID)in.readObject();
+   }
+
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      super.writeExternal(out);
+      out.writeObject(vmid);
+   }
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -69,7 +69,7 @@
    {
       Class[] interfaces;
       
-      StatefulContainer statefulContainer = (StatefulContainer) container;
+      StatefulContainer statefulContainer = (StatefulContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
       
       boolean bindTogether = false;
@@ -77,7 +77,7 @@
       if (remoteHome != null && bindHomeAndBusinessTogether(statefulContainer))
          bindTogether = true;
       
-      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
+      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(getContainer());
       if (bindTogether)
          interfaces = new Class[remoteInterfaces.length + 3];
       else
@@ -99,7 +99,7 @@
 
    protected void initializeJndiName()
    {
-      jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
+      jndiName = ProxyFactoryHelper.getRemoteJndiName(getContainer(), binding);
    }
 
    public void init() throws Exception
@@ -119,36 +119,36 @@
       Object factoryProxy = createPojiProxy(targetId, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
       try
       {
-         Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
+         Util.rebind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
       }
       catch (NamingException e)
       {
-         NamingException namingException = new NamingException("Could not bind stateful remote proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
+         NamingException namingException = new NamingException("Could not bind stateful remote proxy with ejb name " + getContainer().getEjbName() + " into JNDI under jndiName: " + getContainer().getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
          namingException.setRootCause(e);
          throw namingException;
       }
       assert !Dispatcher.singleton.isRegistered(targetId) : targetId + " is already registered";
       Dispatcher.singleton.registerTarget(targetId, this);
 
-      StatefulContainer statefulContainer = (StatefulContainer) container;
+      StatefulContainer statefulContainer = (StatefulContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
       if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
       {
          Object homeProxy = createHomeProxy(remoteHome.value());
-         Util.rebind(container.getInitialContext(), ProxyFactoryHelper.getHomeJndiName(container), homeProxy);
+         Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()), homeProxy);
       }
    }
 
    public void stop() throws Exception
    {
-      Util.unbind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME);
+      Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
       Dispatcher.singleton.unregisterTarget(getTargetId());
       
-      StatefulContainer statefulContainer = (StatefulContainer) container;
+      StatefulContainer statefulContainer = (StatefulContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
       if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
       {
-         Util.unbind(container.getInitialContext(), ProxyFactoryHelper.getHomeJndiName(container));
+         Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()));
       }
       super.stop();
    }
@@ -158,7 +158,7 @@
    {
       try
       {
-         Object containerId = container.getObjectName().getCanonicalName();
+         Object containerId = getContainer().getObjectName().getCanonicalName();
          String stackName = "StatefulSessionClientInterceptors";
          if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
          {
@@ -166,12 +166,12 @@
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
          if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
-         StatefulHomeRemoteProxy proxy = new StatefulHomeRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator);
+         StatefulHomeRemoteProxy proxy = new StatefulHomeRemoteProxy(getContainer(), stack.createInterceptors((Advisor) getContainer(), null), locator);
 
 
          setEjb21Objects(proxy);
          Class[] intfs = {homeInterface};
-         return java.lang.reflect.Proxy.newProxyInstance(container.getBeanClass().getClassLoader(), intfs, proxy);
+         return java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(), intfs, proxy);
       }
       catch (IllegalArgumentException e)
       {
@@ -189,7 +189,7 @@
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
          if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
-         StatefulRemoteProxy proxy = new StatefulRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator);
+         StatefulRemoteProxy proxy = new StatefulRemoteProxy(getContainer(), stack.createInterceptors((Advisor) getContainer(), null), locator);
 
 
          setEjb21Objects(proxy);
@@ -217,7 +217,7 @@
    protected StatefulHandleImpl getHandle()
    {
       StatefulHandleImpl handle = new StatefulHandleImpl();
-      RemoteBinding remoteBinding = (RemoteBinding) advisor.resolveAnnotation(RemoteBinding.class);
+      RemoteBinding remoteBinding = (RemoteBinding) ((Advisor)getContainer()).resolveAnnotation(RemoteBinding.class);
       if (remoteBinding != null)
          handle.jndiName = remoteBinding.jndiBinding();
 
@@ -234,7 +234,7 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         StatefulRemoteProxy proxy = new StatefulRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator, id);
+         StatefulRemoteProxy proxy = new StatefulRemoteProxy(getContainer(), stack.createInterceptors((Advisor) getContainer(), null), locator, id);
          setEjb21Objects(proxy);
          Object[] args = {proxy};
          return proxyConstructor.newInstance(args);

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -70,7 +70,7 @@
 
    protected Class[] getInterfaces()
    {
-      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
+      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(getContainer());
       Class[] interfaces = new Class[remoteInterfaces.length + 1];
       System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
       interfaces[remoteInterfaces.length] = JBossProxy.class;
@@ -79,21 +79,21 @@
 
    protected void initializeJndiName()
    {
-      jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
+      jndiName = ProxyFactoryHelper.getRemoteJndiName(getContainer(), binding);
    }
 
    public void start() throws Exception
    {
       String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
       locator = new InvokerLocator(clientBindUrl);
-      Clustered clustered = (Clustered) advisor.resolveAnnotation(Clustered.class);
+      Clustered clustered = (Clustered) ((Advisor)getContainer()).resolveAnnotation(Clustered.class);
       if (clustered == null) throw new RuntimeException("Could not find @Clustered annotation.  Cannot deploy.");
-      String partitionName = ((StatelessContainer) container).getPartitionName();
-      proxyFamilyName = ((StatelessContainer) container).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
-      HAPartition partition = (HAPartition) container.getInitialContext().lookup("/HAPartition/" + partitionName);
+      String partitionName = ((StatelessContainer) getContainer()).getPartitionName();
+      proxyFamilyName = ((StatelessContainer) getContainer()).getDeploymentQualifiedName() + locator.getProtocol() + partitionName;
+      HAPartition partition = (HAPartition) getContainer().getInitialContext().lookup("/HAPartition/" + partitionName);
       hatarget = new HATarget(partition, proxyFamilyName, locator, HATarget.ENABLE_INVOCATIONS);
       ClusteringTargetsRepository.initTarget(proxyFamilyName, hatarget.getReplicants());
-      ((StatelessContainer) container).getClusterFamilies().put(proxyFamilyName, hatarget);
+      ((StatelessContainer) getContainer()).getClusterFamilies().put(proxyFamilyName, hatarget);
       if (clustered.loadBalancePolicy() == null || clustered.loadBalancePolicy().equals(LoadBalancePolicy.class))
       {
          lbPolicy = new RandomRobin();
@@ -116,7 +116,7 @@
       proxy = null;
       hatarget.destroy();
       drm.unregisterListener(proxyFamilyName, this);
-      ((StatelessContainer) container).getClusterFamilies().remove(proxyFamilyName);
+      ((StatelessContainer) getContainer()).getClusterFamilies().remove(proxyFamilyName);
    }
 
    public Object createProxy()
@@ -133,9 +133,9 @@
          Object[] args = {new StatelessClusteredProxy(containerId, stack.createInterceptors((Advisor) container, null), wrapper, lbPolicy)};
          return proxyConstructor.newInstance(args);
          */
-         String partitionName = ((StatelessContainer) container).getPartitionName();
+         String partitionName = ((StatelessContainer) getContainer()).getPartitionName();
          
-         proxy = constructProxy(new StatelessClusteredProxy(container, stack.createInterceptors((Advisor) container, null), 
+         proxy = constructProxy(new StatelessClusteredProxy(getContainer(), stack.createInterceptors((Advisor) getContainer(), null), 
                                                             wrapper, lbPolicy, partitionName));
          return proxy;
       }
@@ -162,7 +162,7 @@
    protected StatelessHandleImpl getHandle()
    {
       StatelessHandleImpl handle = new StatelessHandleImpl();
-      RemoteBinding remoteBinding = (RemoteBinding)advisor.resolveAnnotation(RemoteBinding.class);
+      RemoteBinding remoteBinding = (RemoteBinding)((Advisor)getContainer()).resolveAnnotation(RemoteBinding.class);
       if (remoteBinding != null)
          handle.jndiName = remoteBinding.jndiBinding();
  

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -25,6 +25,7 @@
 import javax.ejb.LocalHome;
 
 import org.jboss.annotation.ejb.LocalBinding;
+import org.jboss.aop.Advisor;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.NonSerializableFactory;
@@ -46,7 +47,7 @@
    {
       Class[] interfaces;
       
-      EJBContainer statelessContainer = (EJBContainer) container;
+      EJBContainer statelessContainer = (EJBContainer) getContainer();
       LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
       
       boolean bindTogether = false;
@@ -54,7 +55,7 @@
       if (localHome != null && bindHomeAndBusinessTogether(statelessContainer))
          bindTogether = true;
       
-      Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(container);
+      Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(getContainer());
       
       if (bindTogether)
          interfaces = new Class[localInterfaces.length + 3];
@@ -77,21 +78,21 @@
 
    protected void initializeJndiName()
    {
-      jndiName = ProxyFactoryHelper.getLocalJndiName(container);
+      jndiName = ProxyFactoryHelper.getLocalJndiName(getContainer());
    }
 
    @Override
    public void start() throws Exception
    {
       super.start();
-      EJBContainer statelessContainer = (EJBContainer) container;
+      EJBContainer statelessContainer = (EJBContainer) getContainer();
       LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
       if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
          Class[] interfaces = {localHome.value()};
-         Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(container.getBeanClass().getClassLoader(),
-                                                                     interfaces, new StatelessLocalProxy(container));
-         NonSerializableFactory.rebind(container.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(container), homeProxy);
+         Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(),
+                                                                     interfaces, new StatelessLocalProxy(getContainer()));
+         NonSerializableFactory.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()), homeProxy);
       }
    }
 
@@ -99,24 +100,24 @@
    public void stop() throws Exception
    {
       super.stop();
-      EJBContainer statelessContainer = (EJBContainer) container;
+      EJBContainer statelessContainer = (EJBContainer) getContainer();
       LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
       if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
-         NonSerializableFactory.unbind(container.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(container));
+         NonSerializableFactory.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()));
       }
    }
 
 
    public Object createProxy()
    {
-      return constructProxy(new StatelessLocalProxy(container));
+      return constructProxy(new StatelessLocalProxy(getContainer()));
    }
 
    protected StatelessHandleImpl getHandle()
    {
       StatelessHandleImpl handle = new StatelessHandleImpl();
-      LocalBinding localBinding = (LocalBinding) advisor.resolveAnnotation(LocalBinding.class);
+      LocalBinding localBinding = (LocalBinding) ((Advisor)getContainer()).resolveAnnotation(LocalBinding.class);
       if (localBinding != null)
          handle.jndiName = localBinding.jndiBinding();
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -59,7 +59,7 @@
    {
       Class[] interfaces;
       
-      StatelessContainer statelessContainer = (StatelessContainer) container;
+      StatelessContainer statelessContainer = (StatelessContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statelessContainer.resolveAnnotation(RemoteHome.class);
       
       boolean bindTogether = false;
@@ -67,7 +67,7 @@
       if (remoteHome != null && bindHomeAndBusinessTogether(statelessContainer))
          bindTogether = true;
       
-      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
+      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(getContainer());
       
       if (bindTogether)
          interfaces = new Class[remoteInterfaces.length + 3];
@@ -92,7 +92,7 @@
 
    protected void initializeJndiName()
    {
-      jndiName = ProxyFactoryHelper.getRemoteJndiName(container, binding);
+      jndiName = ProxyFactoryHelper.getRemoteJndiName(getContainer(), binding);
    }
 
    public void init() throws Exception
@@ -105,24 +105,24 @@
    public void start() throws Exception
    {
       super.start();
-      EJBContainer statelessContainer = (EJBContainer) container;
+      EJBContainer statelessContainer = (EJBContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statelessContainer
             .resolveAnnotation(RemoteHome.class);
       if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
          Object homeProxy = createHomeProxy(remoteHome.value());
          try {
-            Util.rebind(container.getInitialContext(), ProxyFactoryHelper
-                  .getHomeJndiName(container), homeProxy);
+            Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper
+                  .getHomeJndiName(getContainer()), homeProxy);
          }
          catch (NamingException e)
          {
             NamingException namingException = new NamingException(
                   "Could not bind stateless home proxy with ejb name "
-                        + container.getEjbName()
+                        + getContainer().getEjbName()
                         + " into JNDI under jndiName: "
-                        + container.getInitialContext().getNameInNamespace()
-                        + "/" + ProxyFactoryHelper.getHomeJndiName(container));
+                        + getContainer().getInitialContext().getNameInNamespace()
+                        + "/" + ProxyFactoryHelper.getHomeJndiName(getContainer()));
             namingException.setRootCause(e);
             throw namingException;
          }
@@ -133,20 +133,20 @@
    public void stop() throws Exception
    {
       super.stop();
-      EJBContainer statelessContainer = (EJBContainer) container;
+      EJBContainer statelessContainer = (EJBContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statelessContainer
             .resolveAnnotation(RemoteHome.class);
       if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
-         Util.unbind(container.getInitialContext(), ProxyFactoryHelper
-               .getHomeJndiName(container));
+         Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper
+               .getHomeJndiName(getContainer()));
       }
    }
 
    protected StatelessHandleImpl getHandle()
    {
       StatelessHandleImpl handle = new StatelessHandleImpl();
-      RemoteBinding remoteBinding = (RemoteBinding) advisor
+      RemoteBinding remoteBinding = (RemoteBinding) ((Advisor)getContainer())
             .resolveAnnotation(RemoteBinding.class);
       if (remoteBinding != null)
          handle.jndiName = remoteBinding.jndiBinding();
@@ -164,11 +164,11 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         StatelessRemoteProxy proxy = new StatelessRemoteProxy(container,
-               stack.createInterceptors((Advisor) container, null), locator);
+         StatelessRemoteProxy proxy = new StatelessRemoteProxy(getContainer(),
+               stack.createInterceptors((Advisor) getContainer(), null), locator);
          setEjb21Objects(proxy);
          Class[] interfaces = { homeInterface };
-         return java.lang.reflect.Proxy.newProxyInstance(container
+         return java.lang.reflect.Proxy.newProxyInstance(getContainer()
                .getBeanClass().getClassLoader(), interfaces, proxy);
       } catch (IllegalArgumentException e)
       {
@@ -188,8 +188,8 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         StatelessRemoteProxy proxy = new StatelessRemoteProxy(container,
-               stack.createInterceptors((Advisor) container, null), locator);
+         StatelessRemoteProxy proxy = new StatelessRemoteProxy(getContainer(),
+               stack.createInterceptors((Advisor) getContainer(), null), locator);
          setEjb21Objects(proxy);
          /*
           * Object[] args = {proxy}; return proxyConstructor.newInstance(args);

Added: branches/Branch_4_2/ejb3/src/resources/test-configs/localfromremote2/conf/jndi.properties
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test-configs/localfromremote2/conf/jndi.properties	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/resources/test-configs/localfromremote2/conf/jndi.properties	2007-08-14 20:19:01 UTC (rev 64585)
@@ -0,0 +1,5 @@
+# DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING
+#
+java.naming.provider.url=localhost:1199
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/localfromremote/unit/LocalTestCase.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -21,6 +21,8 @@
  */
 package org.jboss.ejb3.test.localfromremote.unit;
 
+import javax.naming.InitialContext;
+
 import org.jboss.ejb3.test.localfromremote.StatefulRemote;
 import org.jboss.ejb3.test.localfromremote.StatelessRemote;
 import org.jboss.logging.Logger;
@@ -76,7 +78,8 @@
    
    public void testStatefulLocalFromRemote() throws Exception
    {
-      StatelessRemote bean = (StatelessRemote) getInitialContext().lookup("StatelessBean/remote");
+      InitialContext jndiContext = new InitialContext();
+      StatelessRemote bean = (StatelessRemote) jndiContext.lookup("StatelessBean/remote");
       assertNotNull(bean);
       
       try
@@ -84,8 +87,11 @@
          bean.localCall();
          fail("should not be allowed to call local interface remotely");
       }
-      catch (javax.ejb.EJBException e)
-      {}
+      catch (javax.naming.NamingException e)
+      {
+         if (e.getCause() == null || !(e.getCause() instanceof javax.ejb.EJBException))
+            fail("should not be allowed to call local interface remotely");
+      }
    }
    
    public static Test suite() throws Exception

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java	2007-08-14 18:46:04 UTC (rev 64584)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/stateful/unit/RemoteUnitTestCase.java	2007-08-14 20:19:01 UTC (rev 64585)
@@ -270,7 +270,10 @@
       catch (Exception e)
       {
          if (e.getCause() == null || !(e.getCause() instanceof javax.ejb.EJBException))
-            fail("EJBException should be thrown as cause");
+         {
+            fail("EJBException should be thrown as cause: " + e);
+            e.printStackTrace();
+         }
       }
    }
    




More information about the jboss-cvs-commits mailing list