Package org.apache.openejb

Examples of org.apache.openejb.ModuleContext


        assertContexts(containerSystem);
    }

    private void assertContexts(ContainerSystem containerSystem) {
        final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
        final ModuleContext moduleContext = beanContext.getModuleContext();
        final AppContext appContext = moduleContext.getAppContext();

        { // Assert as Properties

            // ModuleContext should have color property
            assertProperty(moduleContext.getProperties(), "color", "orange");

            // BeanContext and AppContext should not
            assertNoProperty(beanContext.getProperties(), "color");
            assertNoProperty(appContext.getProperties(), "color");

            // Try all the above again with mixed case
            assertProperty(moduleContext.getProperties(), "coLOr", "orange");
            assertNoProperty(beanContext.getProperties(), "coLOr");
            assertNoProperty(appContext.getProperties(), "coLOr");
        }

        { // Assert as Options

            // ModuleContext should have color option
            assertOption(moduleContext.getOptions(), "color", "orange");

            // BeanContext should inherit ModuleContext color
            assertOption(beanContext.getOptions(), "color", "orange");

            // AppContext should remain unpolluted
            assertNoOption(appContext.getOptions(), "color");

            // Try all the above again using mixed case
            assertOption(moduleContext.getOptions(), "coLoR", "orange");
            assertOption(beanContext.getOptions(), "coLoR", "orange");
            assertNoOption(appContext.getOptions(), "coLoR");
        }
    }
View Full Code Here


    @Before
    public void setUp() throws SystemException {
        method = Method.class.getMethods()[0];
        beanContext = new BeanContext("aDeploymentId",
                                      null,
                                      new ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null, null, null, false), null, null),
                                      DeploymentIndexTest.class,
                                      null,
                                      null,
                                      null,
                                      null,
View Full Code Here

        request = (ClusterableRequest) mock(ClusterableRequest.class);
        response = (ClusterableResponse) mock(ClusterableResponse.class);
        clusteredContainer = (ClusteredRPCContainer) mock(ClusteredRPCContainer.class);
        beanContext = new BeanContext("aDeploymentId",
                                      null,
                                      new ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null, null, null, false), null, null),
                                      BasicClusterableRequestHandlerTest.class,
                                      null,
                                      null,
                                      null,
                                      null,
