use of org.apache.openejb.config.AppModule in project tomee by apache.
the class QuartzPersistenceForEJBTimersTest method application.
@Module
public AppModule application() {
final EjbModule ejbModule = new EjbModule(new EjbJar());
ejbModule.getEjbJar().addEnterpriseBean(new SingletonBean(MyTimedEjb.class).localBean());
final Properties quartzConfig = new PropertiesBuilder().p("org.apache.openejb.quartz.scheduler.instanceName", "TestScheduler").p("org.apache.openejb.quartz.scheduler.instanceId", "AUTO").p("org.apache.openejb.quartz.threadPool.class", SimpleThreadPool.class.getName()).p("org.apache.openejb.quartz.threadPool.threadCount", "4").p("org.apache.openejb.quartz.threadPool.threadPriority", "5").p("org.apache.openejb.quartz.jobStore.class", JobStoreCMT.class.getName()).p("org.apache.openejb.quartz.jobStore.driverDelegateClass", HSQLDBDelegate.class.getName()).p("org.apache.openejb.quartz.jobStore.dataSource", "QUARTZ").p("org.apache.openejb.quartz.jobStore.nonManagedTXDataSource", "QUARTZ_NOTX").p("org.apache.openejb.quartz.jobStore.tablePrefix", "qrtz_").p("org.apache.openejb.quartz.jobStore.isClustered", "true").p("org.apache.openejb.quartz.jobStore.clusterCheckinInterval", "60000").p("org.apache.openejb.quartz.jobStore.txIsolationLevelSerializable", "true").p("org.apache.openejb.quartz.jobStore.maxMisfiresToHandleAtATime", "100").p("org.apache.openejb.quartz.dataSource.QUARTZ.jndiURL", "openejb:Resource/QuartzPersistenceForEJBTimersDB").p("org.apache.openejb.quartz.dataSource.QUARTZ_NOTX.jndiURL", "openejb:Resource/QuartzPersistenceForEJBTimersDBNoTx").build();
final AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), null);
appModule.getEjbModules().add(ejbModule);
appModule.getProperties().putAll(quartzConfig);
return appModule;
}
use of org.apache.openejb.config.AppModule in project tomee by apache.
the class CheckAnnotationTest method testWebServiceWithStateful.
@Keys({ @Key(value = "annotation.invalid.stateful.webservice", type = KeyType.WARNING) })
public AppModule testWebServiceWithStateful() {
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(Green.class));
final EjbModule ejbModule = new EjbModule(ejbJar);
ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(Green.class)).link());
final AppModule appModule = new AppModule(ejbModule);
return appModule;
}
use of org.apache.openejb.config.AppModule in project tomee by apache.
the class AppClientTest method test.
public void test() throws Exception {
final EjbServer ejbServer = new EjbServer();
final Properties initProps = new Properties();
initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
ejbServer.init(new Properties());
final ServicePool pool = new ServicePool(ejbServer, 10);
final ServiceDaemon serviceDaemon = new ServiceDaemon(pool, 0, "localhost");
serviceDaemon.start();
int port = serviceDaemon.getPort();
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
final ConfigurationFactory config = new ConfigurationFactory();
final EjbModule ejbModule = new EjbModule(new EjbJar("testejbmodule"), new OpenejbJar());
final EjbJar ejbJar = ejbModule.getEjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(Orange.class));
final ClassLoader loader = this.getClass().getClassLoader();
final ClientModule clientModule = new ClientModule(new ApplicationClient(), loader, "orange-client", OrangeAppClient.class.getName(), "orange-client");
final AppModule appModule = new AppModule(loader, "testapp");
appModule.getClientModules().add(clientModule);
appModule.getEjbModules().add(ejbModule);
assembler.createApplication(config.configureApplication(appModule));
final Properties props = new Properties();
props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
props.put("java.naming.provider.url", "ejbd://127.0.0.1:" + port);
props.put("openejb.client.moduleId", "orange-client");
Context context = new InitialContext(props);
final Object home = context.lookup("comp/env/home");
assertTrue(home instanceof OrangeHome);
OrangeHome orangeHome = (OrangeHome) home;
final OrangeRemote orangeRemote = orangeHome.create();
assertEquals("bat", orangeRemote.echo("tab"));
final Object business = context.lookup("comp/env/business");
assertTrue(business instanceof OrangeBusinessRemote);
OrangeBusinessRemote orangeBusinessRemote = (OrangeBusinessRemote) business;
assertEquals("nap", orangeBusinessRemote.echo("pan"));
final Object dataSourceObject = context.lookup("comp/env/datasource");
assertTrue(dataSourceObject instanceof DataSource);
// DataSource dataSource = (DataSource) dataSourceObject;
// assertEquals("nap", orangeBusinessRemote.echo("pan"));
props.put("openejb.client.moduleId", "openejb/global");
context = new InitialContext(props);
final Object global = context.lookup("global/testapp/testejbmodule/Orange!" + OrangeBusinessRemote.class.getName());
assertTrue(global instanceof OrangeBusinessRemote);
OrangeBusinessRemote globalOrangeBusinessRemote = (OrangeBusinessRemote) global;
assertEquals("nap", globalOrangeBusinessRemote.echo("pan"));
serviceDaemon.stop();
OpenEJB.destroy();
}
use of org.apache.openejb.config.AppModule in project tomee by apache.
the class EjbSecurityRoleRefTest method testShouldCheckUserRole.
public void testShouldCheckUserRole() throws Exception {
final EjbJar ejbJar = new EjbJar();
final StatelessBean statelessBean = new StatelessBean(UserBean.class);
final SecurityRoleRef securityRoleRef = new SecurityRoleRef();
securityRoleRef.setRoleName("TEST");
securityRoleRef.setRoleLink("committer");
statelessBean.getSecurityRoleRef().add(securityRoleRef);
ejbJar.addEnterpriseBean(statelessBean);
final AppModule app = new AppModule(this.getClass().getClassLoader(), "classpath-" + ejbJar.hashCode());
app.getEjbModules().add(new EjbModule(ejbJar));
assembler.createApplication(config.configureApplication(app));
final User user = (User) context.lookup("UserBeanLocal");
assertTrue(user.isUserInRole());
}
use of org.apache.openejb.config.AppModule in project tomee by apache.
the class OpenEJBXmlByModuleTest 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(OpenEJBXmlByModuleTest.class.getClassLoader(), OpenEJBXmlByModuleTest.class.getSimpleName());
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(UselessBean.class));
app.getEjbModules().add(new EjbModule(ejbJar));
app.getEjbModules().iterator().next().getAltDDs().put("resources.xml", getClass().getClassLoader().getResource("META-INF/resource/appresource.openejb.xml"));
assembler.createApplication(config.configureApplication(app));
final Properties properties = new Properties();
properties.setProperty(javax.naming.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 = (UselessBean) context.lookup("UselessBeanLocalBean");
}
Aggregations