Author: shane.bryzak(a)jboss.com
Date: 2008-11-11 22:00:50 -0500 (Tue, 11 Nov 2008)
New Revision: 9556
Modified:
trunk/src/main/org/jboss/seam/util/Naming.java
Log:
JBSEAM-3485
Modified: trunk/src/main/org/jboss/seam/util/Naming.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Naming.java 2008-11-11 21:44:58 UTC (rev 9555)
+++ trunk/src/main/org/jboss/seam/util/Naming.java 2008-11-12 03:00:50 UTC (rev 9556)
@@ -16,13 +16,13 @@
public final class Naming
{
-
private static final LogProvider log = Logging.getLogProvider(Naming.class);
private static Hashtable initialContextProperties;
+
+ private static InitialContext initialContext;
public static InitialContext getInitialContext(Hashtable<String, String> props)
throws NamingException
{
-
if (props==null)
{
throw new IllegalStateException("JNDI properties not initialized, Seam
was not started correctly");
@@ -47,20 +47,30 @@
public static InitialContext getInitialContext() throws NamingException
{
- return getInitialContext(initialContextProperties);
+ if (initialContext == null) initInitialContext();
+
+ return initialContext;
}
+
+ private static synchronized void initInitialContext() throws NamingException
+ {
+ if (initialContext == null)
+ {
+ initialContext = getInitialContext(initialContextProperties);
+ }
+ }
private Naming() {}
public static void setInitialContextProperties(Hashtable initialContextProperties)
{
Naming.initialContextProperties = initialContextProperties;
+ initialContext = null;
}
public static Hashtable getInitialContextProperties()
{
return initialContextProperties;
}
-
}
Show replies by date