[jboss-cvs] JBossAS SVN: r61595 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 22 12:30:35 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-22 12:30:35 -0400 (Thu, 22 Mar 2007)
New Revision: 61595
Modified:
branches/Branch_4_2/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: 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-03-22 16:29:02 UTC (rev 61594)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java 2007-03-22 16:30:35 UTC (rev 61595)
@@ -326,7 +326,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)
{
@@ -407,13 +410,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();
+ }
}
}
}
@@ -630,17 +639,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
{
@@ -771,7 +770,7 @@
return super.getInterceptorInstances(interceptorInfos);
}
- protected void extractBeanAndInterceptors()
+ protected synchronized void extractBeanAndInterceptors()
{
if (beanMO == null)
return;
@@ -890,4 +889,25 @@
throw new IllegalStateException(e);
}
}
+
+ 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