01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jndi;
09:
10: import java.util.Properties;
11: import java.util.Hashtable;
12: import javax.naming.Context;
13:
14: /**
15: *
16: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
17: */
18:
19: public class JNDIProperties {
20: private static Properties DEFAULT_ENVIRONMENT = new Properties();
21:
22: public final static String DEFAULT_HOST = "localhost";
23: public final static int DEFAULT_PORT = 1099;
24: public final static String DEFAULT_SCHEME = "java";
25: public final static String PROVIDER_URL = DEFAULT_SCHEME + "://"
26: + DEFAULT_HOST + ":" + DEFAULT_PORT;
27: public final static String URL_PKG_PREFIXES = "org.huihoo.jfox.jndi.url";
28: public final static String INITIAL_CONTEXT_FACTORY = "org.huihoo.jfox.jndi.InitialContextFactoryImpl";
29:
30: static {
31: DEFAULT_ENVIRONMENT.put(Context.INITIAL_CONTEXT_FACTORY,
32: INITIAL_CONTEXT_FACTORY);
33: DEFAULT_ENVIRONMENT.put(Context.PROVIDER_URL, PROVIDER_URL);
34: DEFAULT_ENVIRONMENT.put(Context.URL_PKG_PREFIXES,
35: URL_PKG_PREFIXES);
36: DEFAULT_ENVIRONMENT.put(Context.OBJECT_FACTORIES,
37: INITIAL_CONTEXT_FACTORY);
38: };
39:
40: public static Hashtable getDefaultEnvironment() {
41: return (Hashtable) DEFAULT_ENVIRONMENT.clone();
42: }
43:
44: /**
45: * merge env with the default environment
46: */
47: public static Hashtable mergeEnvironment(Hashtable env) {
48: Hashtable _env = getDefaultEnvironment();
49: _env.putAll(env);
50: return _env;
51: }
52:
53: public static Hashtable cloneEnvironment(Hashtable env) {
54: return (Hashtable) env.clone();
55: }
56: }
|