axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r639992 - /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java
Date Sat, 22 Mar 2008 13:17:56 GMT
Author: scheu
Date: Sat Mar 22 06:17:56 2008
New Revision: 639992

URL: http://svn.apache.org/viewvc?rev=639992&view=rev
Log:
Quick addition of doPriv calls to OASISCatalogManager.

Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java?rev=639992&r1=639991&r2=639992&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/catalog/impl/OASISCatalogManager.java
Sat Mar 22 06:17:56 2008
@@ -28,6 +28,8 @@
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.logging.Logger;
 
 /**
@@ -117,16 +119,16 @@
 
     private String determineFileName() {
 
-    	ClassLoader classLoader = findClassLoader();
-    	// try web app WEB-INF first
-    	URL url = classLoader.getResource(DEFAULT_CATALOG_WEB);
-    	if (url != null) {
-    		return url.toString();
-    	}
-    	// have not returned -- perhaps we're in an EJB?
-    	url = classLoader.getResource(DEFAULT_CATALOG_EJB);
-    	return url == null? null: url.toString();
-    	
+        ClassLoader classLoader = findClassLoader();
+        // try web app WEB-INF first
+        URL url = classLoader.getResource(DEFAULT_CATALOG_WEB);
+        if (url != null) {
+            return url.toString();
+        }
+        // have not returned -- perhaps we're in an EJB?
+        url = classLoader.getResource(DEFAULT_CATALOG_EJB);
+        return url == null? null: url.toString();
+
     }
     
     /**
@@ -135,41 +137,50 @@
      * This method returns an instance of the underlying catalog class.
      */
     public Catalog getPrivateCatalog() {
-        Catalog catalog = staticCatalog;
-        boolean useStatic = super.getUseStaticCatalog();
-
-        if (catalog == null || !useStatic) {
-            try {
-  	            String catalogClassName = getCatalogClassName();
-  	            if (catalogClassName == null) {
-  	                catalog = new Catalog();
-  	            } else {
-  	                try {
-  	                    catalog = (Catalog) Class.forName(catalogClassName).newInstance();
-  	                } catch (ClassNotFoundException cnfe) {
-  	                    debug.message(1,"Catalog class named '"
-  			                          + catalogClassName
-  			                          + "' could not be found. Using default.");
-  	                    catalog = new Catalog();
-  	                } catch (ClassCastException cnfe) {
-  	                    debug.message(1,"Class named '"
-  			                          + catalogClassName
-  			                          + "' is not a Catalog. Using default.");
-  	                    catalog = new Catalog();
-  	                }
-  	            }
-
-  	            catalog.setCatalogManager(this);
-  	            catalog.setupReaders();
-  	            catalog.loadSystemCatalogs();
-            } catch (Exception ex) {
-  	            ex.printStackTrace();
-            }
-
-  	        staticCatalog = catalog;
+        try {
+            final CatalogManager cm = this;
+            Catalog catalog = 
+                (Catalog) AccessController.
+                doPrivileged(new PrivilegedExceptionAction() {
+                    public Object run() throws Exception {
+                        Catalog catalog = staticCatalog;
+                        boolean useStatic = cm.getUseStaticCatalog();
+
+                        if (catalog == null || !useStatic) {
+
+                            String catalogClassName = getCatalogClassName();
+                            if (catalogClassName == null) {
+                                catalog = new Catalog();
+                            } else {
+                                try {
+                                    catalog = (Catalog) Class.forName(catalogClassName).newInstance();
+                                } catch (ClassNotFoundException cnfe) {
+                                    debug.message(1,"Catalog class named '"
+                                                  + catalogClassName
+                                                  + "' could not be found. Using default.");
+                                    catalog = new Catalog();
+                                } catch (ClassCastException cnfe) {
+                                    debug.message(1,"Class named '"
+                                                  + catalogClassName
+                                                  + "' is not a Catalog. Using default.");
+                                    catalog = new Catalog();
+                                }
+                            }
+
+                            catalog.setCatalogManager(cm);
+                            catalog.setupReaders();
+                            catalog.loadSystemCatalogs();
+                        }
+                        return catalog;
+                    }});
+            staticCatalog = catalog;
+            return catalog;
+        } catch (PrivilegedActionException pae) {
+            // The Catch and swallow
+            debug.message(1,"getPrivateCatatalog failed.  " +
+                        "Processing continues " + pae.getException());
         }
-
-        return catalog;
+        return null;
     }
     
     /**
@@ -192,25 +203,29 @@
      *                            host JDK
      */
     private static ClassLoader findClassLoader() {
-		// REVIEW need a doPriv block?
-
-		Method m = null;
-
-		try {
 
-			m = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
-		} catch (NoSuchMethodException e) {
-			// Assume that we are running JDK 1.1, use the current ClassLoader
-			// TODO print debug statement about assuming JDK 1.1
-			return OASISCatalogManager.class.getClassLoader();
-		}
-		try {
-			return (ClassLoader) m.invoke(Thread.currentThread(),
-					(Object[]) null);
-		} catch (Exception x) {
-			throw ExceptionFactory.makeWebServiceException(x);
-		}
-
-	}
+        try {
+            ClassLoader cl = 
+                (ClassLoader) AccessController.
+                doPrivileged(new PrivilegedExceptionAction() {
+                    public Object run() throws Exception {
+                        Method m = null;
+
+                        try {
+                            m = Thread.class.getMethod("getContextClassLoader", (Class[])
null);
+                        } catch (NoSuchMethodException e) {
+                            // Assume that we are running JDK 1.1, use the current ClassLoader
+                            // TODO print debug statement about assuming JDK 1.1
+                            return OASISCatalogManager.class.getClassLoader();
+                        }
+                        return (ClassLoader) m.invoke(Thread.currentThread(),
+                                                      (Object[]) null);
+                    }}
+                );
+            return cl;
+        } catch (PrivilegedActionException pae) {
+            throw ExceptionFactory.makeWebServiceException(pae.getException());
+        }
+    }
    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message