[jboss-cvs] JBossAS SVN: r64543 - in branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3: mdb and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 10 13:03:05 EDT 2007


Author: bdecoste
Date: 2007-08-10 13:03:04 -0400 (Fri, 10 Aug 2007)
New Revision: 64543

Modified:
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/Container.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/BaseRemoteProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusteredProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusteredProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxy.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/TimerServiceFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/JBossTimerServiceFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/TimerServiceFacade.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/PersistentTimer.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/TimerServiceImpl.java
Log:
[JBPAPP-260],[JBPAPP-263] merge of [EJBTHREE-975],[EJBTHREE-942]

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -122,7 +122,7 @@
 
    public void writeExternal(ObjectOutput out) throws IOException
    {
-      out.writeUTF(container.getObjectName().getCanonicalName());
+      out.writeUTF(Ejb3Registry.guid(container));
    }
 
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/Container.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/Container.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -87,4 +87,6 @@
    DependencyPolicy getDependencyPolicy();
    
    InvocationStatistics getInvokeStats();
+   
+   boolean isClustered();
 }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/LocalProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/LocalProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -40,9 +40,10 @@
 {
    private static Logger log = Logger.getLogger(LocalProxy.class);
    
-   // FIXME: should be private
    protected transient Container container = null;
-   private String containerId;
+   protected String containerClusterUid;
+   protected String containerGuid;
+   protected String proxyName;
 
    protected LocalProxy()
    {
@@ -51,28 +52,32 @@
    protected LocalProxy(Container container)
    {
       this.container = container;
-      this.containerId = container.getObjectName().getCanonicalName();
+      this.containerGuid = Ejb3Registry.guid(container);
+      this.containerClusterUid = Ejb3Registry.clusterUid(container);
+      proxyName = container.getEjbName();
    }
 
    protected Container getContainer()
    {
       if(container == null)
-         container = Ejb3Registry.findContainer(containerId);
+         container = Ejb3Registry.findContainer(containerGuid);
       if(container == null)
-         log.warn("Container " + containerId + " is not yet available");
+         log.warn("Container " + containerGuid + " is not yet available");
       return container;
    }
    
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    {
-      this.containerId = in.readUTF();
-      // TODO: one container is private, this won't have to be done anymore
-      this.container = Ejb3Registry.findContainer(containerId);
+      this.containerGuid = in.readUTF();
+      this.containerClusterUid = in.readUTF();
+      this.proxyName = in.readUTF();
    }
 
    public void writeExternal(ObjectOutput out) throws IOException
    {
-      out.writeUTF(containerId);
+      out.writeUTF(containerGuid);
+      out.writeUTF(containerClusterUid);
+      out.writeUTF(proxyName);
    }
 
    public abstract String toString();

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -110,8 +110,8 @@
    public void instantiated()
    {
       super.instantiated();
-      proxyDeployer.initializeRemoteBindingMetadata();
-      proxyDeployer.initializeLocalBindingMetadata();
+ //     proxyDeployer.initializeRemoteBindingMetadata();
+ //     proxyDeployer.initializeLocalBindingMetadata();
    }
 
    @Override
@@ -119,6 +119,15 @@
    {
       super.processMetadata(dependencyPolicy);
    }
+   
+   public void create() throws Exception
+   {
+      super.create();
+      
+      // moved from instantiated so AspectDomain is processed before proxy metadata
+      proxyDeployer.initializeRemoteBindingMetadata();
+      proxyDeployer.initializeLocalBindingMetadata();
+   }
 
    public void start() throws Exception
    {

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -147,7 +147,7 @@
          
       innerStart();
 
-      timerService = TimerServiceFactory.getInstance().createTimerService(this.getObjectName(), this);
+      timerService = TimerServiceFactory.getInstance().createTimerService(this, this);
 
       startProxies();
       

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/BaseRemoteProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/BaseRemoteProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/BaseRemoteProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -26,6 +26,9 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.metadata.SimpleMetaData;
 
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
+
 /**
  * Comment
  *
@@ -34,13 +37,22 @@
  */
 public abstract class BaseRemoteProxy implements java.io.Serializable, InvocationHandler, RemoteProxy
 {
-   protected Object containerId;
+   protected String containerId;
+   protected String containerGuid;
    protected Interceptor[] interceptors;
    protected SimpleMetaData metadata;
 
-   protected BaseRemoteProxy(Object containerId, Interceptor[] interceptors)
+   protected BaseRemoteProxy(Container container, Interceptor[] interceptors)
    {
+      this.containerId = container.getObjectName().getCanonicalName();
+      this.containerGuid = Ejb3Registry.guid(container);
+      this.interceptors = interceptors;
+   }
+   
+   protected BaseRemoteProxy(String containerId, String containerGuid, Interceptor[] interceptors)
+   {
       this.containerId = containerId;
+      this.containerGuid = containerGuid;
       this.interceptors = interceptors;
    }
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -57,21 +57,27 @@
 
    private Container findLocalContainer(Invocation invocation)
    {
-      Object oid = invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
+      String guid = (String)invocation.getMetaData(IS_LOCAL, GUID);
+      String partitionName = (String) invocation.getMetaData(PARTITION_NAME, PARTITION_NAME);
+      
       Container container = null;
       try
       {
-         container = Ejb3Registry.getContainer(oid.toString());
+         container = Ejb3Registry.findContainer(guid);
+         if (container == null)
+         {
+            String oid = (String)invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
+            container = Ejb3Registry.getClusterContainer(Ejb3Registry.clusterUid(oid, partitionName));
+         }
       }
       catch (IllegalStateException ignored)
       {
          if (log.isTraceEnabled())
-            log.trace("Cannot find local container for " + oid);
+            log.trace("Cannot find local container for " + guid);
       }
       
       if (container != null)
       {
-         String partitionName = (String) invocation.getMetaData(PARTITION_NAME, PARTITION_NAME);
          if (partitionName != null)
          {
             if (!partitionName.equals(((EJBContainer) container).getPartitionName()))
@@ -79,7 +85,7 @@
                if (log.isTraceEnabled())
                {
                   log.trace("Partition (" + ((EJBContainer) container).getPartitionName() + 
-                            ") for local container " + oid + " does not match invocation (" +
+                            ") for local container " + guid + " does not match invocation (" +
                             partitionName + ")");
                }
                container = null;
@@ -87,7 +93,7 @@
             else if (log.isTraceEnabled())
             {
                log.trace("Partition (" + ((EJBContainer) container).getPartitionName() + 
-                     ") for local container " + oid + " matches invocation (" +
+                     ") for local container " + guid + " matches invocation (" +
                      partitionName + ")");
             }
          }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -48,6 +48,8 @@
    private static final long serialVersionUID = 337700910587744646L;
 
    private static final Logger log = Logger.getLogger(IsLocalInterceptor.class);
+   
+   public static final String GUID = "GUID";
 
    public static final String IS_LOCAL = "IS_LOCAL";
    public static final String IS_LOCAL_EXCEPTION = "IS_LOCAL_EXCEPTION";
@@ -64,8 +66,8 @@
    {
       if (isLocal())
       {
-         Object oid = invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
-         Container container = Ejb3Registry.getContainer(oid.toString());
+         String guid = (String)invocation.getMetaData(IS_LOCAL, GUID);
+         Container container = Ejb3Registry.getContainer(guid);
          
          return invokeLocal(invocation, container);
       }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -147,7 +147,7 @@
          initBeanContext();
 
          // make sure the timer service is there before injection takes place
-         timerService = TimerServiceFactory.getInstance().createTimerService(this.getObjectName(), this);
+         timerService = TimerServiceFactory.getInstance().createTimerService(this, this);
 
          injectDependencies(beanContext);
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -31,9 +31,11 @@
 import org.jboss.aspects.asynch.AsynchMixin;
 import org.jboss.aspects.asynch.AsynchProvider;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.Container;
 import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.remoting.InvokerLocator;
 
 /**
@@ -47,15 +49,15 @@
    protected InvokerLocator uri;
    AsynchProvider provider;
 
-   public ServiceRemoteProxy(Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public ServiceRemoteProxy(Container container, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.uri = uri;
    }
 
-   public ServiceRemoteProxy(AsynchProvider provider, Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public ServiceRemoteProxy(AsynchProvider provider, String containerId, String containerGuid, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(containerId, containerGuid, interceptors);
       this.uri = uri;
       this.provider = provider;
    }
@@ -86,7 +88,8 @@
       sri.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, containerId, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, uri, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
-
+      sri.getMetaData().addMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.GUID, containerGuid, PayloadKey.AS_IS);
+      
       if (provider != null)
       {
          sri.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
@@ -102,7 +105,7 @@
          Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
          AsynchMixin mixin = new AsynchMixin();
          Interceptor[] newInterceptors = ProxyUtils.addAsynchProxyInterceptor(mixin, interceptors);
-         ServiceRemoteProxy handler = new ServiceRemoteProxy(mixin, containerId, newInterceptors, uri);
+         ServiceRemoteProxy handler = new ServiceRemoteProxy(mixin, containerId, containerGuid, newInterceptors, uri);
          return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
       }
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceRemoteProxyFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -78,7 +78,7 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         Object[] args = {new ServiceRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator)};
+         Object[] args = {new ServiceRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator)};
          return proxyConstructor.newInstance(args);
       }
       catch (InstantiationException e)

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -27,6 +27,8 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.proxy.ejb.handle.StatefulHandleImpl;
 
+import org.jboss.ejb3.Container;
+
 /**
  * Comment
  *
@@ -41,11 +43,16 @@
    protected HomeHandle homeHandle;
    protected EJBMetaData ejbMetaData;
    
-   public BaseSessionRemoteProxy(Object containerId, Interceptor[] interceptors)
+   public BaseSessionRemoteProxy(Container container, Interceptor[] interceptors)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
    }
    
+   public BaseSessionRemoteProxy(String containerId, String containerGuid, Interceptor[] interceptors)
+   {
+      super(containerId, containerGuid, interceptors);
+   }
+   
    protected BaseSessionRemoteProxy()
    {
    }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -30,6 +30,8 @@
 import javax.persistence.EntityManager;
 import org.jboss.aop.metadata.SimpleMetaData;
 
+import org.jboss.ejb3.Ejb3Registry;
+
 /**
  * Overrides superclass to not use MarshalledValue in externalization,
  * as a nested context is meant to be serialized as part of its parent
@@ -47,8 +49,10 @@
 
    public void writeExternal(ObjectOutput out) throws IOException
    {
-      out.writeUTF(getContainer().getObjectName().getCanonicalName());
+      out.writeUTF(Ejb3Registry.clusterUid(getContainer()));
+      out.writeUTF(Ejb3Registry.guid(getContainer()));
       out.writeObject(id);
+      out.writeBoolean(isClustered);
       out.writeObject(metadata);
       out.writeObject(bean);
       out.writeObject(persistenceContexts);
@@ -62,8 +66,10 @@
 
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    {
-      containerName = in.readUTF();
+      containerClusterUid = in.readUTF();
+      containerGuid = in.readUTF();
       id = in.readObject();
+      isClustered = in.readBoolean();
       metadata = (SimpleMetaData) in.readObject();
       bean = in.readObject();
       persistenceContexts = (HashMap<String, EntityManager>)  in.readObject();

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -87,9 +87,11 @@
    protected HashMap<String, EntityManager> persistenceContexts;
 
    protected boolean removed;
-
-   protected String containerName;
    
+   protected String containerClusterUid;
+   protected String containerGuid;
+   protected boolean isClustered = false;
+   
    protected boolean replicationIsPassivation = true;
    
    protected transient boolean passivated = false;
@@ -308,8 +310,10 @@
          containedIn = propagatedContainedIn.get();
          NestedStatefulBeanContext nested = new NestedStatefulBeanContext();
          nested.id = id;
+         nested.isClustered = isClustered;
          nested.container = getContainer();
-         nested.containerName = containerName;
+         nested.containerClusterUid = containerClusterUid;
+         nested.containerGuid = containerGuid;
          nested.bean = bean;
          nested.replicationIsPassivation = replicationIsPassivation;
          containedIn.addContains(nested);
@@ -720,15 +724,21 @@
    public void setContainer(Container container)
    {
       super.setContainer(container);
-      containerName = container.getObjectName().getCanonicalName();
+      containerClusterUid = Ejb3Registry.clusterUid(container);
+      containerGuid = Ejb3Registry.guid(container);
+      isClustered = ((StatefulContainer)container).isClustered();
    }
 
    public Container getContainer()
    {
       if (container == null)
       {
-         container = Ejb3Registry.getContainer(containerName);
+         container = Ejb3Registry.findContainer(containerGuid);
+          
+         if (isClustered && container == null)
+            container = Ejb3Registry.getClusterContainer(containerClusterUid);
       }
+      
       return container;
    }
 
@@ -816,11 +826,14 @@
 
    public void writeExternal(ObjectOutput out) throws IOException
    {
-      out.writeUTF(containerName);
+      out.writeUTF(containerClusterUid);
+      out.writeUTF(containerGuid);
       out.writeObject(id);
       out.writeObject(metadata);
       out.writeLong(lastUsed);
+      out.writeBoolean(isClustered);
       
+      
       if (beanMO == null)
       {
          Object[] beanAndInterceptors = new Object[4];
@@ -859,10 +872,12 @@
    public void readExternal(ObjectInput in) throws IOException,
            ClassNotFoundException
    {
-      containerName = in.readUTF();
+      containerClusterUid = in.readUTF();
+      containerGuid = in.readUTF();
       id = in.readObject();
       metadata = (SimpleMetaData) in.readObject();
       lastUsed = in.readLong();
+      isClustered = in.readBoolean();
       
       beanMO = (MarshalledObject) in.readObject();
       removed = in.readBoolean();

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -40,9 +40,9 @@
    
    private transient StatefulBeanContext beanContext;
    private Object oid;
-   private String containerId;
-   
-   
+   private String containerGuid;
+   private String containerClusterUid;
+   private boolean isClustered = false;
 
    public StatefulBeanContextReference()
    {
@@ -52,26 +52,36 @@
    {
       this.beanContext = beanContext;
       oid = beanContext.getId();
-      containerId = beanContext.getContainer().getObjectName().getCanonicalName();
+      
+      StatefulContainer statefulContainer = (StatefulContainer)beanContext.getContainer();
+      containerGuid = Ejb3Registry.guid(statefulContainer);
+      containerClusterUid = Ejb3Registry.clusterUid(statefulContainer);
+      isClustered = statefulContainer.isClustered();
    }
 
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
    {
-      containerId = in.readUTF();
+      containerGuid = in.readUTF();
+      containerClusterUid = in.readUTF();
       oid = in.readObject();
+      isClustered = in.readBoolean();
    }
 
    public void writeExternal(ObjectOutput out) throws IOException
    {
-      out.writeUTF(containerId);
+      out.writeUTF(containerGuid);
+      out.writeUTF(containerClusterUid);
       out.writeObject(oid);
+      out.writeBoolean(isClustered);
    }
 
    public StatefulBeanContext getBeanContext()
    {
       if (beanContext == null)
       {
-         StatefulContainer container = (StatefulContainer)Ejb3Registry.getContainer(containerId);
+         StatefulContainer container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
+         if (isClustered && container == null)
+            container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
          // We are willing to accept a context that has been marked as removed
          // as it can still hold nested children
          beanContext = container.getCache().get(oid, false);

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -148,8 +148,8 @@
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
          String partitionName = ((StatefulContainer) container).getPartitionName();
-         Object[] args = {new StatefulClusteredProxy(containerId, stack.createInterceptors((Advisor) container, null), 
-                                                     wrapper, lbPolicy, partitionName)};
+         Object[] args = {new StatefulClusteredProxy(container, stack.createInterceptors((Advisor) container, null), 
+               wrapper, lbPolicy, partitionName)};
          
          return proxyConstructor.newInstance(args);
       }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusteredProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusteredProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusteredProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -32,10 +32,13 @@
 import org.jboss.aspects.remoting.ClusterConstants;
 import org.jboss.aspects.remoting.FamilyWrapper;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
 import org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
 import org.jboss.util.id.GUID;
 
@@ -57,18 +60,21 @@
    protected String partitionName;
 
 
-   public StatefulClusteredProxy(Object containerId, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lb, String partitionName)
+   public StatefulClusteredProxy(Container container, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lb, String partitionName)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.family = family;
       this.lbPolicy = lb;
       this.partitionName = partitionName;
    }
 
-   public StatefulClusteredProxy(AsynchProvider provider, Object containerId, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lb, String partitionName)
+   public StatefulClusteredProxy(AsynchProvider provider, String containerId, String containerGuid, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lb, String partitionName)
    {
-      this(containerId, interceptors, family, lb, partitionName);
+      super(containerId, containerGuid, interceptors);
       this.provider = provider;
+      this.family = family;
+      this.lbPolicy = lb;
+      this.partitionName = partitionName;
    }
 
    protected StatefulClusteredProxy()
@@ -98,7 +104,8 @@
       sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.LOADBALANCE_POLICY, lbPolicy, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(ClusteredIsLocalInterceptor.PARTITION_NAME, ClusteredIsLocalInterceptor.PARTITION_NAME, partitionName, PayloadKey.TRANSIENT);
-
+      sri.getMetaData().addMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.GUID, containerGuid, PayloadKey.AS_IS);
+      
       if (provider != null)
       {
          sri.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
@@ -130,7 +137,7 @@
          Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
          AsynchMixin mixin = new AsynchMixin();
          Interceptor[] newInterceptors = ProxyUtils.addAsynchProxyInterceptor(mixin, interceptors);
-         StatefulClusteredProxy handler = new StatefulClusteredProxy(mixin, containerId, newInterceptors, family, lbPolicy, partitionName);
+         StatefulClusteredProxy handler = new StatefulClusteredProxy(mixin, containerId, containerGuid, newInterceptors, family, lbPolicy, partitionName);
          return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
       }
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -656,6 +656,11 @@
       else
          return factory.createProxy();
    }
+   
+   public boolean isClustered()
+   {
+      return hasAnnotation(getBeanClass(), org.jboss.annotation.ejb.Clustered.class.getName());
+   }
 
    protected InvocationResponse invokeHomeMethod(MethodInfo info,
                                                  StatefulRemoteInvocation statefulInvocation) throws Throwable

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulHomeRemoteProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -29,7 +29,9 @@
 import org.jboss.aop.util.MethodHashing;
 import org.jboss.aop.util.PayloadKey;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.Container;
 import org.jboss.ejb3.ProxyUtils;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.logging.Logger;
 import org.jboss.remoting.InvokerLocator;
 
@@ -49,15 +51,15 @@
    private HomeHandle homeHandle;
    private EJBMetaData ejbMetaData;
 
-   public StatefulHomeRemoteProxy(Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public StatefulHomeRemoteProxy(Container container, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.uri = uri;
    }
 
-   public StatefulHomeRemoteProxy(Object containerId, Interceptor[] interceptors, InvokerLocator uri, Object id)
+   public StatefulHomeRemoteProxy(Container container, Interceptor[] interceptors, InvokerLocator uri, Object id)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.uri = uri;
       this.id = id;
    }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -33,8 +33,11 @@
 import org.jboss.aspects.asynch.AsynchMixin;
 import org.jboss.aspects.asynch.AsynchProvider;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.logging.Logger;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.util.id.GUID;
@@ -58,22 +61,22 @@
    private HomeHandle homeHandle;
    private EJBMetaData ejbMetaData;
 
-   public StatefulRemoteProxy(Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public StatefulRemoteProxy(Container container, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.uri = uri;
    }
 
-   public StatefulRemoteProxy(Object containerId, Interceptor[] interceptors, InvokerLocator uri, Object id)
+   public StatefulRemoteProxy(Container container, Interceptor[] interceptors, InvokerLocator uri, Object id)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.uri = uri;
       this.id = id;
    }
 
-   public StatefulRemoteProxy(AsynchProvider provider, Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public StatefulRemoteProxy(AsynchProvider provider, String containerId, String containerGuid, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(containerId, containerGuid, interceptors);
       this.uri = uri;
       this.provider = provider;
    }
@@ -125,7 +128,8 @@
       sri.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, containerId, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, uri, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
-
+      sri.getMetaData().addMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.GUID, containerGuid, PayloadKey.AS_IS);
+      
       if (provider != null)
       {
          sri.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
@@ -157,7 +161,7 @@
          Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
          AsynchMixin mixin = new AsynchMixin();
          Interceptor[] newInterceptors = ProxyUtils.addAsynchProxyInterceptor(mixin, interceptors);
-         StatefulRemoteProxy handler = new StatefulRemoteProxy(mixin, containerId, newInterceptors, uri);
+         StatefulRemoteProxy handler = new StatefulRemoteProxy(mixin, containerId, containerGuid, newInterceptors, uri);
          return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
       }
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -166,7 +166,7 @@
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
          if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
-         StatefulHomeRemoteProxy proxy = new StatefulHomeRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator);
+         StatefulHomeRemoteProxy proxy = new StatefulHomeRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator);
 
 
          setEjb21Objects(proxy);
@@ -190,7 +190,7 @@
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
          if (stack == null) throw new RuntimeException("unable to find interceptor stack: " + stackName);
-         StatefulRemoteProxy proxy = new StatefulRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator);
+         StatefulRemoteProxy proxy = new StatefulRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator);
 
 
          setEjb21Objects(proxy);
@@ -236,7 +236,7 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         StatefulRemoteProxy proxy = new StatefulRemoteProxy(containerId, stack.createInterceptors((Advisor) container, null), locator, id);
+         StatefulRemoteProxy proxy = new StatefulRemoteProxy(container, stack.createInterceptors((Advisor) container, null), locator, id);
          setEjb21Objects(proxy);
          Object[] args = {proxy};
          return proxyConstructor.newInstance(args);

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -136,8 +136,8 @@
          */
          String partitionName = ((StatelessContainer) container).getPartitionName();
          
-         proxy = constructProxy(new StatelessClusteredProxy(containerId, stack.createInterceptors((Advisor) container, null), 
-                                                            wrapper, lbPolicy, partitionName));
+         proxy = constructProxy(new StatelessClusteredProxy(container, stack.createInterceptors((Advisor) container, null), 
+               wrapper, lbPolicy, partitionName));
          return proxy;
       }
       /*

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusteredProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusteredProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessClusteredProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -33,11 +33,14 @@
 import org.jboss.aspects.remoting.ClusterConstants;
 import org.jboss.aspects.remoting.FamilyWrapper;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.JBossProxy;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
 import org.jboss.ejb3.remoting.BaseRemoteProxy;
 import org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.ha.framework.interfaces.LoadBalancePolicy;
 
 /**
@@ -56,18 +59,21 @@
    AsynchProvider provider;
    protected String partitionName;
 
-   public StatelessClusteredProxy(Object containerId, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lbPolicy, String partitionName)
+   public StatelessClusteredProxy(Container container, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lbPolicy, String partitionName)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.family = family;
       this.lbPolicy = lbPolicy;
       this.partitionName = partitionName;
    }
 
-   public StatelessClusteredProxy(AsynchProvider provider, Object containerId, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lbPolicy, String partitionName)
+   public StatelessClusteredProxy(AsynchProvider provider, String containerId, String containerGuid, Interceptor[] interceptors, FamilyWrapper family, LoadBalancePolicy lbPolicy, String partitionName)
    {
-      this(containerId, interceptors, family, lbPolicy, partitionName);
+      super(containerId, containerGuid, interceptors);
       this.provider = provider;
+      this.family = family;
+      this.lbPolicy = lbPolicy;
+      this.partitionName = partitionName;
    }
 
    public StatelessClusteredProxy()
@@ -97,7 +103,8 @@
       sri.getMetaData().addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.LOADBALANCE_POLICY, lbPolicy, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(ClusteredIsLocalInterceptor.PARTITION_NAME, ClusteredIsLocalInterceptor.PARTITION_NAME, partitionName, PayloadKey.TRANSIENT);
-
+      sri.getMetaData().addMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.GUID, containerGuid, PayloadKey.AS_IS);
+      
       if (provider != null)
       {
          sri.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
@@ -113,7 +120,7 @@
          Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
          AsynchMixin mixin = new AsynchMixin();
          Interceptor[] newInterceptors = ProxyUtils.addAsynchProxyInterceptor(mixin, interceptors);
-         StatelessClusteredProxy handler = new StatelessClusteredProxy(mixin, containerId, newInterceptors, family, lbPolicy, partitionName);
+         StatelessClusteredProxy handler = new StatelessClusteredProxy(mixin, containerId, containerGuid, newInterceptors, family, lbPolicy, partitionName);
          return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
       }
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -93,7 +93,7 @@
       {
          super.start();
          
-         timerService = TimerServiceFactory.getInstance().createTimerService(this.getObjectName(), this);
+         timerService = TimerServiceFactory.getInstance().createTimerService(this, this);
          
          TimerServiceFactory.getInstance().restoreTimerService(timerService);
       }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxy.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxy.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxy.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -31,8 +31,11 @@
 import org.jboss.aspects.asynch.AsynchMixin;
 import org.jboss.aspects.asynch.AsynchProvider;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.ProxyUtils;
 import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
+import org.jboss.ejb3.remoting.IsLocalInterceptor;
 import org.jboss.logging.Logger;
 import org.jboss.remoting.InvokerLocator;
 
@@ -50,15 +53,15 @@
    protected InvokerLocator uri;
    AsynchProvider provider;
 
-   public StatelessRemoteProxy(Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public StatelessRemoteProxy(Container container, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(container, interceptors);
       this.uri = uri;
    }
 
-   public StatelessRemoteProxy(AsynchProvider provider, Object containerId, Interceptor[] interceptors, InvokerLocator uri)
+   public StatelessRemoteProxy(AsynchProvider provider, String containerId, String containerGuid, Interceptor[] interceptors, InvokerLocator uri)
    {
-      super(containerId, interceptors);
+      super(containerId, containerGuid, interceptors);
       this.uri = uri;
       this.provider = provider;
    }
@@ -95,7 +98,8 @@
       sri.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, containerId, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR, uri, PayloadKey.AS_IS);
       sri.getMetaData().addMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.SUBSYSTEM, "AOP", PayloadKey.AS_IS);
-
+      sri.getMetaData().addMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.GUID, containerGuid, PayloadKey.AS_IS);
+      
       if (provider != null)
       {
          sri.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
@@ -111,7 +115,7 @@
          Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
          AsynchMixin mixin = new AsynchMixin();
          Interceptor[] newInterceptors = ProxyUtils.addAsynchProxyInterceptor(mixin, interceptors);
-         StatelessRemoteProxy handler = new StatelessRemoteProxy(mixin, containerId, newInterceptors, uri);
+         StatelessRemoteProxy handler = new StatelessRemoteProxy(mixin, containerId, containerGuid, newInterceptors, uri);
          return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
       }
 

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -166,7 +166,7 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         StatelessRemoteProxy proxy = new StatelessRemoteProxy(containerId,
+         StatelessRemoteProxy proxy = new StatelessRemoteProxy(container,
                stack.createInterceptors((Advisor) container, null), locator);
          setEjb21Objects(proxy);
          Class[] interfaces = { homeInterface };
@@ -192,7 +192,7 @@
             stackName = binding.interceptorStack();
          }
          AdviceStack stack = AspectManager.instance().getAdviceStack(stackName);
-         StatelessRemoteProxy proxy = new StatelessRemoteProxy(containerId,
+         StatelessRemoteProxy proxy = new StatelessRemoteProxy(container,
                stack.createInterceptors((Advisor) container, null), locator);
          setEjb21Objects(proxy);
          /*

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/TimerServiceFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/TimerServiceFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/TimerServiceFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -25,6 +25,8 @@
 import javax.ejb.TimerService;
 import javax.management.ObjectName;
 
+import org.jboss.ejb3.Container;
+
 /**
  * Comment
  *
@@ -64,7 +66,7 @@
       }
    }
    
-   public abstract TimerService createTimerService(ObjectName objectName, TimedObjectInvoker invoker);
+   public abstract TimerService createTimerService(Container container, TimedObjectInvoker invoker);
    
    public static TimerServiceFactory getInstance()
    {

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/JBossTimerServiceFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/JBossTimerServiceFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/JBossTimerServiceFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -25,6 +25,8 @@
 import javax.management.ObjectName;
 
 import org.jboss.ejb.txtimer.EJBTimerService;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
@@ -46,14 +48,14 @@
     * @see org.jboss.ejb3.timerservice.TimerServiceFactory#createTimerService(javax.management.ObjectName, org.jboss.ejb3.timerservice.TimedObjectInvoker)
     */
    @Override
-   public TimerService createTimerService(ObjectName containerId, TimedObjectInvoker invoker)
+   public TimerService createTimerService(Container container, TimedObjectInvoker invoker)
    {
       TimerService timerService = null;
       try
       {
          EJBTimerService service = getEJBTimerService();
-         TimerService delegate = service.createTimerService(containerId, null, invoker);
-         timerService = new TimerServiceFacade(containerId, delegate);
+         TimerService delegate = service.createTimerService(container.getObjectName(), null, invoker);
+         timerService = new TimerServiceFacade(container, delegate);
       }
       catch (Exception e)
       {

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/TimerServiceFacade.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/TimerServiceFacade.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/jboss/TimerServiceFacade.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -30,8 +30,8 @@
 import javax.ejb.TimerService;
 import javax.management.ObjectName;
 
+import org.jboss.ejb3.Container;
 import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Registry;
 
 /**
  * Comment
@@ -43,11 +43,11 @@
 {
    private TimerService delegate;
    
-   private ObjectName containerId;
+   private Container container;
    
-   protected TimerServiceFacade(ObjectName containerId, TimerService delegate)
+   protected TimerServiceFacade(Container container, TimerService delegate)
    {
-      this.containerId = containerId;
+      this.container = container;
       this.delegate = delegate;
    }
 
@@ -73,12 +73,12 @@
 
    protected EJBContainer getContainer()
    {
-      return (EJBContainer) Ejb3Registry.getContainer(getContainerId().getCanonicalName());
+      return (EJBContainer) container;
    }
    
    protected ObjectName getContainerId()
    {
-      return containerId;
+      return container.getObjectName();
    }
    
    public Collection getTimers() throws IllegalStateException, EJBException

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/PersistentTimer.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/PersistentTimer.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/PersistentTimer.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -53,25 +53,25 @@
    //private String jobGroup;
    private String triggerName;
    private String triggerGroup;
-   private ObjectName objectName;
+   private String containerGuid;
    
    private Serializable info;
    
-   protected PersistentTimer(Trigger trigger, ObjectName objectName, Serializable info)
+   protected PersistentTimer(Trigger trigger, String containerGuid, Serializable info)
    {
       assert trigger != null;
-      assert objectName != null;
+      assert containerGuid != null;
       
       this.triggerName = trigger.getName();
       this.triggerGroup = trigger.getGroup();
-      this.objectName = objectName;
       this.info = info;
+      this.containerGuid = containerGuid;
    }
    
    protected TimedObjectInvoker getTimedObjectInvoker()
    {
       // TODO: a hack to get back the container. This needs thinking.
-      TimedObjectInvoker invoker = (TimedObjectInvoker) Ejb3Registry.getContainer(objectName.getCanonicalName());
+      TimedObjectInvoker invoker = (TimedObjectInvoker) Ejb3Registry.getContainer(containerGuid);
       assert invoker != null;
       return invoker;
    }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/QuartzTimerServiceFactory.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -27,7 +27,6 @@
 import java.util.Properties;
 
 import javax.ejb.TimerService;
-import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
@@ -37,7 +36,7 @@
 import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
-import org.jboss.ejb3.EJB3Util;
+import org.jboss.ejb3.Container;
 import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
@@ -154,12 +153,12 @@
     * @param invoker    the invoker to call on timeouts
     * @return           an EJB TimerService
     */
-   public TimerService createTimerService(ObjectName objectName, TimedObjectInvoker invoker)
+   public TimerService createTimerService(Container container, TimedObjectInvoker invoker)
    {
       Scheduler scheduler = getScheduler();
       if (scheduler == null) return null;
       
-      return new TimerServiceImpl(scheduler, objectName, invoker);
+      return new TimerServiceImpl(scheduler, container, invoker);
    }
    
    private boolean execute(Connection conn, String stmtName) throws SQLException

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/TimerServiceImpl.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/TimerServiceImpl.java	2007-08-10 16:59:23 UTC (rev 64542)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/timerservice/quartz/TimerServiceImpl.java	2007-08-10 17:03:04 UTC (rev 64543)
@@ -30,6 +30,8 @@
 import javax.ejb.TimerService;
 import javax.management.ObjectName;
 
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.logging.Logger;
 import org.quartz.JobDetail;
@@ -51,18 +53,20 @@
    private static final Logger log = Logger.getLogger(TimerServiceImpl.class);
    
    private Scheduler scheduler;
+   private Container container;
    private ObjectName objectName;
    private String groupName;
    private long jobNum = 0;
    private long triggerNum = 0;
    
-   protected TimerServiceImpl(Scheduler scheduler, ObjectName objectName, TimedObjectInvoker invoker) {
+   protected TimerServiceImpl(Scheduler scheduler, Container container, TimedObjectInvoker invoker) {
       assert scheduler != null;
-      assert objectName != null;
+      assert container != null;
       assert invoker != null;
       
       this.scheduler = scheduler;
-      this.objectName = objectName;
+      this.container = container;
+      this.objectName = container.getObjectName();
       this.groupName = objectName.getCanonicalName();
    }
    
@@ -76,7 +80,7 @@
          
          Timer timer = new TimerImpl(scheduler, trigger, info);
          
-         PersistentTimer persistentTimer = new PersistentTimer(trigger, objectName, info);
+         PersistentTimer persistentTimer = new PersistentTimer(trigger, Ejb3Registry.guid(container), info);
          
          JobDetail jobDetail = new JobDetail(name, groupName, jobClass);
          jobDetail.getJobDataMap().put("timer", persistentTimer);




More information about the jboss-cvs-commits mailing list