Author: shane.bryzak(a)jboss.com
Date: 2008-05-24 20:26:51 -0400 (Sat, 24 May 2008)
New Revision: 8280
Modified:
trunk/src/main/org/jboss/seam/Seam.java
Log:
synchronize loading of cache
Modified: trunk/src/main/org/jboss/seam/Seam.java
===================================================================
--- trunk/src/main/org/jboss/seam/Seam.java 2008-05-25 00:25:09 UTC (rev 8279)
+++ trunk/src/main/org/jboss/seam/Seam.java 2008-05-25 00:26:51 UTC (rev 8280)
@@ -44,7 +44,7 @@
private static final Map<Class, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new
ConcurrentHashMap<Class, EjbDescriptor>();
private static final Set<ClassLoader> CLASSLOADERS_LOADED = new
HashSet<ClassLoader>();
- private static EjbDescriptor getEjbDescriptor(Class clazz)
+ public static EjbDescriptor getEjbDescriptor(Class clazz)
{
EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(clazz);
if (info != null)
@@ -54,14 +54,22 @@
else if (clazz.getClassLoader() == null ||
(clazz.getClassLoader() != null &&
!CLASSLOADERS_LOADED.contains(clazz.getClassLoader())))
{
+ cacheEjbDescriptors(clazz);
+ return EJB_DESCRIPTOR_CACHE.get(clazz);
+ }
+
+ return null;
+ }
+
+ private synchronized static void cacheEjbDescriptors(Class clazz)
+ {
+ if (!CLASSLOADERS_LOADED.contains(clazz.getClassLoader()))
+ {
Map<Class, EjbDescriptor> ejbDescriptors = new
DeploymentDescriptor(clazz).getEjbDescriptors();
EJB_DESCRIPTOR_CACHE.putAll(ejbDescriptors);
- CLASSLOADERS_LOADED.add(clazz.getClassLoader());
- return ejbDescriptors.get(clazz);
+ CLASSLOADERS_LOADED.add(clazz.getClassLoader());
}
-
- return null;
- }
+ }
/**
* Get the default scope