[jboss-cvs] JBossAS SVN: r112264 - in projects/specs/trunk/jboss-jacc-api_1.4_spec: src/main/java/javax/security/jacc and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 26 09:59:08 EDT 2011


Author: mmoyses
Date: 2011-09-26 09:59:08 -0400 (Mon, 26 Sep 2011)
New Revision: 112264

Modified:
   projects/specs/trunk/jboss-jacc-api_1.4_spec/pom.xml
   projects/specs/trunk/jboss-jacc-api_1.4_spec/src/main/java/javax/security/jacc/PolicyConfigurationFactory.java
Log:
removing common-core dependency

Modified: projects/specs/trunk/jboss-jacc-api_1.4_spec/pom.xml
===================================================================
--- projects/specs/trunk/jboss-jacc-api_1.4_spec/pom.xml	2011-09-22 15:04:56 UTC (rev 112263)
+++ projects/specs/trunk/jboss-jacc-api_1.4_spec/pom.xml	2011-09-26 13:59:08 UTC (rev 112264)
@@ -8,7 +8,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.jboss.spec.javax.security.jacc</groupId>
   <artifactId>jboss-jacc-api_1.4_spec</artifactId>
-  <version>1.0.2-SNAPSHOT</version>
+  <version>1.0.1.Final</version>
   <packaging>jar</packaging>
   <name>JACC 1.4 API</name>
   <description>The Java Authorization Contract for Containers 1.4 API classes</description>

Modified: projects/specs/trunk/jboss-jacc-api_1.4_spec/src/main/java/javax/security/jacc/PolicyConfigurationFactory.java
===================================================================
--- projects/specs/trunk/jboss-jacc-api_1.4_spec/src/main/java/javax/security/jacc/PolicyConfigurationFactory.java	2011-09-22 15:04:56 UTC (rev 112263)
+++ projects/specs/trunk/jboss-jacc-api_1.4_spec/src/main/java/javax/security/jacc/PolicyConfigurationFactory.java	2011-09-26 13:59:08 UTC (rev 112264)
@@ -88,59 +88,62 @@
       if (sm != null)
          sm.checkPermission(new SecurityPermission("setPolicy"));
 
