01: /*
02: * Copyright 2003-2006 Rick Knowles <winstone-devel at lists sourceforge net>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: */
07: package winstone.jndi.java;
08:
09: import java.util.Hashtable;
10:
11: import javax.naming.Context;
12: import javax.naming.Name;
13: import javax.naming.NamingException;
14: import javax.naming.spi.InitialContextFactory;
15: import javax.naming.spi.ObjectFactory;
16:
17: import winstone.jndi.WinstoneContext;
18:
19: /**
20: * Creates the initial instance of the Winstone JNDI context (corresponds to
21: * java:/ urls)
22: *
23: * @author <a href="mailto:rick_knowles@hotmail.com">Rick Knowles</a>
24: * @version $Id: javaURLContextFactory.java,v 1.5 2007/04/23 02:55:35 rickknowles Exp $
25: */
26: public class javaURLContextFactory implements InitialContextFactory,
27: ObjectFactory {
28:
29: private static WinstoneContext rootContext;
30: private Object lock = new Boolean(true);
31:
32: public Context getInitialContext(Hashtable env)
33: throws NamingException {
34: synchronized (lock) {
35: if (rootContext == null) {
36: Object lock = new Boolean(true);
37: rootContext = new WinstoneContext(env, null, "java:",
38: lock);
39: WinstoneContext compCtx = new WinstoneContext(env,
40: rootContext, "java:/comp", lock);
41: WinstoneContext envCtx = new WinstoneContext(env,
42: compCtx, "java:/comp/env", lock);
43: rootContext.rebind("java:/comp", compCtx);
44: compCtx.rebind("env", envCtx);
45: }
46: }
47: return (Context) rootContext.lookup("java:/comp/env");
48: }
49:
50: public Object getObjectInstance(Object object, Name name,
51: Context context, Hashtable env) {
52: return null;
53: }
54: }
|