Author: shane.bryzak(a)jboss.com
Date: 2008-05-24 20:24:20 -0400 (Sat, 24 May 2008)
New Revision: 8278
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
Log:
synchronized loading of cache
Modified: branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-24 10:09:54 UTC (rev
8277)
+++ branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-25 00:24:20 UTC (rev
8278)
@@ -41,7 +41,7 @@
private static final Map<Class, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new
ConcurrentHashMap<Class, EjbDescriptor>();
private static final Set<ClassLoader> CLASSLOADERS_LOADED = new
HashSet<ClassLoader>();
- static EjbDescriptor getEjbDescriptor(Class clazz)
+ private static EjbDescriptor getEjbDescriptor(Class clazz)
{
EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(clazz);
if (info != null)
@@ -51,14 +51,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