[jboss-cvs] JBossAS SVN: r59204 - in trunk/server/src/main/org/jboss/ejb: . plugins plugins/inflow plugins/jms plugins/local txtimer
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 21 17:09:45 EST 2006
Author: bill.burke at jboss.com
Date: 2006-12-21 17:09:38 -0500 (Thu, 21 Dec 2006)
New Revision: 59204
Modified:
trunk/server/src/main/org/jboss/ejb/Container.java
trunk/server/src/main/org/jboss/ejb/EjbModule.java
trunk/server/src/main/org/jboss/ejb/EntityContainer.java
trunk/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java
trunk/server/src/main/org/jboss/ejb/MessageDrivenContainer.java
trunk/server/src/main/org/jboss/ejb/SessionContainer.java
trunk/server/src/main/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
trunk/server/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
trunk/server/src/main/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
trunk/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
trunk/server/src/main/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
trunk/server/src/main/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
Log:
Revamp java:comp processing EJB 2.1 containers now push/pop ENC ID onto ENCFactory ThreadLocal stack
Modified: trunk/server/src/main/org/jboss/ejb/Container.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/Container.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/Container.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -78,6 +78,7 @@
import org.jboss.naming.ENCThreadLocalKey;
import org.jboss.naming.NonSerializableFactory;
import org.jboss.naming.Util;
+import org.jboss.naming.ENCFactory;
import org.jboss.security.AnybodyPrincipal;
import org.jboss.security.AuthenticationManager;
import org.jboss.security.AuthorizationManager;
@@ -541,22 +542,43 @@
this.metaData = metaData;
}
+ /**
+ * push the ENC onto the stack so that java:comp works
+ *
+ */
+ public void pushENC()
+ {
+ ENCFactory.pushContextId(getJmxName());
+ }
+
+ public void popENC()
+ {
+ ENCFactory.popContextId();
+ }
+
+ /**
+ * cleanup ENC on shutdown
+ *
+ */
+ public void cleanENC()
+ {
+ ENCFactory.getEncById().remove(getJmxName());
+ }
+
/** Get the components environment context
* @jmx.managed-attribute
* @return Environment Context
*/
public Context getEnvContext() throws NamingException
{
- ClassLoader ccl = SecurityActions.getContextClassLoader();
+ pushENC();
try
{
- // The ENC is a map keyed on the class loader
- SecurityActions.setContextClassLoader(classLoader);
return (Context)new InitialContext().lookup("java:comp/env");
}
finally
{
- SecurityActions.setContextClassLoader(ccl);
+ popENC();
}
}
@@ -846,6 +868,7 @@
*/
protected void destroyService() throws Exception
{
+ cleanENC();
localProxyFactory.destroy();
ejbModule.removeLocalHome(this);
@@ -904,6 +927,7 @@
String contextID = getJaccContextID();
try
{
+ pushENC();
if(!this.classLoader.equals(callerClassLoader))
{
setCl = true;
@@ -1019,6 +1043,8 @@
// stat gathering: concurrent calls
this.invokeStats.callOut();
+ popENC();
+
// Restore the incoming class loader
if(setCl)
{
Modified: trunk/server/src/main/org/jboss/ejb/EjbModule.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/EjbModule.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/EjbModule.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -474,13 +474,14 @@
{
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(con.getClassLoader());
-
+ con.pushENC();
try
{
((EntityContainer)con).getPersistenceManager().start();
}
finally
{
+ con.popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
Modified: trunk/server/src/main/org/jboss/ejb/EntityContainer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/EntityContainer.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/EntityContainer.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -244,7 +244,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Acquire classes from CL
@@ -322,6 +322,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -332,7 +333,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Call default start
@@ -364,6 +365,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -374,7 +376,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
//Stop items in reverse order from start
@@ -411,6 +413,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -421,7 +424,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Destroy container invoker
@@ -483,6 +486,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
Modified: trunk/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/GlobalTxEntityMap.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -127,9 +127,16 @@
EntityContainer container = (EntityContainer) instance.getContainer();
// set the context class loader before calling the store method
SecurityActions.setContextClassLoader(thread, container.getClassLoader());
-
- // store it
- container.invokeEjbStore(instance);
+ container.pushENC();
+ try
+ {
+ // store it
+ container.invokeEjbStore(instance);
+ }
+ finally
+ {
+ container.popENC();
+ }
}
}
@@ -144,11 +151,18 @@
// set the context class loader before calling the store method
SecurityActions.setContextClassLoader(thread, container.getClassLoader());
+ container.pushENC();
+ try
+ {
+ // store it
+ container.storeEntity(instance);
- // store it
- container.storeEntity(instance);
-
- instance.setTxAssociation(SYNCHRONIZED);
+ instance.setTxAssociation(SYNCHRONIZED);
+ }
+ finally
+ {
+ container.popENC();
+ }
}
}
};
Modified: trunk/server/src/main/org/jboss/ejb/MessageDrivenContainer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/MessageDrivenContainer.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/MessageDrivenContainer.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -162,7 +162,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Call default init
@@ -237,6 +237,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -247,7 +248,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Call default start
@@ -277,6 +278,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -287,7 +289,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Call default stop
@@ -314,6 +316,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -324,7 +327,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Destroy container invoker
@@ -377,6 +380,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
Modified: trunk/server/src/main/org/jboss/ejb/SessionContainer.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/SessionContainer.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/SessionContainer.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -142,7 +142,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Acquire classes from CL
@@ -183,6 +183,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -388,7 +389,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Call default start
@@ -409,6 +410,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -461,7 +463,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
// Call default stop
@@ -479,6 +481,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
@@ -527,7 +530,7 @@
// Associate thread with classloader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(getClassLoader());
-
+ pushENC();
try
{
destroyInvokers();
@@ -552,6 +555,7 @@
}
finally
{
+ popENC();
// Reset classloader
SecurityActions.setContextClassLoader(oldCl);
}
Modified: trunk/server/src/main/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -124,7 +124,7 @@
// thread is associated with the right context class loader
ClassLoader oldCl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(container.getClassLoader());
-
+ container.pushENC();
ctx.hasTxSynchronization(false);
ctx.setTransaction(null);
try
@@ -168,6 +168,7 @@
} // synchronized(lock)
finally
{
+ container.popENC();
SecurityActions.setContextClassLoader(oldCl);
}
}
Modified: trunk/server/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -441,6 +441,7 @@
{
SecurityActions.setContextClassLoader(container.getClassLoader());
}
+ container.pushENC();
int commitOption = ctx.isPassivateAfterCommit() ?
ConfigurationMetaData.C_COMMIT_OPTION : EntitySynchronizationInterceptor.this.commitOption;
@@ -513,6 +514,7 @@
{
lock.releaseSync();
container.getLockManager().removeLockRef(lock.getId());
+ container.popENC();
if(setCl)
{
SecurityActions.setContextClassLoader(oldCl);
Modified: trunk/server/src/main/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -244,6 +244,7 @@
MessageDrivenContainer container = getContainer(mi);
boolean commit = true;
+ container.pushENC();
try
{
// Check for starting a transaction
@@ -265,6 +266,7 @@
}
finally
{
+ container.popENC();
// No before/after delivery, end any transaction and release the lock
if (oldClassLoader == null)
{
@@ -299,6 +301,7 @@
{
// Reset delivered flag
delivered = false;
+
// Change back to the original context classloader
resetContextClassLoader(mi);
// We no longer hold the lock
Modified: trunk/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -982,12 +982,14 @@
// Set the right context classloader
ClassLoader oldCL = TCLAction.UTIL.getContextClassLoader();
TCLAction.UTIL.setContextClassLoader(container.getClassLoader());
+ container.pushENC();
try
{
return container.invoke(invocation);
}
finally
{
+ container.popENC();
TCLAction.UTIL.setContextClassLoader(oldCL);
}
}
Modified: trunk/server/src/main/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -344,6 +344,7 @@
{
TCLAction.UTIL.setContextClassLoader(container.getClassLoader());
}
+ container.pushENC();
SecurityActions sa = SecurityActions.UTIL.getSecurityActions();
try
@@ -376,6 +377,7 @@
}
finally
{
+ container.popENC();
if(setCl)
{
TCLAction.UTIL.setContextClassLoader(oldCl);
@@ -415,6 +417,7 @@
{
TCLAction.UTIL.setContextClassLoader(container.getClassLoader());
}
+ container.pushENC();
SecurityActions sa = SecurityActions.UTIL.getSecurityActions();
try
@@ -447,6 +450,7 @@
}
finally
{
+ container.popENC();
if(setCl)
{
TCLAction.UTIL.setContextClassLoader(oldCl);
Modified: trunk/server/src/main/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java 2006-12-21 21:23:17 UTC (rev 59203)
+++ trunk/server/src/main/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java 2006-12-21 22:09:38 UTC (rev 59204)
@@ -78,6 +78,7 @@
{
ClassLoader callerClassLoader = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(container.getClassLoader());
+ container.pushENC();
try
{
Invocation inv = new Invocation(timedObjectId.getInstancePk(), method, new Object[]{timer}, null, null, null);
@@ -100,6 +101,7 @@
}
finally
{
+ container.popENC();
SecurityActions.popRunAsIdentity();
SecurityActions.setContextClassLoader(callerClassLoader);
}
More information about the jboss-cvs-commits
mailing list