Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F26C982DA for ; Tue, 30 Aug 2011 05:58:51 +0000 (UTC) Received: (qmail 12467 invoked by uid 500); 30 Aug 2011 05:58:45 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 12318 invoked by uid 500); 30 Aug 2011 05:58:33 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 12304 invoked by uid 99); 30 Aug 2011 05:58:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2011 05:58:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Aug 2011 05:58:28 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1C70523888FD; Tue, 30 Aug 2011 05:58:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1163094 - /geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoClassLoader.java Date: Tue, 30 Aug 2011 05:58:08 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110830055808.1C70523888FD@eris.apache.org> Author: xuhaihong Date: Tue Aug 30 05:58:07 2011 New Revision: 1163094 URL: http://svn.apache.org/viewvc?rev=1163094&view=rev Log: GERONIMO-6132 Not search wired bundles in bundle classloader by default Modified: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoClassLoader.java Modified: geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoClassLoader.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoClassLoader.java?rev=1163094&r1=1163093&r2=1163094&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoClassLoader.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-hook/src/main/java/org/apache/geronimo/hook/equinox/GeronimoClassLoader.java Tue Aug 30 05:58:07 2011 @@ -45,25 +45,25 @@ import org.osgi.framework.ServiceReferen public class GeronimoClassLoader extends URLClassLoader implements BaseClassLoader { - private static final String PREFIX = "org.apache.xbean.osgi.bundle.util.BundleResourceHelper"; + private static final String PREFIX = "org.apache.xbean.osgi.bundle.util.BundleResourceHelper"; private static final String SEARCH_WIRED_BUNDLES = PREFIX + ".searchWiredBundles"; private static final String CONVERT_RESOURCE_URLS = PREFIX + ".convertResourceUrls"; - + private final static String META_INF_1 = "META-INF/"; private final static String META_INF_2 = "/META-INF/"; - + private final ClassLoaderHook hook; private final ClassLoaderDelegate delegate; private final ProtectionDomain domain; private final AbstractBundle bundle; private final ClasspathManager manager; - + private LinkedHashSet wiredBundles = null; - private boolean searchWiredBundles = getSearchWiredBundles(true); + private boolean searchWiredBundles = getSearchWiredBundles(false); private boolean convertResourceUrls = getConvertResourceUrls(true); - + private URLConverter converter; - + public GeronimoClassLoader(ClassLoaderHook hook, ClassLoader parent, ClassLoaderDelegate delegate, @@ -71,15 +71,15 @@ public class GeronimoClassLoader extends BaseData bundledata, String[] classpath, AbstractBundle bundle) { - super(new URL[] {}, parent); + super(new URL[] {}, parent); this.hook = hook; this.delegate = delegate; this.domain = domain; this.bundle = bundle; - + this.manager = new ClasspathManager(bundledata, classpath, this); } - + @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class clazz = delegate.findClass(name); @@ -88,14 +88,14 @@ public class GeronimoClassLoader extends } return clazz; } - + @Override public URL getResource(String name) { URL resource = delegate.findResource(name); if (resource == null && isMetaInfResource(name)) { LinkedHashSet wiredBundles = getWiredBundles(); Iterator iterator = wiredBundles.iterator(); - while (iterator.hasNext() && resource == null) { + while (iterator.hasNext() && resource == null) { resource = iterator.next().getResource(name); } } @@ -105,10 +105,10 @@ public class GeronimoClassLoader extends return resource; } } - + @Override public Enumeration findResources(String name) throws IOException { - Enumeration e = (Enumeration) delegate.findResources(name); + Enumeration e = delegate.findResources(name); if (isMetaInfResource(name)) { List allResources = getList(); addToList(allResources, e); @@ -117,35 +117,35 @@ public class GeronimoClassLoader extends Enumeration resources = wiredBundle.getResources(name); addToList(allResources, resources); } - return Collections.enumeration(allResources); + return Collections.enumeration(allResources); } else if (e == null) { return Collections.enumeration(Collections.emptyList()); } else { List allResources = getList(); addToList(allResources, e); return Collections.enumeration(allResources); - } + } } - + public void setSearchWiredBundles(boolean search) { searchWiredBundles = search; } - + public boolean getSearchWiredBundles() { return searchWiredBundles; } - + private synchronized LinkedHashSet getWiredBundles() { if (wiredBundles == null) { wiredBundles = BundleUtils.getWiredBundles(bundle); } return wiredBundles; } - + private boolean isMetaInfResource(String name) { return searchWiredBundles && name != null && (name.startsWith(META_INF_1) || name.startsWith(META_INF_2)); } - + private List getList() { if (converter == null) { return new ArrayList(); @@ -157,7 +157,7 @@ public class GeronimoClassLoader extends }; } } - + private void addToList(List list, Enumeration enumeration) { if (enumeration != null) { while (enumeration.hasMoreElements()) { @@ -165,7 +165,7 @@ public class GeronimoClassLoader extends } } } - + private URL convert(URL url) { try { URL convertedURL = converter.resolve(url); @@ -182,29 +182,29 @@ public class GeronimoClassLoader extends BundleContext context = bundle.getBundleContext(); if (context != null) { ServiceReference urlReference = context.getServiceReference(URLConverter.class.getName()); - if (urlReference != null) { + if (urlReference != null) { converter = (URLConverter) context.getService(urlReference); } } } } - + public void close() { - manager.close(); + manager.close(); } - + // other BaseClassLoader methods - + public ProtectionDomain getDomain() { return domain; } - + @Override protected String findLibrary(String libname) { // let the manager find the library for us return manager.findLibrary(libname); } - + public ClasspathEntry createClassPathEntry(BundleFile bundlefile, ProtectionDomain cpDomain) { return new ClasspathEntry(bundlefile, DefaultClassLoader.createProtectionDomain(bundlefile, cpDomain)); } @@ -253,7 +253,7 @@ public class GeronimoClassLoader extends return delegate.listResources(path, filePattern, options); } - public Collection listLocalResources(String path, String filePattern, int options) { + public Collection listLocalResources(String path, String filePattern, int options) { return manager.listLocalResources(path, filePattern, options); } @@ -264,14 +264,14 @@ public class GeronimoClassLoader extends public Bundle getBundle() { return manager.getBaseData().getBundle(); } - + private static boolean getSearchWiredBundles(boolean defaultValue) { String value = System.getProperty(SEARCH_WIRED_BUNDLES); - return (value == null) ? defaultValue : Boolean.parseBoolean(value); + return (value == null) ? defaultValue : Boolean.parseBoolean(value); } - + private static boolean getConvertResourceUrls(boolean defaultValue) { String value = System.getProperty(CONVERT_RESOURCE_URLS); - return (value == null) ? defaultValue : Boolean.parseBoolean(value); - } + return (value == null) ? defaultValue : Boolean.parseBoolean(value); + } }