1 28 29 package com.caucho.config.types; 30 31 import com.caucho.config.NodeBuilder; 32 import com.caucho.config.TypeStrategy; 33 34 import org.w3c.dom.Node ; 35 36 import javax.naming.InitialContext ; 37 38 41 public class JndiTypeStrategy extends TypeStrategy { 42 49 public Object configure(NodeBuilder builder, Node node, Object parent) 50 throws Exception 51 { 52 Object jndiObject = builder.configureObject(node, parent); 53 54 if (! (jndiObject instanceof String )) 55 return jndiObject; 56 57 String jndiPath = (String ) jndiObject; 58 59 if (jndiPath.startsWith("java:comp/")) 60 return new InitialContext ().lookup(jndiPath); 61 else 62 return new InitialContext ().lookup("java:comp/env/" + jndiPath); 63 } 64 } 65 | Popular Tags |