1 55 package org.lateralnz.panther.util; 56 57 58 import javax.naming.Context ; 59 import javax.naming.NameAlreadyBoundException ; 60 import javax.naming.NameNotFoundException ; 61 import javax.naming.NamingException ; 62 63 import org.lateralnz.common.util.Constants; 64 import org.lateralnz.panther.naming.LocalContext; 65 66 71 public class ContextUtils implements Constants { 72 73 private static final String JAVA = "java"; 74 private static final String ENV = "env"; 75 private static final String COMP = "comp"; 76 77 private static final String JAVA_COMP = JAVA + COLON + COMP; 78 private static final String JAVA_COMP_ENV = JAVA + COLON + COMP + FORWARD_SLASH + ENV; 79 80 private ContextUtils() { 81 } 82 83 88 public static final Context getCompEnv(Context ctx) throws NamingException { 89 try { 90 ctx.createSubcontext(JAVA_COMP); 91 } 92 catch (NameAlreadyBoundException nabe) { } 93 94 try { 95 ctx.createSubcontext(JAVA_COMP_ENV); 96 } 97 catch (NameAlreadyBoundException nabe) { } 98 99 return (Context )ctx.lookup(JAVA_COMP_ENV); 100 } 101 } | Popular Tags |