Package org.apache.openejb

Examples of org.apache.openejb.ModuleContext


    @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

            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

    }

    //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(final BeanContext cdi, final Class intrface, final Reference ref, final Bindings bindings, final EnterpriseBeanInfo beanInfo) throws NamingException {
        final ModuleContext module = cdi.getModuleContext();
        final AppContext application = module.getAppContext();

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

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

        assertContexts(containerSystem);
    }

    private void assertContexts(final 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

        assertContexts(containerSystem);
    }

    private void assertContexts(final 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

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

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

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

        final MethodScheduleBuilder methodScheduleBuilder = new MethodScheduleBuilder();

        for (final EnterpriseBeanInfo ejbInfo : ejbJar.enterpriseBeans) {
            final ClassLoader loader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(moduleContext.getClassLoader());
            try {
                final EnterpriseBeanBuilder deploymentBuilder = new EnterpriseBeanBuilder(ejbInfo, moduleContext, moduleInjections);
                final BeanContext bean = deploymentBuilder.build();

                interceptorBindingBuilder.build(bean, ejbInfo);
View Full Code Here

        SystemInstance.get().getProperties().put("openejb.fooApp.color", "blue");
    }

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

        { // Assert as Properties

            // AppContext should have color property
            assertProperty(appContext.getProperties(), "color", "orange");

            // BeanContext and ModuleContext should not
            assertNoProperty(beanContext.getProperties(), "color");
            assertNoProperty(moduleContext.getProperties(), "color");

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

        { // Assert as Options

            // AppContext should have color option
            assertOption(appContext.getOptions(), "color", "orange");

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

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

    public void contextEntered(final ThreadContext oldContext, final ThreadContext newContext) {
        final BeanContext beanContext = newContext.getBeanContext();
        if (beanContext == null) { // OWBContextHolder will be null so calling contextExited will throw a NPE
            return;
        }
        final 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
        final AppContext appContext = moduleContext.getAppContext();
        final WebBeansContext owbContext = appContext.getWebBeansContext();
        final Object oldOWBContext;
        if (owbContext != null) {
            oldOWBContext = singletonService.contextEntered(owbContext);
        } else {
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.