[jbossws-commits] JBossWS SVN: r15042 - common/trunk/src/main/java/org/jboss/ws/common/deployment.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Fri Oct 7 04:40:57 EDT 2011
Author: alessio.soldano at jboss.com
Date: 2011-10-07 04:40:57 -0400 (Fri, 07 Oct 2011)
New Revision: 15042
Added:
common/trunk/src/main/java/org/jboss/ws/common/deployment/SecurityActions.java
Modified:
common/trunk/src/main/java/org/jboss/ws/common/deployment/DeploymentAspectManagerImpl.java
Log:
[JBWS-3366] Use DeploymentAspect::getLoader to set the TCCL before starting/stopping DA in DeploymentAspectManagerImpl
Modified: common/trunk/src/main/java/org/jboss/ws/common/deployment/DeploymentAspectManagerImpl.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/deployment/DeploymentAspectManagerImpl.java 2011-10-07 08:37:57 UTC (rev 15041)
+++ common/trunk/src/main/java/org/jboss/ws/common/deployment/DeploymentAspectManagerImpl.java 2011-10-07 08:40:57 UTC (rev 15042)
@@ -123,8 +123,19 @@
DeploymentAspect aspect = getDeploymentAspects().get(i);
try
{
- logInvocation(aspect, "Start");
- aspect.start(dep);
+ if (aspect.canHandle(dep)) {
+ logInvocation(aspect, "Start");
+ ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
+ try
+ {
+ SecurityActions.setContextClassLoader(aspect.getLoader());
+ aspect.start(dep);
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(origClassLoader);
+ }
+ }
}
catch (RuntimeException rte)
{
Added: common/trunk/src/main/java/org/jboss/ws/common/deployment/SecurityActions.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/deployment/SecurityActions.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/ws/common/deployment/SecurityActions.java 2011-10-07 08:40:57 UTC (rev 15042)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ws.common.deployment;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 06-Oct-2011
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the context classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
More information about the jbossws-commits
mailing list