[jboss-cvs] JBossAS SVN: r61605 - trunk/ejb3/src/main/org/jboss/ejb3/stateful.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 22 14:25:33 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-22 14:25:33 -0400 (Thu, 22 Mar 2007)
New Revision: 61605
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
Log:
[EJBTHREE-923] Avoid unnecessary passivation/activation callbacks for beans cached on remote nodes
Avoid leak to TM via XPC cleanup Synchronization
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-03-22 18:00:12 UTC (rev 61604)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-03-22 18:25:33 UTC (rev 61605)
@@ -324,7 +324,10 @@
{
boolean canPassivate = (removed || !inUse);
- if (canPassivate && getContains() != null)
+ // Just check contains directly; don't call getContains() since
+ // getContains() will deserialize the beanMO. If the beanMO isn't
+ // deserialized it's safe to assume the children aren't in use
+ if (canPassivate && contains != null)
{
synchronized (contains)
{
@@ -405,13 +408,19 @@
passivated = true;
}
- // Pass the call on to any nested children
- List<StatefulBeanContext> children = getThreadSafeContains();
- if (children != null)
+ // Only bother informing children if we aren't already serialized.
+ // If we're serialized, so are they and there's no point.
+ // Notifying them would cause us to deserialize a beanMO to no purpose.
+ if (contains != null)
{
- for (StatefulBeanContext contained : children)
+ // Pass the call on to any nested children
+ List<StatefulBeanContext> children = getThreadSafeContains();
+ if (children != null)
{
- contained.passivateAfterReplication();
+ for (StatefulBeanContext contained : children)
+ {
+ contained.passivateAfterReplication();
+ }
}
}
}
@@ -628,17 +637,7 @@
Transaction tx = TxUtil.getTransactionManager().getTransaction();
if (tx != null && TxUtils.isActive(tx))
{
- tx.registerSynchronization(new Synchronization()
- {
- public void beforeCompletion()
- {
- }
-
- public void afterCompletion(int status)
- {
- closeExtendedPCs();
- }
- });
+ tx.registerSynchronization(new XPCCloseSynchronization(this));
}
else
{
@@ -769,7 +768,7 @@
return super.getInterceptorInstances(interceptorInfos);
}
- protected void extractBeanAndInterceptors()
+ protected synchronized void extractBeanAndInterceptors()
{
if (beanMO == null)
return;
@@ -875,4 +874,25 @@
{
return this.getId();
}
+
+ private static class XPCCloseSynchronization implements Synchronization
+ {
+ private StatefulBeanContext ctx;
+
+ private XPCCloseSynchronization(StatefulBeanContext context)
+ {
+ ctx = context;
+ }
+
+ public void beforeCompletion()
+ {
+ }
+
+ public void afterCompletion(int status)
+ {
+ ctx.closeExtendedPCs();
+ // Clean ref to ctx, as some TMs leak Synchronization refs
+ ctx = null;
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list