1 22 package org.jboss.ejb3.naming.client.java; 23 24 import java.util.Hashtable ; 25 26 import javax.naming.Context ; 27 import javax.naming.InitialContext ; 28 import javax.naming.Name ; 29 import javax.naming.NameNotFoundException ; 30 import javax.naming.NameParser ; 31 import javax.naming.NamingException ; 32 import javax.naming.spi.ObjectFactory ; 33 34 import org.jboss.corba.ORBFactory; 35 import org.jboss.ejb3.naming.BrainlessContext; 36 import org.jboss.naming.client.java.HandleDelegateFactory; 37 38 44 public class javaURLContextFactory implements ObjectFactory 45 { 46 47 50 public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable <?, ?> environment) 51 throws Exception 52 { 53 if(nameCtx == null) 54 nameCtx = new InitialContext (environment); 55 final Context lookupCtx = nameCtx; 56 return new BrainlessContext() 57 { 58 @Override 59 public Object lookup(Name name) throws NamingException 60 { 61 if (name.size() > 0 && "java:comp".equals(name.get(0))) 62 { 63 if (name.size() == 2 && "ORB".equals(name.get(1))) 64 return ORBFactory.getORB(); 65 else if (name.size() == 2 && "HandleDelegate".equals(name.get(1))) 66 return HandleDelegateFactory.getHandleDelegateSingleton(); 67 } 68 throw new NameNotFoundException (name.toString()); 69 } 70 71 @Override 72 public Object lookup(String name) throws NamingException 73 { 74 NameParser parser = lookupCtx.getNameParser(""); 75 return lookup(parser.parse(name)); 76 } 77 }; 78 } 79 80 } 81 | Popular Tags |