[jboss-cvs] JBossAS SVN: r104929 - projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 18 09:24:00 EDT 2010
Author: alesj
Date: 2010-05-18 09:24:00 -0400 (Tue, 18 May 2010)
New Revision: 104929
Modified:
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java
Log:
Use set over map.
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java 2010-05-18 13:20:44 UTC (rev 104928)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.java 2010-05-18 13:24:00 UTC (rev 104929)
@@ -55,6 +55,7 @@
import org.jboss.classloader.spi.PackageInformation;
import org.jboss.classloading.spi.RealClassLoader;
import org.jboss.logging.Logger;
+import org.jboss.util.collection.ConcurrentSet;
import org.jboss.util.collection.Iterators;
/**
@@ -78,13 +79,13 @@
private DelegateLoader loader;
/** The loaded classes */
- private Map<String, String> loadedClasses = new ConcurrentHashMap<String, String>();
+ private Set<String> loadedClasses = new ConcurrentSet<String>();
/** Our resource cache */
private Map<String, URL> resourceCache;
/** Our black list */
- private Map<String, String> blackList;
+ private Set<String> blackList;
/**
* Create a new ClassLoader with no parent.
@@ -109,7 +110,7 @@
resourceCache = new ConcurrentHashMap<String, URL>();
if (basePolicy.isBlackListable())
- blackList = new ConcurrentHashMap<String, String>();
+ blackList = new ConcurrentSet<String>();
if (log.isDebugEnabled())
log.debug("Created " + this + " with policy " + policy.toLongString());
@@ -205,7 +206,7 @@
public Set<String> listLoadedClasses()
{
- return Collections.unmodifiableSet(loadedClasses.keySet());
+ return Collections.unmodifiableSet(loadedClasses);
}
public Set<String> listLoadedResourceNames()
@@ -638,7 +639,7 @@
}
}, policy.getAccessControlContext());
- loadedClasses.put(name, name);
+ loadedClasses.add(name);
policy.classFound(new ClassFoundEvent(this, result));
return result;
@@ -680,7 +681,7 @@
}
// Is this resource blacklisted?
- if (blackList != null && blackList.containsKey(name))
+ if (blackList != null && blackList.contains(name))
{
if (trace)
log.trace(this + " resource is blacklisted " + name);
@@ -712,7 +713,7 @@
// Blacklist when not found
if (blackList != null && result == null)
- blackList.put(name, name);
+ blackList.add(name);
return result;
}
@@ -885,8 +886,14 @@
public Class<?> getCachedClass(String name)
{
- // TODO look in global and/or local cache
- return null;
+ try
+ {
+ return checkCacheAndBlackList(name, false, log.isTraceEnabled());
+ }
+ catch (ClassNotFoundException ignored)
+ {
+ return null;
+ }
}
public URL getCachedResource(String name)
@@ -897,7 +904,7 @@
public int getResourceBlackListSize()
{
- Map<String, String> blackList = this.blackList;
+ Set<String> blackList = this.blackList;
if (blackList == null)
return 0;
return blackList.size();
@@ -913,10 +920,10 @@
public Set<String> listResourceBlackList()
{
- Map<String, String> blackList = this.blackList;
+ Set<String> blackList = this.blackList;
if (blackList == null)
return Collections.emptySet();
- return Collections.unmodifiableSet(blackList.keySet());
+ return Collections.unmodifiableSet(blackList);
}
public Map<String, URL> listResourceCache()
@@ -931,7 +938,7 @@
{
if (blackList != null)
{
- for (String name : blackList.keySet())
+ for (String name : blackList)
clearBlackList(name);
}
}
More information about the jboss-cvs-commits
mailing list