1 16 17 package org.apache.naming.modules.fs; 18 19 import java.util.Hashtable ; 20 21 import javax.naming.Context ; 22 import javax.naming.Name ; 23 import javax.naming.NamingException ; 24 import javax.naming.spi.InitialContextFactory ; 25 import javax.naming.spi.ObjectFactory ; 26 28 44 45 public class fsURLContextFactory implements ObjectFactory ,InitialContextFactory 46 { 47 private static org.apache.commons.logging.Log log= 48 org.apache.commons.logging.LogFactory.getLog( fsURLContextFactory.class ); 49 52 protected static Context initialContext = null; 53 54 55 57 60 public Object getObjectInstance(Object obj, Name name, Context nameCtx, 61 Hashtable environment) 62 throws NamingException { 63 if( log.isDebugEnabled() ) log.debug( "getObjectInstance " + obj + " " + name + " " + nameCtx + " " + environment); 65 66 FileDirContext fc= new FileDirContext(environment); 67 fc.setDocBase( "/" ); 68 fc.setURLPrefix("fs:"); 69 return fc; 70 } 71 72 73 76 public Context getInitialContext(Hashtable environment) 77 throws NamingException 78 { 79 if (initialContext == null) { 81 FileDirContext fc= new FileDirContext(environment); 82 fc.setDocBase( "/" ); 83 fc.setURLPrefix("fs:"); 84 initialContext=fc; 85 if( log.isDebugEnabled() ) 86 log.debug("Create initial fs context "+ environment); 87 } 88 return initialContext; 89 } 90 } 91 92 | Popular Tags |