[jboss-cvs] JBossAS SVN: r72868 - projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 29 12:26:54 EDT 2008
Author: alesj
Date: 2008-04-29 12:26:54 -0400 (Tue, 29 Apr 2008)
New Revision: 72868
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java
Log:
CL weak ref.
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2008-04-29 16:23:55 UTC (rev 72867)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2008-04-29 16:26:54 UTC (rev 72868)
@@ -23,6 +23,7 @@
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
+import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.Set;
import java.util.HashMap;
@@ -39,14 +40,15 @@
*/
public class DefaultAnnotationEnvironment implements AnnotationEnvironment
{
- private ClassLoader classLoader;
+ private WeakReference<ClassLoader> clRef;
private Map<Class<? extends Annotation>, Map<ElementType, Set<String>>> env;
public DefaultAnnotationEnvironment(ClassLoader classLoader)
{
if (classLoader == null)
throw new IllegalArgumentException("Null classloader");
- this.classLoader = classLoader;
+
+ this.clRef = new WeakReference<ClassLoader>(classLoader);
this.env = new HashMap<Class<? extends Annotation>, Map<ElementType, Set<String>>>();
}
@@ -100,6 +102,10 @@
*/
protected Set<Class<?>> transform(Set<String> classNames)
{
+ ClassLoader classLoader = clRef.get();
+ if (classLoader == null)
+ throw new IllegalArgumentException("ClassLoader was already garbage collected.");
+
try
{
Set<Class<?>> classes = new HashSet<Class<?>>(classNames.size());
More information about the jboss-cvs-commits
mailing list