use of org.apache.openejb.core.ivm.ContextHandler in project tomee by apache.
the class javaURLContextFactory method getContext.
public static Context getContext() {
final ThreadContext callContext = ThreadContext.getThreadContext();
if (callContext == null) {
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final ClassLoader current = Thread.currentThread().getContextClassLoader();
final Context globalContext = containerSystem.getJNDIContext();
if (current == null) {
return globalContext;
}
for (final AppContext appContext : containerSystem.getAppContexts()) {
for (final WebContext web : appContext.getWebContexts()) {
// more specific first
if (current.equals(web.getClassLoader())) {
return new ContextHandler(web.getJndiEnc());
}
}
if (current.equals(appContext.getClassLoader())) {
return new ContextHandler(appContext.getAppJndiContext());
}
}
return globalContext;
}
final BeanContext di = callContext.getBeanContext();
if (di != null) {
return di.getJndiEnc();
} else {
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
return containerSystem.getJNDIContext();
}
}
Aggregations