01: // ========================================================================
02: // $Id: InitialContextFactory.java 1327 2006-11-27 18:40:14Z janb $
03: // Copyright 1999-2006 Mort Bay Consulting Pty. Ltd.
04: // ------------------------------------------------------------------------
05: // Licensed under the Apache License, Version 2.0 (the "License");
06: // you may not use this file except in compliance with the License.
07: // You may obtain a copy of the License at
08: // http://www.apache.org/licenses/LICENSE-2.0
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14: // ========================================================================
15:
16: package org.mortbay.naming;
17:
18: import java.util.Hashtable;
19: import java.util.Properties;
20:
21: import javax.naming.CompoundName;
22: import javax.naming.Context;
23: import javax.naming.Name;
24: import javax.naming.NameParser;
25: import javax.naming.NamingException;
26:
27: import org.mortbay.log.Log;
28: import org.mortbay.naming.local.localContextRoot;
29:
30: /*------------------------------------------------*/
31: /**
32: * InitialContextFactory.java
33: *
34: * Factory for the default InitialContext.
35: * Created: Tue Jul 1 19:08:08 2003
36: *
37: * @author <a href="mailto:janb@mortbay.com">Jan Bartel</a>
38: * @version 1.0
39: */
40: public class InitialContextFactory implements
41: javax.naming.spi.InitialContextFactory {
42: public static class DefaultParser implements NameParser {
43: static Properties syntax = new Properties();
44: static {
45: syntax.put("jndi.syntax.direction", "left_to_right");
46: syntax.put("jndi.syntax.separator", "/");
47: syntax.put("jndi.syntax.ignorecase", "false");
48: }
49:
50: public Name parse(String name) throws NamingException {
51: return new CompoundName(name, syntax);
52: }
53: };
54:
55: /*------------------------------------------------*/
56: /**
57: * Get Context that has access to default Namespace.
58: * This method won't be called if a name URL beginning
59: * with java: is passed to an InitialContext.
60: *
61: * @see org.mortbay.naming.java.javaURLContextFactory
62: * @param env a <code>Hashtable</code> value
63: * @return a <code>Context</code> value
64: */
65: public Context getInitialContext(Hashtable env) {
66: Log.debug("InitialContextFactory.getInitialContext()");
67:
68: Context ctx = new localContextRoot(env);
69: if (Log.isDebugEnabled())
70: Log
71: .debug("Created initial context delegate for local namespace:"
72: + ctx);
73:
74: return ctx;
75: }
76: }
|