[jboss-cvs] JBossAS SVN: r59599 - in trunk/ejb3/src/main/org/jboss/ejb3: stateful and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 12 07:26:52 EST 2007
Author: wolfc
Date: 2007-01-12 07:26:46 -0500 (Fri, 12 Jan 2007)
New Revision: 59599
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java
Log:
EJBTHREE-833: StatefulLocalProxy made detachable
Modified: trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java 2007-01-12 12:13:33 UTC (rev 59598)
+++ trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java 2007-01-12 12:26:46 UTC (rev 59599)
@@ -28,6 +28,7 @@
import java.io.ObjectOutput;
import java.lang.reflect.InvocationHandler;
import org.jboss.ejb3.remoting.Proxy;
+import org.jboss.logging.Logger;
/**
* Comment
@@ -37,26 +38,41 @@
*/
public abstract class LocalProxy implements InvocationHandler, Externalizable, Proxy
{
- protected Container container;
+ private static Logger log = Logger.getLogger(LocalProxy.class);
+
+ // FIXME: should be private
+ protected transient Container container = null;
+ private String containerId;
- public LocalProxy()
+ protected LocalProxy()
{
}
- public LocalProxy(Container container)
+ protected LocalProxy(Container container)
{
this.container = container;
+ this.containerId = container.getObjectName().getCanonicalName();
}
+ protected Container getContainer()
+ {
+ if(container == null)
+ container = Ejb3Registry.getContainer(containerId);
+ if(container == null)
+ log.warn("Container " + containerId + " is not yet available");
+ return container;
+ }
+
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
- String containerId = in.readUTF();
+ this.containerId = in.readUTF();
+ // TODO: one container is private, this won't have to be done anymore
this.container = Ejb3Registry.getContainer(containerId);
}
public void writeExternal(ObjectOutput out) throws IOException
{
- out.writeUTF(container.getObjectName().getCanonicalName());
+ out.writeUTF(containerId);
}
public abstract String toString();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java 2007-01-12 12:13:33 UTC (rev 59598)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxy.java 2007-01-12 12:26:46 UTC (rev 59599)
@@ -88,7 +88,7 @@
}
//Make sure we get the cache id before getting the asynchronous interface
- StatefulContainer sfsb = (StatefulContainer) container;
+ StatefulContainer sfsb = (StatefulContainer) getContainer();
Object ret = ProxyUtils.handleCallLocally(proxy, this, method, args);
if (ret != null)
{
@@ -105,7 +105,7 @@
{
Class[] interfaces = ProxyUtils.addAsynchProviderInterface(infs);
AsynchMixin mixin = new AsynchMixin();
- StatefulLocalProxy handler = new StatefulLocalProxy(mixin, container, id);
+ StatefulLocalProxy handler = new StatefulLocalProxy(mixin, getContainer(), id);
return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler);
}
@@ -117,13 +117,13 @@
{
if (id != null)
{
- return container.getEjbName().toString() + ":" + id.toString();
+ return getContainer().getEjbName().toString() + ":" + id.toString();
}
else
{
//If the proxy has not been used yet, create a temporary id
GUID guid = new GUID();
- return container.getEjbName().toString() + ":" + guid.toString();
+ return getContainer().getEjbName().toString() + ":" + guid.toString();
}
}
More information about the jboss-cvs-commits
mailing list