[jboss-cvs] JBossAS SVN: r64387 - in branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3: remoting and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 31 15:54:58 EDT 2007
Author: bdecoste
Date: 2007-07-31 15:54:57 -0400 (Tue, 31 Jul 2007)
New Revision: 64387
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Container.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
Log:
[EJBTHREE-1019] added partition name to clusterId for Ejb3Registry lookup
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Container.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Container.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -87,4 +87,6 @@
DependencyPolicy getDependencyPolicy();
InvocationStatistics getInvokeStats();
+
+ boolean isClustered();
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -495,6 +495,8 @@
*/
public String getPartitionName()
{
+ if (partitionName == null)
+ this.findPartitionName();
return partitionName;
}
@@ -718,6 +720,7 @@
protected void findPartitionName()
{
Clustered clustered = (Clustered) resolveAnnotation(Clustered.class);
+
if (clustered == null)
{
partitionName = null;
@@ -1016,4 +1019,9 @@
}
return info;
}
+
+ public boolean isClustered()
+ {
+ return false;
+ }
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -27,6 +27,8 @@
import java.util.HashMap;
import java.util.Map;
+import org.jboss.annotation.ejb.Clustered;
+
import org.jboss.logging.Logger;
/**
@@ -76,11 +78,19 @@
return container.getObjectName().getCanonicalName() + ",VMID=" + VMID;
}
- public static final String oid(Container container)
- {
+ public static final String clusterUid(Container container)
+ {
+ if (container.isClustered())
+ return container.getObjectName().getCanonicalName() + ",Partition=" + ((EJBContainer)container).getPartitionName();
+
return container.getObjectName().getCanonicalName();
}
+ public static final String clusterUid(String oid, String partitionName)
+ {
+ return oid + ",Partition=" + partitionName;
+ }
+
/**
* Registers a container.
*
@@ -93,7 +103,9 @@
if(hasContainer(guid))
throw new IllegalStateException("Container " + guid + " + is already registered");
containers.put(guid, container);
- clusterContainers.put(oid(container), container);
+
+ if (container.isClustered())
+ clusterContainers.put(clusterUid(container), container);
}
/**
@@ -108,7 +120,9 @@
if(!hasContainer(guid))
throw new IllegalStateException("Container " + guid + " + is not registered");
containers.remove(guid);
- clusterContainers.remove(oid(container));
+
+ if (container.isClustered())
+ clusterContainers.remove(clusterUid(container));
}
/**
@@ -123,7 +137,7 @@
{
if(!hasContainer(guid))
throw new IllegalStateException("Container " + guid + " is not registered");
-
+
return containers.get(guid);
}
@@ -135,12 +149,12 @@
* @return the container
* @throws IllegalStateException if the container is not registered
*/
- public static Container getClusterContainer(String oid)
+ public static Container getClusterContainer(String clusterUid)
{
- Container container = clusterContainers.get(oid);
+ Container container = clusterContainers.get(clusterUid);
if(container == null)
- throw new IllegalStateException("Container " + oid + " is not registered");
-
+ throw new IllegalStateException("Container " + clusterUid + " is not registered " + clusterContainers);
+
return container;
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/LocalProxy.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/LocalProxy.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -41,7 +41,7 @@
private static Logger log = Logger.getLogger(LocalProxy.class);
private transient Container container = null;
- protected String containerOid;
+ protected String containerClusterUid;
protected String containerGuid;
protected String proxyName;
@@ -53,7 +53,7 @@
{
this.container = container;
this.containerGuid = Ejb3Registry.guid(container);
- this.containerOid = Ejb3Registry.oid(container);
+ this.containerClusterUid = Ejb3Registry.clusterUid(container);
proxyName = container.getEjbName();
}
@@ -69,14 +69,14 @@
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
this.containerGuid = in.readUTF();
- this.containerOid = in.readUTF();
+ this.containerClusterUid = in.readUTF();
this.proxyName = in.readUTF();
}
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeUTF(containerGuid);
- out.writeUTF(containerOid);
+ out.writeUTF(containerClusterUid);
out.writeUTF(proxyName);
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -58,6 +58,8 @@
private Container findLocalContainer(Invocation invocation)
{
String guid = (String)invocation.getMetaData(IS_LOCAL, GUID);
+ String partitionName = (String) invocation.getMetaData(PARTITION_NAME, PARTITION_NAME);
+
Container container = null;
try
{
@@ -65,7 +67,7 @@
if (container == null)
{
String oid = (String)invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
- container = Ejb3Registry.getClusterContainer(oid);
+ container = Ejb3Registry.getClusterContainer(Ejb3Registry.clusterUid(oid, partitionName));
}
}
catch (IllegalStateException ignored)
@@ -76,7 +78,6 @@
if (container != null)
{
- String partitionName = (String) invocation.getMetaData(PARTITION_NAME, PARTITION_NAME);
if (partitionName != null)
{
if (!partitionName.equals(((EJBContainer) container).getPartitionName()))
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -49,9 +49,10 @@
public void writeExternal(ObjectOutput out) throws IOException
{
- out.writeUTF(Ejb3Registry.oid(getContainer()));
+ 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);
@@ -65,9 +66,10 @@
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
- containerOid = 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/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -30,6 +30,7 @@
import org.jboss.ejb3.cache.StatefulCache;
import org.jboss.ejb3.interceptor.InterceptorInfo;
import org.jboss.ejb3.tx.TxUtil;
+import org.jboss.logging.Logger;
import org.jboss.serial.io.MarshalledObject;
import org.jboss.tm.TxUtils;
@@ -61,6 +62,8 @@
{
/** The serialVersionUID */
private static final long serialVersionUID = -102470788178912606L;
+
+ protected static Logger log = Logger.getLogger(StatefulBeanContext.class);
protected Object id;
@@ -88,8 +91,9 @@
protected boolean removed;
- protected String containerOid;
+ protected String containerClusterUid;
protected String containerGuid;
+ protected boolean isClustered = false;
protected boolean replicationIsPassivation = true;
@@ -309,8 +313,9 @@
containedIn = propagatedContainedIn.get();
NestedStatefulBeanContext nested = new NestedStatefulBeanContext();
nested.id = id;
+ nested.isClustered = isClustered;
nested.container = getContainer();
- nested.containerOid = containerOid;
+ nested.containerClusterUid = containerClusterUid;
nested.containerGuid = containerGuid;
nested.bean = bean;
nested.replicationIsPassivation = replicationIsPassivation;
@@ -722,8 +727,9 @@
public void setContainer(Container container)
{
super.setContainer(container);
- containerOid = Ejb3Registry.oid(container);
+ containerClusterUid = Ejb3Registry.clusterUid(container);
containerGuid = Ejb3Registry.guid(container);
+ isClustered = ((StatefulContainer)container).isClustered();
}
public Container getContainer()
@@ -731,10 +737,11 @@
if (container == null)
{
container = Ejb3Registry.findContainer(containerGuid);
-
- if (container == null)
- container = Ejb3Registry.getClusterContainer(containerOid);
+
+ if (isClustered && container == null)
+ container = Ejb3Registry.getClusterContainer(containerClusterUid);
}
+
return container;
}
@@ -822,11 +829,12 @@
public void writeExternal(ObjectOutput out) throws IOException
{
- out.writeUTF(containerOid);
+ out.writeUTF(containerClusterUid);
out.writeUTF(containerGuid);
out.writeObject(id);
out.writeObject(metadata);
out.writeLong(lastUsed);
+ out.writeBoolean(isClustered);
if (beanMO == null)
{
@@ -866,11 +874,12 @@
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
{
- containerOid = 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/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContextReference.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -41,7 +41,8 @@
private transient StatefulBeanContext beanContext;
private Object oid;
private String containerGuid;
- private String containerOid;
+ private String containerClusterUid;
+ private boolean isClustered = false;
public StatefulBeanContextReference()
{
@@ -51,22 +52,27 @@
{
this.beanContext = beanContext;
oid = beanContext.getId();
- containerGuid = Ejb3Registry.guid(beanContext.getContainer());
- containerOid = Ejb3Registry.oid(beanContext.getContainer());
+
+ StatefulContainer statefulContainer = (StatefulContainer)beanContext.getContainer();
+ containerGuid = Ejb3Registry.guid(statefulContainer);
+ containerClusterUid = Ejb3Registry.clusterUid(statefulContainer);
+ isClustered = statefulContainer.isClustered();
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
containerGuid = in.readUTF();
- containerOid = in.readUTF();
+ containerClusterUid = in.readUTF();
oid = in.readObject();
+ isClustered = in.readBoolean();
}
public void writeExternal(ObjectOutput out) throws IOException
{
out.writeUTF(containerGuid);
- out.writeUTF(containerOid);
+ out.writeUTF(containerClusterUid);
out.writeObject(oid);
+ out.writeBoolean(isClustered);
}
public StatefulBeanContext getBeanContext()
@@ -74,8 +80,8 @@
if (beanContext == null)
{
StatefulContainer container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
- if (container == null)
- container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerOid);
+ 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/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -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/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java 2007-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -27,10 +27,10 @@
import java.io.ObjectInput;
import java.io.IOException;
import java.io.ObjectOutput;
+import java.rmi.dgc.VMID;
import javax.ejb.EJBException;
-import org.jboss.aop.util.MethodHashing;
import org.jboss.aspects.asynch.AsynchMixin;
import org.jboss.aspects.asynch.AsynchProvider;
import org.jboss.aspects.asynch.FutureHolder;
@@ -38,7 +38,7 @@
import org.jboss.ejb3.Ejb3Registry;
import org.jboss.ejb3.LocalProxy;
import org.jboss.ejb3.ProxyUtils;
-import org.jboss.util.id.GUID;
+import org.jboss.logging.Logger;
/**
* Comment
@@ -50,15 +50,18 @@
{
private static final long serialVersionUID = 206913210970415540L;
+ private static final Logger log = Logger.getLogger(StatefulLocalProxy.class);
+
protected Object id;
AsynchProvider provider;
+ protected boolean isClustered = false;
-
-
- public StatefulLocalProxy(Container container, Object id)
+ public StatefulLocalProxy(Container container, Object id, VMID vmid)
{
super(container);
this.id = id;
+ this.containerGuid = this.containerClusterUid + ",VMID=" + vmid;
+ isClustered = ((StatefulContainer)container).isClustered();
}
public StatefulLocalProxy(AsynchProvider provider, Container container, Object id)
@@ -66,6 +69,7 @@
super(container);
this.provider = provider;
this.id = id;
+ isClustered = ((StatefulContainer)container).isClustered();
}
public StatefulLocalProxy()
@@ -77,6 +81,7 @@
{
super.readExternal(in);
id = in.readObject();
+ isClustered = in.readBoolean();
}
//@Override
@@ -84,6 +89,7 @@
{
super.writeExternal(out);
out.writeObject(id);
+ out.writeBoolean(isClustered);
}
public Object invoke(Object proxy, Method method, Object[] args)
@@ -102,9 +108,9 @@
}
Container container = Ejb3Registry.findContainer(containerGuid);
- if (container == null && Ejb3Registry.hasClusterContainer(containerOid))
- container = Ejb3Registry.getClusterContainer(containerOid);
-
+ if (isClustered && container == null && Ejb3Registry.hasClusterContainer(containerClusterUid))
+ container = Ejb3Registry.getClusterContainer(containerClusterUid);
+
if (container == null)
throw new EJBException("Invalid (i.e. remote) invocation of local interface (null container)");
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-07-31 18:11:09 UTC (rev 64386)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2007-07-31 19:54:57 UTC (rev 64387)
@@ -22,6 +22,8 @@
package org.jboss.ejb3.stateful;
import java.lang.reflect.InvocationTargetException;
+import java.rmi.dgc.VMID;
+
import javax.ejb.LocalHome;
import javax.naming.NamingException;
import org.jboss.annotation.ejb.LocalBinding;
@@ -41,6 +43,8 @@
public class StatefulLocalProxyFactory extends BaseStatefulProxyFactory
{
private static final Logger log = Logger.getLogger(StatefulLocalProxyFactory.class);
+
+ private VMID vmid = new VMID();
protected Class[] getInterfaces()
{
@@ -127,7 +131,7 @@
StatefulBeanContext ctx = sfsb.getCache().create();
ctx.setInUse(false);
Object id = ctx.getId();
- Object[] args = {new StatefulLocalProxy(container, id)};
+ Object[] args = {new StatefulLocalProxy(container, id, vmid)};
return proxyConstructor.newInstance(args);
}
catch (InstantiationException e)
@@ -153,7 +157,7 @@
try
{
StatefulContainer sfsb = (StatefulContainer) container;
- Object[] args = {new StatefulLocalProxy(container, id)};
+ Object[] args = {new StatefulLocalProxy(container, id, vmid)};
return proxyConstructor.newInstance(args);
}
catch (InstantiationException e)
@@ -179,7 +183,7 @@
{
StatefulContainer sfsb = (StatefulContainer) container;
Object id = sfsb.createSession(initTypes, initValues);
- Object[] args = {new StatefulLocalProxy(container, id)};
+ Object[] args = {new StatefulLocalProxy(container, id, vmid)};
return proxyConstructor.newInstance(args);
}
catch (InstantiationException e)
More information about the jboss-cvs-commits
mailing list