Search in sources :

Example 6 with CoreContainerSystem

use of org.apache.openejb.core.CoreContainerSystem in project tomee by apache.

the class HttpResponseImplSessionTest method start.

@Before
public void start() throws Exception {
    SystemInstance.get().setComponent(ContainerSystem.class, new CoreContainerSystem(new IvmJndiFactory()));
    server = new OpenEJBHttpEjbServer();
    server.init(new Properties());
    server.start();
}
Also used : IvmJndiFactory(org.apache.openejb.core.ivm.naming.IvmJndiFactory) CoreContainerSystem(org.apache.openejb.core.CoreContainerSystem) Properties(java.util.Properties) Before(org.junit.Before)

Example 7 with CoreContainerSystem

use of org.apache.openejb.core.CoreContainerSystem 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);
}
Also used : IvmContext(org.apache.openejb.core.ivm.naming.IvmContext) WebContext(org.apache.openejb.core.WebContext) AppContext(org.apache.openejb.AppContext) StandardRoot(org.apache.catalina.webresources.StandardRoot) IvmJndiFactory(org.apache.openejb.core.ivm.naming.IvmJndiFactory) TomEEWebappClassLoader(org.apache.tomee.catalina.TomEEWebappClassLoader) CoreContainerSystem(org.apache.openejb.core.CoreContainerSystem) WebAppEnricher(org.apache.openejb.classloader.WebAppEnricher) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) AppInfo(org.apache.openejb.assembler.classic.AppInfo) FacilitiesInfo(org.apache.openejb.assembler.classic.FacilitiesInfo) StandardContext(org.apache.catalina.core.StandardContext) TomEEWebappClassLoader(org.apache.tomee.catalina.TomEEWebappClassLoader) URLClassLoader(java.net.URLClassLoader) File(java.io.File) Before(org.junit.Before)

Aggregations

CoreContainerSystem (org.apache.openejb.core.CoreContainerSystem)7 Properties (java.util.Properties)4 NamingException (javax.naming.NamingException)4 HashSet (java.util.HashSet)3 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 InitialContext (javax.naming.InitialContext)2 NameNotFoundException (javax.naming.NameNotFoundException)2 ServletContext (javax.servlet.ServletContext)2 AppContext (org.apache.openejb.AppContext)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 WebContext (org.apache.openejb.core.WebContext)2 IvmJndiFactory (org.apache.openejb.core.ivm.naming.IvmJndiFactory)2 ContainerSystem (org.apache.openejb.spi.ContainerSystem)2 Before (org.junit.Before)2 File (java.io.File)1