summaryrefslogtreecommitdiff
path: root/libjava/javax/naming
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-18 19:53:36 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2003-09-18 19:53:36 +0000
commit85257777061efc11b94090a613fdc00a3ae57825 (patch)
tree374fcddca39583f634e003edd0ae4b5225115a36 /libjava/javax/naming
parent8b2e817bb22232a517e385b2984dcdf5eb366518 (diff)
downloadgcc-85257777061efc11b94090a613fdc00a3ae57825.tar.gz
* javax/naming/InitialContext.java: Reindented.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71535 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/javax/naming')
-rw-r--r--libjava/javax/naming/InitialContext.java280
1 files changed, 143 insertions, 137 deletions
diff --git a/libjava/javax/naming/InitialContext.java b/libjava/javax/naming/InitialContext.java
index 62837ab9ee5..715f30ad5cd 100644
--- a/libjava/javax/naming/InitialContext.java
+++ b/libjava/javax/naming/InitialContext.java
@@ -1,5 +1,5 @@
/* InitialContext.java --
- Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,170 +57,176 @@ public class InitialContext implements Context
public InitialContext (Hashtable environment)
throws NamingException
- {
- init (environment);
- }
+ {
+ init (environment);
+ }
protected InitialContext (boolean lazy)
throws NamingException
- {
- if (! lazy)
- init (null);
- }
+ {
+ if (! lazy)
+ init (null);
+ }
public InitialContext ()
throws NamingException
- {
- init (null);
- }
+ {
+ init (null);
+ }
/** @since 1.3 */
protected void init (Hashtable environment)
throws NamingException
- {
- // FIXME: Is this enough?
- final String[] properties = {
- Context.DNS_URL,
- Context.INITIAL_CONTEXT_FACTORY,
- Context.OBJECT_FACTORIES,
- Context.PROVIDER_URL,
- Context.STATE_FACTORIES,
- Context.URL_PKG_PREFIXES,
- };
+ {
+ // FIXME: Is this enough?
+ final String[] properties = {
+ Context.DNS_URL,
+ Context.INITIAL_CONTEXT_FACTORY,
+ Context.OBJECT_FACTORIES,
+ Context.PROVIDER_URL,
+ Context.STATE_FACTORIES,
+ Context.URL_PKG_PREFIXES,
+ };
- // Create myProps, cloning environment if needed.
- if (environment != null)
- myProps = (Hashtable) environment.clone ();
- else
- myProps = new Hashtable ();
+ // Create myProps, cloning environment if needed.
+ if (environment != null)
+ myProps = (Hashtable) environment.clone ();
+ else
+ myProps = new Hashtable ();
- Applet napplet = (Applet) myProps.get (Context.APPLET);
+ Applet napplet = (Applet) myProps.get (Context.APPLET);
- for (int i = properties.length - 1; i >= 0; i--)
- {
- Object o = myProps.get (properties[i]);
+ for (int i = properties.length - 1; i >= 0; i--)
+ {
+ Object o = myProps.get (properties[i]);
- if (o == null)
- {
- if (napplet != null)
- o = napplet.getParameter (properties[i]);
- if (o == null)
- o = System.getProperty (properties[i]);
- if (o != null)
- myProps.put (properties[i], o);
- }
- }
-
- try
- {
- Enumeration ep = Thread.currentThread().getContextClassLoader().getResources("jndi.naming");
- while (ep.hasMoreElements ())
- {
- URL url = (URL) ep.nextElement ();
- Properties p = new Properties ();
+ if (o == null)
+ {
+ if (napplet != null)
+ o = napplet.getParameter (properties[i]);
+ if (o == null)
+ o = System.getProperty (properties[i]);
+ if (o != null)
+ myProps.put (properties[i], o);
+ }
+ }
+
+ try
+ {
+ Enumeration ep = Thread.currentThread().getContextClassLoader().getResources("jndi.naming");
+ while (ep.hasMoreElements ())
+ {
+ URL url = (URL) ep.nextElement ();
+ Properties p = new Properties ();
- try {
- InputStream is = url.openStream ();
- p.load (is);
- is.close ();
- } catch (IOException e) {}
-
- merge (myProps, p);
- }
- }
- catch (IOException e) {}
-
- String home = System.getProperty("gnu.classpath.home.url");
- if (home != null)
- {
- String url = home + "/jndi.properties";
- Properties p = new Properties ();
+ try
+ {
+ InputStream is = url.openStream ();
+ p.load (is);
+ is.close ();
+ }
+ catch (IOException e)
+ {
+ }
+
+ merge (myProps, p);
+ }
+ }
+ catch (IOException e)
+ {
+ }
+
+ String home = System.getProperty("gnu.classpath.home.url");
+ if (home != null)
+ {
+ String url = home + "/jndi.properties";
+ Properties p = new Properties ();
- try
- {
- InputStream is = new URL(url).openStream();
- p.load (is);
- is.close ();
- }
- catch (IOException e)
- {
- // Ignore.
- }
-
- merge (myProps, p);
- }
- }
+ try
+ {
+ InputStream is = new URL(url).openStream();
+ p.load (is);
+ is.close ();
+ }
+ catch (IOException e)
+ {
+ // Ignore.
+ }
+
+ merge (myProps, p);
+ }
+ }
// FIXME: Is this enough?
private static final String[] colon_list =
- {
- Context.OBJECT_FACTORIES,
- Context.URL_PKG_PREFIXES,
- Context.STATE_FACTORIES
- };
+ {
+ Context.OBJECT_FACTORIES,
+ Context.URL_PKG_PREFIXES,
+ Context.STATE_FACTORIES
+ };
private static void merge (Hashtable h1, Hashtable h2)
- {
- Enumeration e2 = h2.keys();
+ {
+ Enumeration e2 = h2.keys();
- while (e2.hasMoreElements())
- {
- String key2 = (String) e2.nextElement();
- Object value1 = h1.get(key2);
- if (value1 == null)
- h1.put(key2, h2.get(key2));
- else if (key2.compareTo(colon_list[0]) == 0
- || key2.compareTo(colon_list[1]) == 0
- || key2.compareTo(colon_list[2]) == 0
- || key2.compareTo(colon_list[3]) == 0)
- {
- String value2 = (String) h2.get(key2);
- h1.put(key2, (String) value1 + ":" + value2);
- }
- }
- }
+ while (e2.hasMoreElements())
+ {
+ String key2 = (String) e2.nextElement();
+ Object value1 = h1.get(key2);
+ if (value1 == null)
+ h1.put(key2, h2.get(key2));
+ else if (key2.compareTo(colon_list[0]) == 0
+ || key2.compareTo(colon_list[1]) == 0
+ || key2.compareTo(colon_list[2]) == 0
+ || key2.compareTo(colon_list[3]) == 0)
+ {
+ String value2 = (String) h2.get(key2);
+ h1.put(key2, (String) value1 + ":" + value2);
+ }
+ }
+ }
protected Context getDefaultInitCtx () throws NamingException
- {
- if (! gotDefault)
- {
- defaultInitCtx = NamingManager.getInitialContext (myProps);
- gotDefault = true;
- }
- return defaultInitCtx;
- }
+ {
+ if (! gotDefault)
+ {
+ defaultInitCtx = NamingManager.getInitialContext (myProps);
+ gotDefault = true;
+ }
+ return defaultInitCtx;
+ }
protected Context getURLOrDefaultInitCtx (Name name)
- throws NamingException
- {
- if (name.size () > 0)
- return getURLOrDefaultInitCtx (name.get (0));
- else
- return getDefaultInitCtx ();
- }
+ throws NamingException
+ {
+ if (name.size () > 0)
+ return getURLOrDefaultInitCtx (name.get (0));
+ else
+ return getDefaultInitCtx ();
+ }
protected Context getURLOrDefaultInitCtx (String name)
- throws NamingException
- {
- String scheme = null;
-
- if (NamingManager.hasInitialContextFactoryBuilder())
- return getDefaultInitCtx();
- int colon = name.indexOf(':');
- int slash = name.indexOf('/');
- if (colon > 0 && (slash == -1 || colon < slash))
- scheme = name.substring(0, colon);
- if (scheme != null)
- {
- Context context =
- NamingManager.getURLContext(scheme, myProps);
- if (context != null)
- return context;
- }
-
+ throws NamingException
+ {
+ String scheme = null;
+
+ if (NamingManager.hasInitialContextFactoryBuilder())
return getDefaultInitCtx();
- }
+ int colon = name.indexOf(':');
+ int slash = name.indexOf('/');
+ if (colon > 0 && (slash == -1 || colon < slash))
+ scheme = name.substring(0, colon);
+ if (scheme != null)
+ {
+ Context context =
+ NamingManager.getURLContext(scheme, myProps);
+ if (context != null)
+ return context;
+ }
+
+ return getDefaultInitCtx();
+ }
public void bind (Name name, Object obj) throws NamingException
{
@@ -338,13 +344,13 @@ public class InitialContext implements Context
}
public String composeName (String name,
- String prefix) throws NamingException
+ String prefix) throws NamingException
{
return getURLOrDefaultInitCtx (name).composeName (name, prefix);
}
public Object addToEnvironment (String propName,
- Object propVal) throws NamingException
+ Object propVal) throws NamingException
{
return myProps.put (propName, propVal);
}