Search in sources :

Example 11 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class MergeWebappJndiContext method merge.

private void merge(final EjbModule ejbModule, final WebModule webModule) {
    final JndiConsumer webApp = webModule.getWebApp();
    final EjbJar ejbJar = ejbModule.getEjbJar();
    for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
        merge(bean.getEnvEntryMap(), webApp.getEnvEntryMap());
        merge(bean.getEjbRefMap(), webApp.getEjbRefMap());
        merge(bean.getEjbLocalRefMap(), webApp.getEjbLocalRefMap());
        merge(bean.getServiceRefMap(), webApp.getServiceRefMap());
        merge(bean.getResourceRefMap(), webApp.getResourceRefMap());
        merge(bean.getResourceEnvRefMap(), webApp.getResourceEnvRefMap());
        merge(bean.getMessageDestinationRefMap(), webApp.getMessageDestinationRefMap());
        merge(bean.getPersistenceContextRefMap(), webApp.getPersistenceContextRefMap());
        merge(bean.getPersistenceUnitRefMap(), webApp.getPersistenceUnitRefMap());
        mergeUserTransaction(bean.getResourceRefMap(), webApp.getResourceRefMap(), webApp);
        mergeUserTransaction(bean.getResourceEnvRefMap(), webApp.getResourceEnvRefMap(), webApp);
        mergeUserTransaction(webApp.getResourceRefMap(), bean.getResourceRefMap(), bean);
        mergeUserTransaction(webApp.getResourceEnvRefMap(), bean.getResourceEnvRefMap(), bean);
    }
    // easy way to get a JndiConsumer
    final SessionBean aggregator = new SessionBean();
    for (final EnterpriseBean a : ejbJar.getEnterpriseBeans()) {
        aggregator.getEnvEntryMap().putAll(a.getEnvEntryMap());
        aggregator.getEjbRefMap().putAll(a.getEjbRefMap());
        aggregator.getEjbLocalRefMap().putAll(a.getEjbLocalRefMap());
        aggregator.getServiceRefMap().putAll(a.getServiceRefMap());
        aggregator.getResourceRefMap().putAll(a.getResourceRefMap());
        aggregator.getResourceEnvRefMap().putAll(a.getResourceEnvRefMap());
        aggregator.getMessageDestinationRefMap().putAll(a.getMessageDestinationRefMap());
        aggregator.getPersistenceContextRefMap().putAll(a.getPersistenceContextRefMap());
        aggregator.getPersistenceUnitRefMap().putAll(a.getPersistenceUnitRefMap());
    }
    for (final EnterpriseBean a : ejbJar.getEnterpriseBeans()) {
        copy(aggregator.getEnvEntryMap(), a.getEnvEntryMap());
        copy(aggregator.getEjbRefMap(), a.getEjbRefMap());
        copy(aggregator.getEjbLocalRefMap(), a.getEjbLocalRefMap());
        copy(aggregator.getServiceRefMap(), a.getServiceRefMap());
        copy(aggregator.getResourceRefMap(), a.getResourceRefMap());
        copy(aggregator.getResourceEnvRefMap(), a.getResourceEnvRefMap());
        copy(aggregator.getMessageDestinationRefMap(), a.getMessageDestinationRefMap());
        copy(aggregator.getPersistenceContextRefMap(), a.getPersistenceContextRefMap());
        copy(aggregator.getPersistenceUnitRefMap(), a.getPersistenceUnitRefMap());
        mergeUserTransaction(aggregator.getResourceRefMap(), a.getResourceRefMap(), a);
        mergeUserTransaction(aggregator.getResourceEnvRefMap(), a.getResourceEnvRefMap(), a);
    }
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) JndiConsumer(org.apache.openejb.jee.JndiConsumer) SessionBean(org.apache.openejb.jee.SessionBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 12 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class EjbRefTest method ear.

private void ear(final EjbJar... ejbJars) throws OpenEJBException, NamingException, IOException {
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "classpath-" + ejbJars.hashCode());
    for (final EjbJar ejbJar : ejbJars) {
        app.getEjbModules().add(new EjbModule(ejbJar));
    }
    assembler.createApplication(config.configureApplication(app));
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar)

Example 13 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class ResourcePropertyLeakTest method application.

@Module
public AppModule application() {
    final EjbModule ejbModule = new EjbModule(new EjbJar());
    final AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), null);
    appModule.getEjbModules().add(ejbModule);
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) AppModule(org.apache.openejb.config.AppModule) Module(org.apache.openejb.testing.Module)

Example 14 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class ResourcesJsonTest method setUp.

@Before
public void setUp() throws OpenEJBException, NamingException, IOException {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final AppModule app = new AppModule(ResourcesJsonTest.class.getClassLoader(), ResourcesJsonTest.class.getSimpleName());
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(ConfiguredThroughJSonBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    app.getEjbModules().iterator().next().getAltDDs().put("resources.json", getClass().getClassLoader().getResource("appresource.resources.json"));
    assembler.createApplication(config.configureApplication(app));
    final Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    properties.setProperty("openejb.embedded.initialcontext.close", "destroy");
    // some hack to be sure to call destroy()
    context = new InitialContext(properties);
    bean = (ConfiguredThroughJSonBean) context.lookup("ConfiguredThroughJSonBeanLocalBean");
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) Properties(java.util.Properties) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) InitialContext(javax.naming.InitialContext) SingletonBean(org.apache.openejb.jee.SingletonBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar) Before(org.junit.Before)

Example 15 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class DeploymentContextOptionsTest method testAppContextOptions.

public void testAppContextOptions() throws Exception {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    {
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    }
    {
        // Setup the descriptor information
        final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        final EjbJar ejbJar = ejbModule.getEjbJar();
        ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        final AppModule appModule = new AppModule(ejbModule);
        appModule.getProperties().setProperty("color", "orange");
        assembler.createApplication(config.configureApplication(appModule));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
    assertOption(beanContext.getOptions(), "color", "orange");
    assertOption(beanContext.getModuleContext().getOptions(), "color", "orange");
    assertOption(beanContext.getModuleContext().getAppContext().getOptions(), "color", "orange");
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) AppModule(org.apache.openejb.config.AppModule) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

EjbJar (org.apache.openejb.jee.EjbJar)233 StatelessBean (org.apache.openejb.jee.StatelessBean)113 Assembler (org.apache.openejb.assembler.classic.Assembler)90 EjbModule (org.apache.openejb.config.EjbModule)78 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)75 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)64 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)64 Properties (java.util.Properties)48 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)47 InitialContext (javax.naming.InitialContext)42 SingletonBean (org.apache.openejb.jee.SingletonBean)42 AppModule (org.apache.openejb.config.AppModule)39 StatefulBean (org.apache.openejb.jee.StatefulBean)33 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)31 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)27 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)26 Module (org.apache.openejb.testing.Module)26 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)25 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)23 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)19