diff options
author | Anthony Green <green@redhat.com> | 2000-11-27 03:16:14 +0000 |
---|---|---|
committer | Anthony Green <green@gcc.gnu.org> | 2000-11-27 03:16:14 +0000 |
commit | 18205ca3b63fa0536ce6db35b4f1e264bdda5276 (patch) | |
tree | fddd25f01c276e915b483a1138befefd75ad4852 /libjava/javax/naming/spi/NamingManager.java | |
parent | 158227a66aac2270747de0be47f1026e6bb13782 (diff) | |
download | gcc-18205ca3b63fa0536ce6db35b4f1e264bdda5276.tar.gz |
Initial jndi check-in
From-SVN: r37770
Diffstat (limited to 'libjava/javax/naming/spi/NamingManager.java')
-rw-r--r-- | libjava/javax/naming/spi/NamingManager.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libjava/javax/naming/spi/NamingManager.java b/libjava/javax/naming/spi/NamingManager.java new file mode 100644 index 00000000000..9cb814e9e12 --- /dev/null +++ b/libjava/javax/naming/spi/NamingManager.java @@ -0,0 +1,57 @@ +/* Copyright (C) 2000 Free Software Foundation + + This file is part of libgcj. + + This software is copyrighted work licensed under the terms of the + Libgcj License. Please consult the file "LIBGCJ_LICENSE" for + details. */ + +package javax.naming.spi; + +import java.util.Hashtable; +import javax.naming.*; + +public class NamingManager +{ + private static InitialContextFactoryBuilder icfb = null; + + public static boolean hasInitialContextFactoryBuilder () + { + return icfb != null; + } + + public static Context getInitialContext (Hashtable environment) throws NamingException + { + InitialContextFactory icf = null; + + if (icfb != null) + icf = icfb.createInitialContextFactory(environment); + else + { + String java_naming_factory_initial = null; + if (environment != null) + java_naming_factory_initial + = (String) environment.get (Context.INITIAL_CONTEXT_FACTORY); + if (java_naming_factory_initial == null) + throw new NoInitialContextException ("Can't find property: " + Context.INITIAL_CONTEXT_FACTORY); + + try { + icf = (InitialContextFactory) Thread.currentThread().getContextClassLoader().loadClass(java_naming_factory_initial).newInstance(); + } catch (Exception exception) { + NoInitialContextException e + = new NoInitialContextException("Can't load InitialContextFactory class: " + java_naming_factory_initial); + e.setRootCause(exception); + throw e; + } + } + + return icf.getInitialContext (environment); + } + + public static Context getURLContext(String scheme, + Hashtable environment) + throws NamingException + { + throw new Error ("javax.naming.spi.NamingManager.getURLContext not implemented"); + } +} |