use of org.apache.tomee.catalina.TomEEWebappClassLoader in project tomee by apache.
the class ReloadingLoaderTest method initContext.
@Before
public void initContext() throws LifecycleException {
final OpenEjbConfiguration configuration = new OpenEjbConfiguration();
configuration.facilities = new FacilitiesInfo();
final CoreContainerSystem containerSystem = new CoreContainerSystem(new IvmJndiFactory());
SystemInstance.get().setComponent(OpenEjbConfiguration.class, configuration);
SystemInstance.get().setComponent(ContainerSystem.class, containerSystem);
SystemInstance.get().setComponent(WebAppEnricher.class, new WebAppEnricher() {
@Override
public URL[] enrichment(final ClassLoader webappClassLaoder) {
return new URL[0];
}
});
parentInstance = new AtomicReference<>(ParentClassLoaderFinder.Helper.get());
loader = new TomEEWebappClassLoader(parentInstance.get()) {
@Override
public ClassLoader getInternalParent() {
return parentInstance.get();
}
@Override
protected void clearReferences() {
// no-op: this test should be reworked to support it but in real life a loader is not stopped/started
}
};
loader.init();
final StandardRoot resources = new StandardRoot();
loader.setResources(resources);
resources.setContext(new StandardContext() {
@Override
public String getDocBase() {
final File file = new File("target/foo");
file.mkdirs();
return file.getAbsolutePath();
}
@Override
public String getMBeanKeyProperties() {
return "foo";
}
{
}
});
resources.start();
loader.start();
info = new AppInfo();
info.appId = "test";
context = new AppContext(info.appId, SystemInstance.get(), loader, new IvmContext(), new IvmContext(), true);
containerSystem.addAppContext(context);
final WebContext webDeployment = new WebContext(context);
webDeployment.setId(context.getId());
webDeployment.setClassLoader(loader);
containerSystem.addWebContext(webDeployment);
}
Aggregations