}
Context compCtx = (Context) compContext.get();
if (compCtx == null) {
// the component context was not set for this thread
throw new NameNotFoundException(name);
}
if ("comp".equals(name)) {
return compCtx;
} else if (name.startsWith("comp/")) {
return compCtx.lookup(name.substring(5));
} else if ("/comp".equals(name)) {
return compCtx;
} else if (name.startsWith("/comp/")) {
return compCtx.lookup(name.substring(6));
} else {
throw new NameNotFoundException("Unrecognized name, does not start with expected 'comp': " + name);
}
}
return super.lookup(name);
}