View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 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  
25  import javax.naming.CompoundName;
26  import javax.naming.Context;
27  import javax.naming.Name;
28  import javax.naming.NameParser;
29  import javax.naming.NamingException;
30  
31  import org.eclipse.jetty.jndi.local.localContextRoot;
32  import org.eclipse.jetty.util.log.Logger;
33  
34  
35  /*------------------------------------------------*/
36  /**
37   * InitialContextFactory.java
38   *
39   * Factory for the default InitialContext.
40   * Created: Tue Jul  1 19:08:08 2003
41   *
42   *
43   * @version 1.0
44   */
45  public class InitialContextFactory implements javax.naming.spi.InitialContextFactory
46  {
47      private static Logger __log = NamingUtil.__log;
48  
49      public static class DefaultParser implements NameParser
50      {
51          static Properties syntax = new Properties();
52          static
53          {
54              syntax.put("jndi.syntax.direction", "left_to_right");
55              syntax.put("jndi.syntax.separator", "/");
56              syntax.put("jndi.syntax.ignorecase", "false");
57          }
58          public Name parse (String name)
59              throws NamingException
60          {
61              return new CompoundName (name, syntax);
62          }
63      };
64  
65  
66  
67      /*------------------------------------------------*/
68      /**
69       * Get Context that has access to default Namespace.
70       * This method won't be called if a name URL beginning
71       * with java: is passed to an InitialContext.
72       *
73       * @see org.eclipse.jetty.jndi.java.javaURLContextFactory
74       * @param env a <code>Hashtable</code> value
75       * @return a <code>Context</code> value
76       */
77      public Context getInitialContext(Hashtable env)
78      {
79          __log.debug("InitialContextFactory.getInitialContext()");
80  
81          Context ctx = new localContextRoot(env);
82          if(__log.isDebugEnabled())__log.debug("Created initial context delegate for local namespace:"+ctx);
83  
84          return ctx;
85      }
86  }