String tmp = params[i];
// take parameter 1
// look up the name through InitialContext
RegistryContext ctx = new RegistryContext();
Object obj = null;
try {
obj = (Context) ctx.lookup(tmp);
} catch (Exception ex) {
if (canThrowEx()) {
throw new Exception("No object found in JNDI for name: " + tmp);
} else {
err.println("No object found in JNDI for name: " + tmp);
log.debug("CtxDelegateExe done.");
return;
}
}
// See if what you got is instance of Context
if (!(obj instanceof Context)) {
if (canThrowEx()) {
throw new Exception("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.ctx.Context type.");
} else {
err.println("Object found in JNDI for name: " + tmp + " is not org.jboss.fresh.ctx.Context type.");
log.debug("CtxDelegateExe done.");
return;
}
}
Context ctx0 = (Context) obj;
// now shell.getContext()
if(log.isDebugEnabled()) {
log.debug("shell: " + shell + ", ctx: " + shell.getContext());
}
shell.getContext().registerDelegate(ctx0);
shell.getContext().put("AppContext", ctx0);
Context gctx = null;
try {
tmp = "java:/FRESH/GlobalContext";
gctx = (Context) ctx.lookup(tmp);
} catch (Exception ex) {
if (canThrowEx()) {
throw new Exception("No object found in JNDI for name: " + tmp);
} else {
err.println("No object found in JNDI for name: " + tmp);