[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...
Gavin King
gavin.king at jboss.com
Fri May 18 12:27:06 EDT 2007
User: gavin
Date: 07/05/18 12:27:06
Modified: src/main/org/jboss/seam Seam.java Component.java
Log:
JBSEAM-1332, fix NPE on hot redeploy
Revision Changes Path
1.29 +32 -2 jboss-seam/src/main/org/jboss/seam/Seam.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Seam.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Seam.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- Seam.java 8 May 2007 01:34:31 -0000 1.28
+++ Seam.java 18 May 2007 16:27:06 -0000 1.29
@@ -1,5 +1,6 @@
-//$Id: Seam.java,v 1.28 2007/05/08 01:34:31 sbryzak2 Exp $
+//$Id: Seam.java,v 1.29 2007/05/18 16:27:06 gavin Exp $
package org.jboss.seam;
+
import static org.jboss.seam.ComponentType.ENTITY_BEAN;
import static org.jboss.seam.ComponentType.JAVA_BEAN;
import static org.jboss.seam.ComponentType.MESSAGE_DRIVEN_BEAN;
@@ -9,7 +10,12 @@
import static org.jboss.seam.util.EJB.STATEFUL;
import static org.jboss.seam.util.EJB.STATELESS;
import static org.jboss.seam.util.EJB.name;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
import javax.persistence.Entity;
+
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
@@ -17,6 +23,7 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
import org.jboss.seam.util.Strings;
+
/**
* Convenience methods for accessing annotated information
* about Seam component classes.
@@ -27,6 +34,8 @@
{
private static final String SESSION_INVALID = "org.jboss.seam.sessionInvalid";
+ private static final Map<Class, String> COMPONENT_NAME_CACHE = new ConcurrentHashMap<Class, String>();
+
/**
* Get the default scope
* @see Scope
@@ -70,7 +79,8 @@
{
return ENTITY_BEAN;
}
- else {
+ else
+ {
return JAVA_BEAN;
}
}
@@ -81,6 +91,20 @@
*/
public static String getComponentName(Class<?> clazz)
{
+ String result = COMPONENT_NAME_CACHE.get(clazz);
+ if (result==null)
+ {
+ result = searchComponentName(clazz);
+ if (result!=null)
+ {
+ COMPONENT_NAME_CACHE.put(clazz, result);
+ }
+ }
+ return result;
+ }
+
+ public static String searchComponentName(Class<?> clazz)
+ {
while ( clazz!=null && !Object.class.equals(clazz) )
{
Name name = clazz.getAnnotation(Name.class);
@@ -229,9 +253,15 @@
}
}
}
+
public static String getVersion()
{
Package pkg = Seam.class.getPackage();
return (pkg != null ? pkg.getImplementationVersion() : null);
}
+
+ public static void clearComponentNameCache()
+ {
+ COMPONENT_NAME_CACHE.clear();
+ }
}
1.247 +1 -1 jboss-seam/src/main/org/jboss/seam/Component.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Component.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Component.java,v
retrieving revision 1.246
retrieving revision 1.247
diff -u -b -r1.246 -r1.247
More information about the jboss-cvs-commits
mailing list