1 // ======================================================================== 2 // $Id: InitialContextFactory.java 1327 2006-11-27 18:40:14Z janb $ 3 // Copyright 1999-2006 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 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 19 import java.util.Hashtable; 20 import java.util.Properties; 21 22 import javax.naming.CompoundName; 23 import javax.naming.Context; 24 import javax.naming.Name; 25 import javax.naming.NameParser; 26 import javax.naming.NamingException; 27 28 import org.mortbay.log.Log; 29 import org.mortbay.naming.local.localContextRoot; 30 31 32 /*------------------------------------------------*/ 33 /** 34 * InitialContextFactory.java 35 * 36 * Factory for the default InitialContext. 37 * Created: Tue Jul 1 19:08:08 2003 38 * 39 * @author <a href="mailto:janb@mortbay.com">Jan Bartel</a> 40 * @version 1.0 41 */ 42 public class InitialContextFactory implements javax.naming.spi.InitialContextFactory 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.mortbay.naming.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 }