1 //
2 // ========================================================================
3 // Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.jndi;
20
21
22 import java.util.Hashtable;
23 import java.util.Properties;
24 import javax.naming.CompoundName;
25 import javax.naming.Context;
26 import javax.naming.Name;
27 import javax.naming.NameParser;
28 import javax.naming.NamingException;
29
30 import org.eclipse.jetty.jndi.local.localContextRoot;
31 import org.eclipse.jetty.util.log.Logger;
32
33
34 /*------------------------------------------------*/
35 /**
36 * InitialContextFactory.java
37 *
38 * Factory for the default InitialContext.
39 * Created: Tue Jul 1 19:08:08 2003
40 *
41 *
42 * @version 1.0
43 */
44 public class InitialContextFactory implements javax.naming.spi.InitialContextFactory
45 {
46 private static Logger __log = NamingUtil.__log;
47
48 public static class DefaultParser implements NameParser
49 {
50 static Properties syntax = new Properties();
51 static
52 {
53 syntax.put("jndi.syntax.direction", "left_to_right");
54 syntax.put("jndi.syntax.separator", "/");
55 syntax.put("jndi.syntax.ignorecase", "false");
56 }
57 public Name parse (String name)
58 throws NamingException
59 {
60 return new CompoundName (name, syntax);
61 }
62 };
63
64
65
66 /*------------------------------------------------*/
67 /**
68 * Get Context that has access to default Namespace.
69 * This method won't be called if a name URL beginning
70 * with java: is passed to an InitialContext.
71 *
72 * @see org.eclipse.jetty.jndi.java.javaURLContextFactory
73 * @param env a <code>Hashtable</code> value
74 * @return a <code>Context</code> value
75 */
76 public Context getInitialContext(Hashtable env)
77 {
78 __log.debug("InitialContextFactory.getInitialContext()");
79
80 Context ctx = new localContextRoot(env);
81 if(__log.isDebugEnabled())__log.debug("Created initial context delegate for local namespace:"+ctx);
82
83 return ctx;
84 }
85 }