[jboss-cvs] JBossAS SVN: r74345 - 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 Jun 10 05:19:43 EDT 2008
Author: alesj
Date: 2008-06-10 05:19:42 -0400 (Tue, 10 Jun 2008)
New Revision: 74345
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/WeakClassLoaderHolder.java
Log:
Make default ann env serializable.
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-06-10 08:50:57 UTC (rev 74344)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/DefaultAnnotationEnvironment.java 2008-06-10 09:19:42 UTC (rev 74345)
@@ -21,6 +21,7 @@
*/
package org.jboss.deployers.plugins.annotations;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.reflect.AccessibleObject;
@@ -44,20 +45,34 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class DefaultAnnotationEnvironment extends WeakClassLoaderHolder implements AnnotationEnvironment
+public class DefaultAnnotationEnvironment extends WeakClassLoaderHolder implements AnnotationEnvironment, Serializable
{
+ private static final long serialVersionUID = 1L;
/** The log */
private static final Logger log = Logger.getLogger(DefaultAnnotationEnvironment.class);
/** The info map */
- private Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> env;
+ private transient Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> env;
public DefaultAnnotationEnvironment(ClassLoader classLoader)
{
super(classLoader);
- this.env = new HashMap<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>>();
+ env = new HashMap<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>>();
}
/**
+ * Get env map.
+ *
+ * @return the env map
+ */
+ protected Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> getEnv()
+ {
+ if (env == null)
+ throw new IllegalArgumentException("Null env, previously serialized?");
+
+ return env;
+ }
+
+ /**
* Put the annotation info.
*
* @param annClass the annotation class
@@ -69,7 +84,9 @@
{
if (log.isTraceEnabled())
log.trace("Adding annotation @" + annClass.getSimpleName() + " for " + className + " at type " + type + ", signature: " + signature);
-
+
+ Map<Class<? extends Annotation>, Map<ElementType, Set<ClassSignaturePair>>> env = getEnv();
+
Map<ElementType, Set<ClassSignaturePair>> elements = env.get(annClass);
if (elements == null)
{
@@ -96,7 +113,7 @@
{
Set<ClassSignaturePair> pairs = null;
- Map<ElementType, Set<ClassSignaturePair>> elements = env.get(annClass);
+ Map<ElementType, Set<ClassSignaturePair>> elements = getEnv().get(annClass);
if (elements != null)
pairs = elements.get(type);
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java 2008-06-10 08:50:57 UTC (rev 74344)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/annotations/WeakClassLoaderHolder.java 2008-06-10 09:19:42 UTC (rev 74345)
@@ -30,7 +30,7 @@
*/
abstract class WeakClassLoaderHolder
{
- private WeakReference<ClassLoader> clRef;
+ private transient WeakReference<ClassLoader> clRef;
public WeakClassLoaderHolder(ClassLoader classLoader)
{
@@ -47,6 +47,9 @@
*/
protected ClassLoader getClassLoader()
{
+ if (clRef == null)
+ throw new IllegalArgumentException("Null classloader ref, previously serialized?");
+
ClassLoader classLoader = clRef.get();
if (classLoader == null)
throw new IllegalArgumentException("ClassLoader was already garbage collected.");
More information about the jboss-cvs-commits
mailing list