- private static Context context;
-
- private static void initialize() {
- try {
- context = new StubInitialContext();
- } catch (NamingException e) { // can't happen.
- throw new RuntimeException(e);
- }
- }
-
- /**
- * This method must be called to register this initial context factory as
- * the default implementation for JNDI.
- *
- * @throws Exception
- */
- public static void register() {
- // sets up the InitialContextFactoryForTest as default factory.
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
- StubInitialContextFactory.class.getName());
- if (context == null) {
- initialize();
- }
- }
-
- /**
- * Unregisters the initial context factory
- */
- public static void unregister() {
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "");
- context = null;
- }
-
- public Context getInitialContext(Hashtable<?, ?> environment)
- throws NamingException {
- return context;
- }
+ private static Context CONTEXT;
+
+ private static void initialize() {
+ try {
+ CONTEXT = new StubInitialContext();
+ } catch (NamingException e) { // can't happen.
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * This method must be called to register this initial context factory as
+ * the default implementation for JNDI.
+ *
+ * @throws Exception
+ */
+ public static void register() {
+ // sets up the InitialContextFactoryForTest as default factory.
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+ StubInitialContextFactory.class.getName());
+ if (CONTEXT == null) {
+ initialize();
+ }
+ }
+
+ /**
+ * Unregisters the initial context factory
+ */
+ public static void unregister() {
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "");
+ CONTEXT = null;
+ }
+
+ public Context getInitialContext(Hashtable<?, ?> aEnvironment)
+ throws NamingException {
+ return CONTEXT;
+ }