[jboss-cvs] jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session ...
Brian Stansberry
brian.stansberry at jboss.com
Thu Jul 27 22:30:19 EDT 2006
User: bstansberry
Date: 06/07/27 22:30:19
Modified: src/main/org/jboss/web/tomcat/tc5/session Tag: Branch_4_0
JBossCacheService.java JBossCacheManager.java
CacheListener.java
Log:
[JBAS-3443] JBossCacheService shouldn't call PojoCache.getInstance()
Revision Changes Path
No revision
No revision
1.3.2.40 +6 -10 jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheService.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JBossCacheService.java
===================================================================
RCS file: /cvsroot/jboss/jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheService.java,v
retrieving revision 1.3.2.39
retrieving revision 1.3.2.40
diff -u -b -r1.3.2.39 -r1.3.2.40
--- JBossCacheService.java 21 Jun 2006 23:42:39 -0000 1.3.2.39
+++ JBossCacheService.java 28 Jul 2006 02:30:19 -0000 1.3.2.40
@@ -47,7 +47,6 @@
import org.jboss.aspects.patterns.observable.Subject;
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.aop.PojoCache;
import org.jboss.cache.aop.PojoCacheMBean;
import org.jboss.cache.transaction.BatchModeTransactionManager;
import org.jboss.invocation.MarshalledValue;
@@ -109,8 +108,6 @@
private String webAppPath_;
private TransactionManager tm;
- // Class loader for this web app.
- private ClassLoader tcl_;
private JBossCacheManager manager_;
private CacheListener cacheListener_;
private JBossCacheWrapper cacheWrapper_;
@@ -128,8 +125,8 @@
{
cacheServiceName_ = new ObjectName(treeCacheObjectName);
// Create Proxy-Object for this service
- proxy_ = (PojoCache) ((PojoCacheMBean) MBeanProxyExt.create(PojoCacheMBean.class,
- cacheServiceName_)).getInstance();
+ proxy_ = (PojoCacheMBean) MBeanProxyExt.create(PojoCacheMBean.class,
+ cacheServiceName_);
if (proxy_ == null)
{
throw new RuntimeException("JBossCacheService: locate null TomcatCacheMbean");
@@ -149,7 +146,6 @@
public void start(ClassLoader tcl, JBossCacheManager manager)
{
- tcl_ = tcl;
manager_ = manager;
Context webapp = (Context) manager_.getContainer();
@@ -186,9 +182,9 @@
if(useTreeCacheMarshalling_)
{
log_.debug("UseMarshalling is true. We will register the fqn: " +
- fqnStr + " with class loader" +tcl_ +
+ fqnStr + " with class loader" +tcl +
" and activate the webapp's Region");
- proxy_.registerClassLoader(fqnStr, tcl_);
+ proxy_.registerClassLoader(fqnStr, tcl);
proxy_.activateRegion(fqnStr);
}
} catch (Exception ex)
@@ -284,7 +280,7 @@
// Swap in/out the webapp classloader so we can deserialize
// attributes whose classes are only available to the webapp
ClassLoader prevTCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(tcl_);
+ Thread.currentThread().setContextClassLoader(manager_.getWebappClassLoader());
try
{
ByteArrayInputStream bais = new ByteArrayInputStream(sessionBytes);
@@ -1019,7 +1015,7 @@
if (mv == null) return null;
// Swap in/out the tcl for this web app. Needed only for un marshalling.
ClassLoader prevTCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(tcl_);
+ Thread.currentThread().setContextClassLoader(manager_.getWebappClassLoader());
try
{
return ((MarshalledValue) mv).get();
1.3.2.45 +63 -6 jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JBossCacheManager.java
===================================================================
RCS file: /cvsroot/jboss/jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java,v
retrieving revision 1.3.2.44
retrieving revision 1.3.2.45
diff -u -b -r1.3.2.44 -r1.3.2.45
--- JBossCacheManager.java 21 Jun 2006 19:57:43 -0000 1.3.2.44
+++ JBossCacheManager.java 28 Jul 2006 02:30:19 -0000 1.3.2.45
@@ -57,7 +57,7 @@
* @author Ben Wang
* @author Brian Stansberry
*
- * @version $Revision: 1.3.2.44 $
+ * @version $Revision: 1.3.2.45 $
*/
public class JBossCacheManager
extends JBossManager
@@ -119,6 +119,9 @@
*/
private Boolean replicationFieldBatchMode_;
+ /** Class loader for this web app. */
+ private ClassLoader tcl_;
+
// ---------------------------------------------------------- Constructors
public JBossCacheManager()
@@ -474,6 +477,9 @@
clearSessions();
+ // Don't leak the classloader
+ tcl_ = null;
+
proxy_.stop();
tm = null;
@@ -1125,6 +1131,14 @@
}
/**
+ * Gets the classloader of the webapp we are managing.
+ */
+ protected ClassLoader getWebappClassLoader()
+ {
+ return tcl_;
+ }
+
+ /**
* Goes through all sessions and look if they have expired.
* Note this overrides the method in JBossManager.
*/
@@ -1215,6 +1229,38 @@
}
}
+ public void processRemoteAttributeRemoval(String realId, String attrKey)
+ {
+
+ ClusteredSession session = findLocalSession(realId);
+ if (session != null)
+ {
+ boolean localCall = false; // call is due to remote event
+ boolean localOnly = true; // don't call back into cache
+ boolean notify = false; // SRV.10.7 gives us leeway
+ // not to notify listeners,
+ // which is safer
+
+ // Ensure the correct TCL is in place
+ ClassLoader prevTcl = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(tcl_);
+ try
+ {
+ synchronized (session)
+ {
+ session.removeAttributeInternal(attrKey, localCall, localOnly, notify);
+ }
+ if (log_.isTraceEnabled())
+ log_.trace("processRemoteAttributeRemoval: removed attribute " +
+ attrKey + " from " + realId);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(prevTcl);
+ }
+ }
+ }
+
public void processRemoteInvalidation(String realId)
{
// Remove the session from our local map
@@ -1239,7 +1285,18 @@
boolean localCall = false; // this call originated from the cache;
// we have already removed session
boolean localOnly = true; // Don't pass attr removals to cache
+
+ // Ensure the correct TCL is in place
+ ClassLoader prevTcl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(tcl_);
session.expire(notify, localCall, localOnly);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(prevTcl);
+ }
// Remove any stats for this session
stats_.removeStats(realId);
@@ -1299,9 +1356,9 @@
// Start the JBossCacheService
// Will need to pass the classloader that is associated with this
//web app so de-serialization will work correctly.
- ClassLoader tcl = super.getContainer().getLoader().getClassLoader();
+ tcl_ = super.getContainer().getLoader().getClassLoader();
- proxy_.start(tcl, this);
+ proxy_.start(tcl_, this);
tm = proxy_.getTransactionManager();
if(tm == null)
@@ -1403,8 +1460,8 @@
// We need to pass the classloader that is associated with this
// web app so de-serialization will work correctly.
- ClassLoader cl = container_.getLoader().getClassLoader();
- proxy_.start(cl, this);
+ tcl_ = container_.getLoader().getClassLoader();
+ proxy_.start(tcl_, this);
}
catch (ClusteringNotSupportedException e)
{
1.6.2.12 +4 -18 jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/CacheListener.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheListener.java
===================================================================
RCS file: /cvsroot/jboss/jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/CacheListener.java,v
retrieving revision 1.6.2.11
retrieving revision 1.6.2.12
diff -u -b -r1.6.2.11 -r1.6.2.12
--- CacheListener.java 14 Jun 2006 02:47:42 -0000 1.6.2.11
+++ CacheListener.java 28 Jul 2006 02:30:19 -0000 1.6.2.12
@@ -90,26 +90,12 @@
// as an Observer.
if (fieldBased_
&& needToHandle(fqn)
- && JBossCacheService.ATTRIBUTE.equals(fqn.get(POJO_ATTRIBUTE_FQN_INDEX)))
+ && JBossCacheService.ATTRIBUTE.equals(fqn.get(POJO_ATTRIBUTE_FQN_INDEX))
+ && fqn.size() > POJO_KEY_FQN_INDEX)
{
String sessId = getIdFromFqn(fqn);
- FieldBasedClusteredSession session =
- (FieldBasedClusteredSession) manager_.findLocalSession(sessId);
- if (session != null)
- {
String attrKey = (String) fqn.get(POJO_KEY_FQN_INDEX);
- boolean localCall = false; // call is due to remote event
- boolean localOnly = true; // don't call back into cache
- boolean notify = false; // SRV.10.7 gives us leeway
- // not to notify listeners,
- // which is safer
- synchronized (session)
- {
- session.removeAttributeInternal(attrKey, localCall, localOnly, notify);
- }
- if (log_.isTraceEnabled())
- log_.trace("nodeRemoved: removed attribute " + attrKey);
- }
+ manager_.processRemoteAttributeRemoval(sessId, attrKey);
}
}
else if(fqn.size() == SESSION_FQN_SIZE && needToHandle(fqn))
More information about the jboss-cvs-commits
mailing list