[jboss-cvs] JBossAS SVN: r80990 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 00:47:33 EST 2008
Author: anil.saldhana at jboss.com
Date: 2008-11-14 00:47:33 -0500 (Fri, 14 Nov 2008)
New Revision: 80990
Added:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SecurityActions.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
Log:
EJBTHREE-1587: priv blocks
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SecurityActions.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SecurityActions.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SecurityActions.java 2008-11-14 05:47:33 UTC (rev 80990)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.session;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Nov 13, 2008
+ */
+class SecurityActions
+{
+ static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ static void setContextClassLoader(final ClassLoader cls)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cls);
+ return null;
+ }
+ });
+ }
+}
\ No newline at end of file
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2008-11-14 05:34:47 UTC (rev 80989)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2008-11-14 05:47:33 UTC (rev 80990)
@@ -132,9 +132,10 @@
/*
* Replace the TCL with the CL for this Container
*/
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(this.getClassloader());
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
+ SecurityActions.setContextClassLoader(this.getClassloader());
+
try
{
@@ -221,7 +222,7 @@
finally
{
invokedMethod.pop();
- Thread.currentThread().setContextClassLoader(oldLoader);
+ SecurityActions.setContextClassLoader(oldLoader);
}
}
More information about the jboss-cvs-commits
mailing list