Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 3438 invoked from network); 22 Mar 2008 13:18:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Mar 2008 13:18:21 -0000 Received: (qmail 13325 invoked by uid 500); 22 Mar 2008 13:18:19 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 13182 invoked by uid 500); 22 Mar 2008 13:18:18 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 13171 invoked by uid 500); 22 Mar 2008 13:18:18 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 13168 invoked by uid 99); 22 Mar 2008 13:18:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Mar 2008 06:18:18 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Mar 2008 13:17:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B81BF1A983A; Sat, 22 Mar 2008 06:17:56 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: axis2-cvs@ws.apache.org From: scheu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080322131756.B81BF1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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