[jboss-cvs] JBossAS SVN: r73395 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3: session and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 14 13:39:37 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-05-14 13:39:36 -0400 (Wed, 14 May 2008)
New Revision: 73395
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BaseContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
Log:
[EJBTHREE-1360] Restore StatefulBeanContext externaliztion
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BaseContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BaseContext.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BaseContext.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -67,6 +67,16 @@
this.bean = bean;
}
+ /**
+ * Only for externalization use by subclass StatefulBeanContext; do not use elsewhere.
+ *
+ * @deprecated
+ */
+ protected BaseContext()
+ {
+
+ }
+
public Object getId()
{
return null;
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionBeanContext.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -49,6 +49,16 @@
super(container, bean);
}
+ /**
+ * Only for externalization use by subclass StatefulBeanContext; do not use elsewhere.
+ *
+ * @deprecated
+ */
+ protected SessionBeanContext()
+ {
+
+ }
+
public abstract EJBContext getEJBContext();
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -41,5 +41,15 @@
{
super(container, bean);
}
+
+ /**
+ * Only for externalization use by subclass ProxiedStatefulBeanContext; do not use elsewhere.
+ *
+ * @deprecated
+ */
+ protected SessionSpecBeanContext()
+ {
+
+ }
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -32,7 +32,6 @@
import org.jboss.aop.metadata.SimpleMetaData;
import org.jboss.ejb3.Ejb3Registry;
-import org.jboss.ejb3.session.SessionSpecContainer;
/**
* Overrides superclass to not use MarshalledValue in externalization,
@@ -55,10 +54,17 @@
super(container, bean);
}
+ /**
+ * Only for externalization.
+ */
+ public NestedStatefulBeanContext()
+ {
+ }
+
public void writeExternal(ObjectOutput out) throws IOException
{
- out.writeUTF(Ejb3Registry.clusterUid(getContainer()));
- out.writeUTF(Ejb3Registry.guid(getContainer()));
+ out.writeUTF(containerClusterUid);
+ out.writeUTF(containerGuid);
out.writeObject(id);
out.writeBoolean(isClustered);
out.writeObject(metadata);
@@ -98,6 +104,10 @@
// If we've just been deserialized, we are passivated
passivated = true;
+
+ container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
+ if (isClustered && container == null)
+ container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
}
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/ProxiedStatefulBeanContext.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -58,14 +58,19 @@
private StatefulBeanContextReference parentRef;
public ProxiedStatefulBeanContext(StatefulBeanContext delegate)
- {
- super(delegate.getContainer(), delegate.getInstance());
-
+ {
this.delegate = delegate;
oid = delegate.getId();
- containerId = container.getObjectName().getCanonicalName();
+ containerId = delegate.getContainer().getObjectName().getCanonicalName();
parentRef = new StatefulBeanContextReference(delegate.getContainedIn());
}
+
+ /**
+ * Only for externalization.
+ */
+ public ProxiedStatefulBeanContext()
+ {
+ }
protected StatefulBeanContext getDelegate()
{
@@ -419,4 +424,24 @@
// ignore
}
+ @Override
+ public Object getInvokedMethodKey()
+ {
+ return getDelegate().getInvokedMethodKey();
+ }
+
+ @Override
+ public Object getInterceptor(Class<?> interceptorClass) throws IllegalArgumentException
+ {
+ return getDelegate().getInterceptor(interceptorClass);
+ }
+
+ @Override
+ public void initialiseInterceptorInstances()
+ {
+ getDelegate().initialiseInterceptorInstances();
+ }
+
+
+
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContext.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -21,7 +21,10 @@
*/
package org.jboss.ejb3.stateful;
+import java.io.Externalizable;
import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.ArrayList;
@@ -58,46 +61,46 @@
*
* @version $Revision$
*/
-public class StatefulBeanContext extends SessionSpecBeanContext<StatefulContainer> implements Identifiable, Serializable, org.jboss.ejb3.tx.container.StatefulBeanContext<Object>
+public class StatefulBeanContext extends SessionSpecBeanContext<StatefulContainer> implements Identifiable, Externalizable, org.jboss.ejb3.tx.container.StatefulBeanContext<Object>
{
/** The serialVersionUID */
private static final long serialVersionUID = -102470788178912606L;
- private static class Serialized implements Serializable
- {
- private static final long serialVersionUID = 1L;
-
- private String containerClusterUid;
- private String containerGuid;
- private boolean isClustered = false;
- private Object id;
- private SimpleMetaData metadata;
- private long lastUsed;
- private MarshalledObject beanMO;
- private boolean removed;
- private boolean replicationIsPassivation;
-
- private Object readResolve() throws ObjectStreamException
- {
- StatefulContainer container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
-
- if (isClustered && container == null)
- container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
-
- if(container == null)
- throw new IllegalStateException("Can't find container " + containerGuid);
-
- StatefulBeanContext context = new StatefulBeanContext(container, beanMO);
- context.id = this.id;
- context.metadata = this.metadata;
- context.lastUsed = this.lastUsed;
- context.removed = this.removed;
- context.replicationIsPassivation = this.replicationIsPassivation;
- // I'm deserializing, so I was passivated
- context.passivated = true;
- return context;
- }
- }
+// private static class Serialized implements Serializable
+// {
+// private static final long serialVersionUID = 1L;
+//
+// private String containerClusterUid;
+// private String containerGuid;
+// private boolean isClustered = false;
+// private Object id;
+// private SimpleMetaData metadata;
+// private long lastUsed;
+// private MarshalledObject beanMO;
+// private boolean removed;
+// private boolean replicationIsPassivation;
+//
+// private Object readResolve() throws ObjectStreamException
+// {
+// StatefulContainer container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
+//
+// if (isClustered && container == null)
+// container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
+//
+// if(container == null)
+// throw new IllegalStateException("Can't find container " + containerGuid);
+//
+// StatefulBeanContext context = new StatefulBeanContext(container, beanMO);
+// context.id = this.id;
+// context.metadata = this.metadata;
+// context.lastUsed = this.lastUsed;
+// context.removed = this.removed;
+// context.replicationIsPassivation = this.replicationIsPassivation;
+// // I'm deserializing, so I was passivated
+// context.passivated = true;
+// return context;
+// }
+// }
protected Object id;
@@ -166,6 +169,16 @@
this.isClustered = container.isClustered();
this.id = new GUID();
}
+
+ /**
+ * Only for use by externalization; do not use elsewhere.
+ *
+ * @deprecated
+ */
+ public StatefulBeanContext()
+ {
+
+ }
public List<StatefulBeanContext> getContains()
{
@@ -886,65 +899,10 @@
}
}
- private Object writeReplace() throws ObjectStreamException
- {
- Serialized state = new Serialized();
- if (this.beanMO == null)
- {
- Object[] beanAndInterceptors = new Object[4];
- beanAndInterceptors[0] = bean;
- beanAndInterceptors[1] = persistenceContexts;
- if (interceptorInstances != null && interceptorInstances.size() > 0)
- {
- ArrayList list = new ArrayList();
- list.addAll(interceptorInstances.values());
- beanAndInterceptors[2] = list;
- }
- beanAndInterceptors[3] = contains;
-
- // BES 2007/02/12 Previously we were trying to hold a ref to
- // beanMO after we created it, but that exposes the risk of
- // two different versions of the constituent state that
- // can fall out of sync. So now we just write a local variable.
-
- try
- {
- MarshalledObject mo = new MarshalledObject(beanAndInterceptors);
- state.beanMO = mo;
- }
- catch(IOException e)
- {
- throw new RuntimeException("Marshalling of bean " + bean + " failed", e);
- }
- }
- else
- {
- // We've been deserialized and are now being re-serialized, but
- // extractBeanAndInterceptors hasn't been called in between.
- // This can happen if a passivated session is involved in a
- // JBoss Cache state transfer to a newly deployed node.
- state.beanMO = this.beanMO;
- }
-
- state.containerClusterUid = this.containerClusterUid;
- state.containerGuid = this.containerGuid;
- state.isClustered = this.isClustered;
- state.id = this.id;
- state.lastUsed = this.lastUsed;
- state.metadata = this.metadata;
- state.removed = this.removed;
- state.replicationIsPassivation = this.replicationIsPassivation;
- return state;
- }
-
-// public void writeExternal(ObjectOutput out) throws IOException
+// private Object writeReplace() throws ObjectStreamException
// {
-// out.writeUTF(containerName);
-// out.writeObject(id);
-// out.writeObject(metadata);
-// out.writeLong(lastUsed);
-//
-// if (beanMO == null)
+// Serialized state = new Serialized();
+// if (this.beanMO == null)
// {
// Object[] beanAndInterceptors = new Object[4];
// beanAndInterceptors[0] = bean;
@@ -962,8 +920,15 @@
// // two different versions of the constituent state that
// // can fall out of sync. So now we just write a local variable.
//
-// MarshalledObject mo = new MarshalledObject(beanAndInterceptors);
-// out.writeObject(mo);
+// try
+// {
+// MarshalledObject mo = new MarshalledObject(beanAndInterceptors);
+// state.beanMO = mo;
+// }
+// catch(IOException e)
+// {
+// throw new RuntimeException("Marshalling of bean " + bean + " failed", e);
+// }
// }
// else
// {
@@ -971,30 +936,88 @@
// // extractBeanAndInterceptors hasn't been called in between.
// // This can happen if a passivated session is involved in a
// // JBoss Cache state transfer to a newly deployed node.
-// out.writeObject(beanMO);
+// state.beanMO = this.beanMO;
// }
-//
//
-// out.writeBoolean(removed);
-// out.writeBoolean(replicationIsPassivation);
+// state.containerClusterUid = this.containerClusterUid;
+// state.containerGuid = this.containerGuid;
+// state.isClustered = this.isClustered;
+// state.id = this.id;
+// state.lastUsed = this.lastUsed;
+// state.metadata = this.metadata;
+// state.removed = this.removed;
+// state.replicationIsPassivation = this.replicationIsPassivation;
+// return state;
// }
-//
-// public void readExternal(ObjectInput in) throws IOException,
-// ClassNotFoundException
-// {
-// containerName = in.readUTF();
-// id = in.readObject();
-// metadata = (SimpleMetaData) in.readObject();
-// lastUsed = in.readLong();
-//
-// beanMO = (MarshalledObject) in.readObject();
-// removed = in.readBoolean();
-// replicationIsPassivation = in.readBoolean();
-//
-// // If we've just been deserialized, we are passivated
-// passivated = true;
-// }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeUTF(containerClusterUid);
+ out.writeUTF(containerGuid);
+ out.writeBoolean(isClustered);
+ out.writeObject(id);
+ out.writeLong(lastUsed);
+ out.writeObject(metadata);
+ out.writeBoolean(removed);
+ out.writeBoolean(replicationIsPassivation);
+
+ if (beanMO == null)
+ {
+ Object[] beanAndInterceptors = new Object[4];
+ beanAndInterceptors[0] = bean;
+ beanAndInterceptors[1] = persistenceContexts;
+ if (interceptorInstances != null && interceptorInstances.size() > 0)
+ {
+ ArrayList list = new ArrayList();
+ list.addAll(interceptorInstances.values());
+ beanAndInterceptors[2] = list;
+ }
+ beanAndInterceptors[3] = contains;
+
+ // BES 2007/02/12 Previously we were trying to hold a ref to
+ // beanMO after we created it, but that exposes the risk of
+ // two different versions of the constituent state that
+ // can fall out of sync. So now we just write a local variable.
+
+ MarshalledObject mo = new MarshalledObject(beanAndInterceptors);
+ out.writeObject(mo);
+ }
+ else
+ {
+ // We've been deserialized and are now being re-serialized, but
+ // extractBeanAndInterceptors hasn't been called in between.
+ // This can happen if a passivated session is involved in a
+ // JBoss Cache state transfer to a newly deployed node.
+ out.writeObject(beanMO);
+ }
+ }
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException
+ {
+ containerClusterUid = in.readUTF();
+ containerGuid = in.readUTF();
+ isClustered = in.readBoolean();
+
+ container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid);
+ if (isClustered && container == null)
+ container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
+
+ if(container == null)
+ throw new IllegalStateException("Can't find container " + containerGuid);
+
+ id = in.readObject();
+ lastUsed = in.readLong();
+ metadata = (SimpleMetaData) in.readObject();
+ removed = in.readBoolean();
+ replicationIsPassivation = in.readBoolean();
+
+ beanMO = (MarshalledObject) in.readObject();
+
+ // If we've just been deserialized, we are passivated
+ passivated = true;
+ }
+
public Object getInvokedMethodKey()
{
return this.getId();
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java 2008-05-14 16:00:27 UTC (rev 73394)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulBeanContextReference.java 2008-05-14 17:39:36 UTC (rev 73395)
@@ -21,10 +21,6 @@
*/
package org.jboss.ejb3.stateful;
-import java.io.Externalizable;
-import java.io.ObjectInput;
-import java.io.IOException;
-import java.io.ObjectOutput;
import java.io.Serializable;
import org.jboss.ejb3.Ejb3Registry;
@@ -38,7 +34,7 @@
public class StatefulBeanContextReference implements Serializable
{
/** The serialVersionUID */
- private static final long serialVersionUID = 2644760020735482423L;
+ private static final long serialVersionUID = -7622266426902284032L;
private transient StatefulBeanContext beanContext;
private Object oid;
@@ -46,18 +42,6 @@
private String containerClusterUid;
private boolean isClustered = false;
- private static class Serialized implements Serializable
- {
- private Object oid;
- private String containerGuid;
- private String containerClusterUid;
- private boolean isClustered = false;
-
- private Serialized(StatefulBeanContextReference ref)
- {
- }
- }
-
public StatefulBeanContextReference(StatefulBeanContext beanContext)
{
assert beanContext != null : "beanContext is null";
@@ -69,18 +53,6 @@
isClustered = beanContext.getContainer().isClustered();
}
-// public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
-// {
-// containerId = in.readUTF();
-// oid = in.readObject();
-// }
-//
-// public void writeExternal(ObjectOutput out) throws IOException
-// {
-// out.writeUTF(containerId);
-// out.writeObject(oid);
-// }
-
public StatefulBeanContext getBeanContext()
{
if (beanContext == null)
@@ -96,9 +68,4 @@
}
return beanContext;
}
-
- private Object writeReplace()
- {
- return new Serialized(this);
- }
}
More information about the jboss-cvs-commits
mailing list