1 22 package org.jboss.naming; 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.spi.ObjectFactory ; 30 31 import org.jboss.logging.Logger; 32 import org.jboss.util.id.GUID; 33 34 41 public class LinkRefPairObjectFactory implements ObjectFactory 42 { 43 45 46 private static final Logger log = Logger.getLogger(LinkRefPairObjectFactory.class); 47 48 49 static final String className = LinkRefPairObjectFactory.class.getName(); 50 51 52 static final String guid = new GUID().asString(); 53 54 56 58 60 62 64 public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception 65 { 66 LinkRefPair pair = (LinkRefPair) obj; 67 String jndiName; 68 69 boolean local = false; 71 if (guid.equals(pair.getGUID())) 72 { 73 jndiName = pair.getLocalLinkName(); 74 local = true; 75 } 76 else 77 jndiName = pair.getRemoteLinkName(); 78 79 InitialContext ctx; 80 if (local || environment == null) 81 ctx = new InitialContext (); 82 else 83 ctx = new InitialContext (environment); 84 85 return ctx.lookup(jndiName); 86 } 87 88 90 92 94 96 } 98 | Popular Tags |