use of org.apache.openejb.config.EjbModule 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.config.EjbModule 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.config.EjbModule 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");
}
use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class DeploymentContextOptionsTest method testModuleContextOptions.
public void testModuleContextOptions() 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();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
openejbJar.getProperties().setProperty("color", "orange");
ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
assembler.createApplication(config.configureApplication(ejbModule));
}
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");
assertNoOption(beanContext.getModuleContext().getAppContext().getOptions(), "color");
}
use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class DeploymentContextOptionsTest method testBeanContextOptions.
public void testBeanContextOptions() 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();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
{
// Set at BeanContext level
final EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
deployment.getProperties().put("color", "orange");
}
assembler.createApplication(config.configureApplication(ejbModule));
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
assertOption(beanContext.getOptions(), "color", "orange");
assertNoOption(beanContext.getModuleContext().getOptions(), "color");
assertNoOption(beanContext.getModuleContext().getAppContext().getOptions(), "color");
}
Aggregations