use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class SingletonContainerTest method setUp.
protected void setUp() throws Exception {
super.setUp();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));
// Setup the descriptor information
final SingletonBean bean = new SingletonBean(WidgetBean.class);
bean.addBusinessLocal(Widget.class.getName());
bean.addBusinessRemote(RemoteWidget.class.getName());
bean.addPostConstruct("init");
bean.addPreDestroy("destroy");
bean.setLocalBean(new Empty());
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class SingletonLazyInstantiationTest method setUp.
@Override
protected void setUp() throws Exception {
exception.set(false);
MySingleton.instances.set(0);
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));
// Setup the descriptor information
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(MySingleton.class));
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class Compat3to2Test method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
statefulContainerInfo.properties.setProperty("PoolSize", "0");
statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
statefulContainerInfo.properties.setProperty("Frequency", "0");
assembler.createContainer(statefulContainerInfo);
final EjbJar ejbJar = new EjbJar();
final StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(TargetBean.class));
bean.setHomeAndRemote(TargetHome.class, Target.class);
assembler.createApplication(config.configureApplication(new EjbModule(getClass().getClassLoader(), getClass().getSimpleName(), "test", ejbJar, null)));
calls.clear();
final InitialContext ctx = new InitialContext();
final TargetHome home = (TargetHome) ctx.lookup("TargetBeanRemoteHome");
assertNotNull(home);
final Target target = home.create("Fuzz");
assertNotNull(target);
final String name = target.getName();
assertEquals("Fuzz", name);
target.remove();
assertCalls(Call.values());
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class EntityManagerPropogationTest method setUp.
public void setUp() throws OpenEJBException, IOException, NamingException {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
System.setProperty("openejb.embedded", "true");
// Boot up the minimum required OpenEJB components
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// Start creating the test application
// Create an ejb-jar.xml for this app
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean("PleaseCloseMyExtendedEm", PleaseCloseMyExtendedEmBean.class));
ejbJar.addEnterpriseBean(new StatefulBean("PleaseCloseMyEm", PleaseCloseMyEmBean.class));
ejbJar.addEnterpriseBean(new StatelessBean("PleaseCloseMyLessEm", PleaseCloseMyEmBean.class));
// Add six beans and link them all in a chain
addStatefulBean(ejbJar, ExtendedContextBean.class, "Extended", "Extendedx2");
addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx2", "Extendedx3");
addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx3", "Extendedx4");
addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx4", "Extendedx5");
addStatefulBean(ejbJar, ExtendedContextBean.class, "ExtendedToTransaction", "StatelessTransactionToExtended");
addStatefulBean(ejbJar, ExtendedContextBean.class, "Extendedx5", "Extendedx6");
ejbJar.addEnterpriseBean(new StatefulBean("Extendedx6", EndNodeBean.class));
// Add six beans and link them all in a chain
addStatefulBean(ejbJar, TransactionContextBean.class, "Transaction", "Transactionx2");
addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx2", "Transactionx3");
addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx3", "Transactionx4");
addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx4", "Transactionx5");
addStatefulBean(ejbJar, TransactionContextBean.class, "Transactionx5", "Transactionx6");
addStatefulBean(ejbJar, TransactionContextBean.class, "TransactionToExtended", "Extendedx5");
addStatelessBean(ejbJar, TransactionContextBean.class, "StatelessTransactionToExtended", "Extendedx5");
ejbJar.addEnterpriseBean(new StatefulBean("Transactionx6", EndNodeBean.class));
ejbJar.setAssemblyDescriptor(new AssemblyDescriptor());
ejbJar.getAssemblyDescriptor().addApplicationException(IllegalArgumentException.class, false, true);
ejbJar.getAssemblyDescriptor().addApplicationException(ArgumentException.class, false, true);
// List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
// declared.add(new ContainerTransaction(TransAttribute.REQUIRED, ExtendedContextBean.class.getName(), "Extendedx5", "*"));
// declared.add(new ContainerTransaction(TransAttribute.REQUIRED, ExtendedContextBean.class.getName(), "TransactionToExtended", "*"));
final EjbModule ejbModule = new EjbModule(ejbJar);
// Create an "ear"
final AppModule appModule = new AppModule(ejbModule.getClassLoader(), "test-app");
// Add the ejb-jar.xml to the ear
appModule.getEjbModules().add(ejbModule);
// Create a persistence-unit for this app
final PersistenceUnit unit = new PersistenceUnit("testUnit");
unit.addClass(Color.class);
unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
unit.getProperties().setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
// Add the persistence.xml to the "ear"
appModule.addPersistenceModule(new PersistenceModule("root", new Persistence(unit)));
// Configure and assemble the ear -- aka. deploy it
final AppInfo info = config.configureApplication(appModule);
assembler.createApplication(info);
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class StatefulConcurrentLookupTest method beforeClass.
@BeforeClass
public static synchronized void beforeClass() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
assembler.createContainer(statefulContainerInfo);
final EjbJar ejbJar = new EjbJar();
final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
final Timeout timeout1 = new Timeout();
timeout1.setTimeout(10);
timeout1.setUnit(TimeUnit.SECONDS);
final ConcurrentMethod method1 = new ConcurrentMethod();
method1.setMethod(new NamedMethod("*"));
method1.setAccessTimeout(timeout1);
bean1.getConcurrentMethod().add(method1);
ejbJar.addEnterpriseBean(bean1);
assembler.createApplication(config.configureApplication(ejbJar));
}
Aggregations