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);
}
}
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));
}
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;
}
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");
}
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");
}
Aggregations