-      if (factory == null)
+      synchronized (PolicyConfigurationFactory.class)
       {
-         String factoryName = null;
-         Class<?> clazz = null;
-         try
-         {
-            LoadAction action = new LoadAction();
-            try
-            {
-               clazz = AccessController.doPrivileged(action);
-               factoryName = action.getName();
-            }
-            catch (PrivilegedActionException ex)
-            {
-               factoryName = action.getName();
-               Exception e = ex.getException();
-               if (e instanceof ClassNotFoundException)
-                  throw (ClassNotFoundException) e;
-               else
-                  throw new PolicyContextException("Failure during load of class: " + action.getName(), e);
-            }
-            factory = (PolicyConfigurationFactory) clazz.newInstance();
-         }
-         catch (ClassNotFoundException e)
-         {
-            String msg = "Failed to find PolicyConfigurationFactory : " + factoryName;
-            throw new ClassNotFoundException(msg, e);
-         }
-         catch (IllegalAccessException e)
-         {
-            String msg = "Unable to access class : " + factoryName;
-            throw new PolicyContextException(msg, e);
-         }
-         catch (InstantiationException e)
-         {
-            String msg = "Failed to create instance of: " + factoryName;
-            throw new PolicyContextException(msg, e);
-         }
-         catch (ClassCastException e)
-         {
-            StringBuffer msg = new StringBuffer(factoryName + " Is not a PolicyConfigurationFactory, ");
-            msg.append("PCF.class.CL: " + PolicyConfigurationFactory.class.getClassLoader());
-            msg.append("\nPCF.class.CS: " + PolicyConfigurationFactory.class.getProtectionDomain().getCodeSource());
-            msg.append("\nPCF.class.hash: " + System.identityHashCode(PolicyConfigurationFactory.class));
-            msg.append("\nclazz.CL: " + clazz.getClassLoader());
-            msg.append("\nclazz.CS: " + clazz.getProtectionDomain().getCodeSource());
-            msg.append("\nclazz.super.CL: " + clazz.getSuperclass().getClassLoader());
-            msg.append("\nclazz.super.CS: " + clazz.getSuperclass().getProtectionDomain().getCodeSource());
-            msg.append("\nclazz.super.hash: " + System.identityHashCode(clazz.getSuperclass()));
-            ClassCastException cce = new ClassCastException(msg.toString());
-            cce.initCause(e);
-            throw cce;
-         }
+    	  if (factory == null)
+    	  {
+    		  String factoryName = null;
+    		  Class<?> clazz = null;
+    		  try
+    		  {
+    			  LoadAction action = new LoadAction();
+    			  try
+    			  {
+    				  clazz = AccessController.doPrivileged(action);
+    				  factoryName = action.getName();
+    			  }
+    			  catch (PrivilegedActionException ex)
+    			  {
+    				  factoryName = action.getName();
+    				  Exception e = ex.getException();
+    				  if (e instanceof ClassNotFoundException)
+    					  throw (ClassNotFoundException) e;
+    				  else
+    					  throw new PolicyContextException("Failure during load of class: " + factoryName, e);
+    			  }
+    			  factory = (PolicyConfigurationFactory) clazz.newInstance();
+    		  }
+    		  catch (ClassNotFoundException e)
+    		  {
+    			  String msg = "Failed to find PolicyConfigurationFactory : " + factoryName;
+    			  throw new ClassNotFoundException(msg, e);
+    		  }
+    		  catch (IllegalAccessException e)
+    		  {
+    			  String msg = "Unable to access class : " + factoryName;
+    			  throw new PolicyContextException(msg, e);
+    		  }
+    		  catch (InstantiationException e)
+    		  {
+    			  String msg = "Failed to create instance of: " + factoryName;
+    			  throw new PolicyContextException(msg, e);
+    		  }
+    		  catch (ClassCastException e)
+    		  {
+    			  StringBuffer msg = new StringBuffer(factoryName + " Is not a PolicyConfigurationFactory, ");
+    			  msg.append("PCF.class.CL: " + PolicyConfigurationFactory.class.getClassLoader());
+    			  msg.append("\nPCF.class.CS: " + PolicyConfigurationFactory.class.getProtectionDomain().getCodeSource());
+    			  msg.append("\nPCF.class.hash: " + System.identityHashCode(PolicyConfigurationFactory.class));
+    			  msg.append("\nclazz.CL: " + clazz.getClassLoader());
+    			  msg.append("\nclazz.CS: " + clazz.getProtectionDomain().getCodeSource());
+    			  msg.append("\nclazz.super.CL: " + clazz.getSuperclass().getClassLoader());
+    			  msg.append("\nclazz.super.CS: " + clazz.getSuperclass().getProtectionDomain().getCodeSource());
+    			  msg.append("\nclazz.super.hash: " + System.identityHashCode(clazz.getSuperclass()));
+    			  ClassCastException cce = new ClassCastException(msg.toString());
+    			  cce.initCause(e);
+    			  throw cce;
+    		  }
+    	  }
       }
       return factory;
    }
@@ -234,9 +237,26 @@
             // Use the default factory implementation.
             name = DEFAULT_FACTORY_NAME;
          }
-         ClassLoader loader = Thread.currentThread().getContextClassLoader();
-         Class<?> factoryClass = loader.loadClass(name);
-         return factoryClass;
+         ClassLoader[] cls = new ClassLoader[] { PolicyConfigurationFactory.class.getClassLoader(), // JACC classes (not always on TCCL [modular env])
+        		 Thread.currentThread().getContextClassLoader(), // User defined classes
+                 ClassLoader.getSystemClassLoader() // System loader, usually has app class path
+         };
+         ClassNotFoundException e = null;
+         for (ClassLoader cl : cls)
+         {
+             if (cl == null)
+                 continue;
+
+             try
+             {
+                 return cl.loadClass(name);
+             }
+             catch (ClassNotFoundException ce)
+             {
+                 e = ce;
+             }
+         }
+         throw e != null ? e : new ClassNotFoundException(name);
       }
    }
 }



More information about the jboss-cvs-commits mailing list