Search in sources :

Example 16 with IvmContext

use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.

the class IvmContextTest method testBindFromCurrentContextSetsTheCorrectParent_lookupRelativeToTheCurrentNode.

@Test
public void testBindFromCurrentContextSetsTheCorrectParent_lookupRelativeToTheCurrentNode() throws Exception {
    final IvmContext root = IvmContext.createRootContext();
    root.bind("a/b/c", null);
    IvmContext a = (IvmContext) root.lookup("a");
    a.bind("object", null);
    requireCorrectParentChildRelationship(a, (IvmContext) a.lookup("object"));
    IvmContext b = (IvmContext) a.lookup("b");
    b.bind("object", null);
    requireCorrectParentChildRelationship(b, (IvmContext) b.lookup("object"));
}
Also used : IvmContext(org.apache.openejb.core.ivm.naming.IvmContext) Test(org.junit.Test)

Example 17 with IvmContext

use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.

the class AppNamingReadOnlyTest method getMockBeanContextsList.

private List<BeanContext> getMockBeanContextsList() throws SystemException, URISyntaxException {
    IvmContext context = new IvmContext();
    AppContext mockAppContext = new AppContext("appId", SystemInstance.get(), this.getClass().getClassLoader(), context, context, false);
    ModuleContext mockModuleContext = new ModuleContext("moduleId", new URI(""), "uniqueId", mockAppContext, context, this.getClass().getClassLoader());
    BeanContext mockBeanContext = new BeanContext("test", context, mockModuleContext, this.getClass(), this.getClass(), new HashMap<>());
    List<BeanContext> beanContextsList = new ArrayList<>();
    beanContextsList.add(mockBeanContext);
    return beanContextsList;
}
Also used : BeanContext(org.apache.openejb.BeanContext) IvmContext(org.apache.openejb.core.ivm.naming.IvmContext) AppContext(org.apache.openejb.AppContext) ModuleContext(org.apache.openejb.ModuleContext) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 18 with IvmContext

use of org.apache.openejb.core.ivm.naming.IvmContext in project tomee by apache.

the class LocalClientRunner method createDeployment.

private BeanContext createDeployment(final Class<?> testClass) {
    try {
        final AppContext appContext = new AppContext("", SystemInstance.get(), testClass.getClassLoader(), new IvmContext(), new IvmContext(), false);
        final ModuleContext moduleContext = new ModuleContext("", null, "", appContext, new IvmContext(), null);
        return new BeanContext(null, new IvmContext(), moduleContext, testClass, null, null, null, null, null, null, null, null, null, BeanType.MANAGED, false, false);
    } catch (final SystemException e) {
        throw new IllegalStateException(e);
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) IvmContext(org.apache.openejb.core.ivm.naming.IvmContext) SystemException(org.apache.openejb.SystemException) AppContext(org.apache.openejb.AppContext) ModuleContext(org.apache.openejb.ModuleContext)

Example 19 with IvmContext

use of org.apache.openejb.core.ivm.naming.IvmContext 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

IvmContext (org.apache.openejb.core.ivm.naming.IvmContext)19 Test (org.junit.Test)13 AppContext (org.apache.openejb.AppContext)4 BeanContext (org.apache.openejb.BeanContext)3 ArrayList (java.util.ArrayList)2 ModuleContext (org.apache.openejb.ModuleContext)2 WebContext (org.apache.openejb.core.WebContext)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 IOException (java.io.IOException)1 InvalidObjectException (java.io.InvalidObjectException)1 ObjectStreamException (java.io.ObjectStreamException)1 PrintWriter (java.io.PrintWriter)1 Method (java.lang.reflect.Method)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URLClassLoader (java.net.URLClassLoader)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1