[jboss-cvs] JBossAS SVN: r86599 - projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 1 12:23:23 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-04-01 12:23:23 -0400 (Wed, 01 Apr 2009)
New Revision: 86599

Added:
   projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/SecurityActions.java
Modified:
   projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
Log:
[JBAOP-712] Use correct classloader for loading and deploying base-aspects.xml

Modified: projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2009-04-01 16:23:06 UTC (rev 86598)
+++ projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2009-04-01 16:23:23 UTC (rev 86599)
@@ -298,7 +298,8 @@
             if (base != null)
             {
                log.debug("Deploying base aspects " + base);
-               AspectXmlLoader.deployXML(base, null, manager);
+               ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
+               AspectXmlLoader.deployXML(base, cl, manager);
                deployedBaseXml = true;
             }
          }
@@ -337,7 +338,7 @@
          return null;
       }
 
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
       URL base = cl.getResource(baseXml);
       if (base == null)
       {

Added: projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/SecurityActions.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/SecurityActions.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/java/org/jboss/aop/asintegration/core/SecurityActions.java	2009-04-01 16:23:23 UTC (rev 86599)
@@ -0,0 +1,73 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.aop.asintegration.core;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SecurityActions
+{
+   interface GetClassLoaderAction
+   {
+      ClassLoader getClassLoader(Class<?> clazz);
+      
+      GetClassLoaderAction NON_PRIVILEGED = new GetClassLoaderAction()
+      {
+         public ClassLoader getClassLoader(Class<?> clazz)
+         {
+            return clazz.getClassLoader();
+         }
+      };
+      
+      GetClassLoaderAction PRIVILEGED = new GetClassLoaderAction()
+      {
+         public ClassLoader getClassLoader(final Class<?> clazz)
+         {
+            
+            return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+            {
+               public ClassLoader run()
+               {
+                  return clazz.getClassLoader();
+               }
+            });
+         }
+      };
+   }
+   
+   static ClassLoader getClassLoader(Class<?> clazz)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         return GetClassLoaderAction.NON_PRIVILEGED.getClassLoader(clazz);
+      }
+      else
+      {
+         return GetClassLoaderAction.PRIVILEGED.getClassLoader(clazz);
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list