View Full Code Here

    @Override
    public void contextEntered(ThreadContext oldContext, ThreadContext newContext) {
        BeanContext beanContext = newContext.getBeanContext();
        if (beanContext == null) return;
        ModuleContext moduleContext = beanContext.getModuleContext();
        //TODO its not clear what the scope for one of these context should be: ejb, module, or app
        //For now, go with the attachment of the BeanManager to AppContext
        AppContext appContext = moduleContext.getAppContext();
        WebBeansContext owbContext = appContext.getWebBeansContext();
        if (owbContext == null) {
//            throw new IllegalStateException("WebBeansContext not initialized in appContext " + appContext);
            return;
        }
View Full Code Here

        Context moduleJndiContext = new JndiEncBuilder(ejbJar.moduleJndiEnc, moduleInjections, null, ejbJar.moduleName, ejbJar.moduleUri, ejbJar.uniqueId, classLoader)
            .build(JndiEncBuilder.JndiScope.module);

        HashMap<String, BeanContext> deployments = new HashMap<String, BeanContext>();

        ModuleContext moduleContext = new ModuleContext(ejbJar.moduleName, ejbJar.moduleUri, ejbJar.uniqueId, context, moduleJndiContext, classLoader);
        moduleContext.getProperties().putAll(ejbJar.properties);
        InterceptorBindingBuilder interceptorBindingBuilder = new InterceptorBindingBuilder(classLoader, ejbJar);

        MethodScheduleBuilder methodScheduleBuilder = new MethodScheduleBuilder();
       
        for (EnterpriseBeanInfo ejbInfo : ejbJar.enterpriseBeans) {
View Full Code Here

    }

    //ee6 specified ejb bindings in module, app, and global contexts

    private String computeGlobalName(final BeanContext cdi, final Class<?> intrface) {
        final ModuleContext module = cdi.getModuleContext();
        final AppContext application = module.getAppContext();

        final String appName = application.isStandaloneModule() ? "" : application.getId() + "/";
        final String moduleName = cdi.getModuleName() + "/";
        String beanName = cdi.getEjbName();
        if (intrface != null) {
View Full Code Here

        return "global/" + appName + moduleName + beanName;
    }

    private void bindJava(BeanContext cdi, Class intrface, Reference ref, Bindings bindings, EnterpriseBeanInfo beanInfo) throws NamingException {
        final ModuleContext module = cdi.getModuleContext();
        final AppContext application = module.getAppContext();

        Context moduleContext = module.getModuleJndiContext();
        Context appContext = application.getAppJndiContext();
        Context globalContext = application.getGlobalJndiContext();

        String appName = application.isStandaloneModule() ? "" : application.getId() + "/";
        String moduleName = cdi.getModuleName() + "/";
View Full Code Here

        assertContexts(containerSystem);
    }

    private void assertContexts(ContainerSystem containerSystem) {
        final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
        final ModuleContext moduleContext = beanContext.getModuleContext();
        final AppContext appContext = moduleContext.getAppContext();

        { // Assert as Properties

            // BeanContext should have color property
            assertProperty(beanContext.getProperties(), "color", "orange");

            // ModuleContext and AppContext should not
            assertNoProperty(moduleContext.getProperties(), "color");
            assertNoProperty(appContext.getProperties(), "color");

            // Try all the above again with mixed case
            assertProperty(beanContext.getProperties(), "coLOr", "orange");
            assertNoProperty(moduleContext.getProperties(), "coLOr");
            assertNoProperty(appContext.getProperties(), "coLOr");
        }

        { // Assert as Options

            // ModuleContext should have color option
            assertOption(beanContext.getOptions(), "color", "orange");

            // AppContext and ModuleContext should remain unpolluted
            assertNoOption(moduleContext.getOptions(), "color");
            assertNoOption(appContext.getOptions(), "color");

            // Try all the above again using mixed case
            assertOption(beanContext.getOptions(), "coLoR", "orange");
            assertNoOption(moduleContext.getOptions(), "coLoR");
            assertNoOption(appContext.getOptions(), "coLoR");
        }
    }
View Full Code Here

            final Iterator<BeanContext> it = deployments.values().iterator();
            if (!it.hasNext()) return;

            // TODO we should just pass in the ModuleContext
            final ModuleContext moduleContext = it.next().getModuleContext();

            appContext = new HashMap<String, String>();
            putAll(appContext, SystemInstance.get().getProperties());
            putAll(appContext, moduleContext.getAppContext().getProperties());
            putAll(appContext, moduleContext.getProperties());

            appContext.put("appName", moduleContext.getAppContext().getId());
            appContext.put("appId", moduleContext.getAppContext().getId());

            appContext.put("moduleName", moduleContext.getId());
            appContext.put("moduleId", moduleContext.getId());
        }
View Full Code Here

    }

    @Test
    public void testRollback() throws Exception {
        SystemInstance.init(new Properties());
        BeanContext cdi = new BeanContext("foo", null, new ModuleContext("foo",null, "bar", new AppContext("foo", SystemInstance.get(), null, null, null, false), null, null), Object.class, null, new HashMap<String, String>());
        cdi.addApplicationException(AE1.class, true, true);
        cdi.addApplicationException(AE3.class, true, false);
        cdi.addApplicationException(AE6.class, false, true);

        assertEquals(ExceptionType.APPLICATION_ROLLBACK, cdi.getExceptionType(new AE1()));
View Full Code Here

TOP

Related Classes of org.apache.openejb.ModuleContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.