View Javadoc

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