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.Log; 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 public static class DefaultParser implements NameParser 43 { 44 static Properties syntax = new Properties(); 45 static 46 { 47 syntax.put("jndi.syntax.direction", "left_to_right"); 48 syntax.put("jndi.syntax.separator", "/"); 49 syntax.put("jndi.syntax.ignorecase", "false"); 50 } 51 public Name parse (String name) 52 throws NamingException 53 { 54 return new CompoundName (name, syntax); 55 } 56 }; 57 58 59 60 /*------------------------------------------------*/ 61 /** 62 * Get Context that has access to default Namespace. 63 * This method won't be called if a name URL beginning 64 * with java: is passed to an InitialContext. 65 * 66 * @see org.eclipse.jetty.jndi.java.javaURLContextFactory 67 * @param env a <code>Hashtable</code> value 68 * @return a <code>Context</code> value 69 */ 70 public Context getInitialContext(Hashtable env) 71 { 72 Log.debug("InitialContextFactory.getInitialContext()"); 73 74 Context ctx = new localContextRoot(env); 75 if(Log.isDebugEnabled())Log.debug("Created initial context delegate for local namespace:"+ctx); 76 77 return ctx; 78 } 79 }