Search in sources :

Example 76 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class EjbModuleIdTest method testSystemProperty.

/**
 * OPENEJB-1555
 *
 * @throws Exception
 */
@Test
public void testSystemProperty() throws Exception {
    final Map<String, String> map = new HashMap<String, String>();
    map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"orangeId\"><module-name>orangeName</module-name></ejb-jar>");
    final File file = Archives.jarArchive(map, "test", OrangeBean.class);
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    SystemInstance.get().setProperty(file.getName() + ".moduleId", "orangeSystem");
    final AppInfo appInfo = factory.configureApplication(file);
    final EjbJarInfo ejbJarInfo = appInfo.ejbJars.get(0);
    assertEquals("orangeSystem", ejbJarInfo.moduleName);
}
Also used : HashMap(java.util.HashMap) Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 77 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class HooksTest method check.

@Test
public void check() throws OpenEJBException {
    SystemInstance.get().addObserver(new HookLifecycle());
    assertFalse(HookLifecycle.start);
    assertFalse(HookLifecycle.stop);
    final Assembler assembler = new Assembler();
    assertTrue(HookLifecycle.start);
    assertFalse(HookLifecycle.stop);
    assembler.destroy();
    assertTrue(HookLifecycle.start);
    assertTrue(HookLifecycle.stop);
}
Also used : Assembler(org.apache.openejb.assembler.classic.Assembler) Test(org.junit.Test)

Example 78 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class NoServiceJarTest method test.

public void test() throws Exception {
    final ConfigurationFactory factory = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    final Resource orange = new Resource("Orange");
    orange.setClassName(Color.class.getName());
    orange.getProperties().setProperty("red", "255");
    orange.getProperties().setProperty("green", "200");
    orange.getProperties().setProperty("blue", "0");
    final ResourceInfo resourceInfo = factory.configureService(orange, ResourceInfo.class);
    assembler.createResource(resourceInfo);
    assembler.createSecurityService(factory.configureService(SecurityServiceInfo.class));
    assembler.createTransactionManager(factory.configureService(TransactionServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(MyBean.class));
    final AppContext application = assembler.createApplication(factory.configureApplication(new EjbModule(ejbJar)));
    final MyBean myBean = (MyBean) application.getBeanContexts().get(0).getBusinessLocalBeanHome().create();
    final Color color = myBean.getColor();
    assertNotNull(color);
    assertEquals(255, color.getRed());
    assertEquals(200, color.getGreen());
    assertEquals(0, color.getBlue());
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) SingletonBean(org.apache.openejb.jee.SingletonBean) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) AppContext(org.apache.openejb.AppContext) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 79 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class LegacyInterfaceTest 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.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(MySingletonBean.class));
    ejbJar.addEnterpriseBean(new EntityBean(MyBmpBean.class, PersistenceType.BEAN));
    // <entity>
    // <ejb-name>License</ejb-name>
    // <local-home>org.apache.openejb.test.entity.cmr.onetoone.LicenseLocalHome</local-home>
    // <local>org.apache.openejb.test.entity.cmr.onetoone.LicenseLocal</local>
    // <ejb-class>org.apache.openejb.test.entity.cmr.onetoone.LicenseBean</ejb-class>
    // <persistence-type>Container</persistence-type>
    // <prim-key-class>java.lang.Integer</prim-key-class>
    // <reentrant>false</reentrant>
    // <cmp-version>2.x</cmp-version>
    // <abstract-schema-name>License</abstract-schema-name>
    // <cmp-field>
    // <field-name>id</field-name>
    // </cmp-field>
    // <cmp-field>
    // <field-name>number</field-name>
    // </cmp-field>
    // <cmp-field>
    // <field-name>points</field-name>
    // </cmp-field>
    // <cmp-field>
    // <field-name>notes</field-name>
    // </cmp-field>
    // <primkey-field>id</primkey-field>
    // <query>
    // <!-- CompondPK one-to-one shares the local home interface so we need to declare this useless finder -->
    // <query-method>
    // <method-name>findByPrimaryKey</method-name>
    // <method-params>
    // <method-param>org.apache.openejb.test.entity.cmr.onetoone.LicensePk</method-param>
    // </method-params>
    // </query-method>
    // <ejb-ql>SELECT OBJECT(DL) FROM License DL</ejb-ql>
    // </query>
    // </entity>
    final EntityBean cmp = ejbJar.addEnterpriseBean(new EntityBean(MyCmpBean.class, PersistenceType.CONTAINER));
    cmp.setPrimKeyClass(Integer.class.getName());
    cmp.setPrimkeyField("id");
    cmp.getCmpField().add(new CmpField("id"));
    cmp.getCmpField().add(new CmpField("name"));
    final Query query = new Query();
    query.setQueryMethod(new QueryMethod("findByPrimaryKey", Integer.class.getName()));
    query.setEjbQl("SELECT OBJECT(DL) FROM License DL");
    cmp.getQuery().add(query);
    final List<ContainerTransaction> transactions = ejbJar.getAssemblyDescriptor().getContainerTransaction();
    // <container-transaction>
    // <method>
    // <ejb-name>MyBean</ejb-name>
    // <method-name>*</method-name>
    // </method>
    // <trans-attribute>Supports</trans-attribute>
    // </container-transaction>
    transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyBmpBean", "*"));
    transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MyCmpBean", "*"));
    transactions.add(new ContainerTransaction(TransAttribute.SUPPORTS, null, "MySingletonBean", "*"));
    final File f = new File("test").getAbsoluteFile();
    if (!f.exists() && !f.mkdirs()) {
        throw new Exception("Failed to create test directory: " + f);
    }
    final AppModule module = new AppModule(this.getClass().getClassLoader(), f.getAbsolutePath());
    module.getEjbModules().add(new EjbModule(ejbJar));
    assembler.createApplication(config.configureApplication(module));
}
Also used : AppModule(org.apache.openejb.config.AppModule) Query(org.apache.openejb.jee.Query) QueryMethod(org.apache.openejb.jee.QueryMethod) EjbModule(org.apache.openejb.config.EjbModule) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) RemoveException(javax.ejb.RemoveException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException) SingletonBean(org.apache.openejb.jee.SingletonBean) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) CmpField(org.apache.openejb.jee.CmpField) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) EntityBean(org.apache.openejb.jee.EntityBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) File(java.io.File) EjbJar(org.apache.openejb.jee.EjbJar)

Example 80 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class AsynchInRoleTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    config = new ConfigurationFactory();
    assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
Also used : TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) Before(org.junit.Before)

Aggregations

Assembler (org.apache.openejb.assembler.classic.Assembler)171 EjbJar (org.apache.openejb.jee.EjbJar)88 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)84 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)76 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)76 StatelessBean (org.apache.openejb.jee.StatelessBean)56 InitialContext (javax.naming.InitialContext)50 File (java.io.File)49 AppInfo (org.apache.openejb.assembler.classic.AppInfo)47 Properties (java.util.Properties)42 HashMap (java.util.HashMap)39 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)39 ContainerSystem (org.apache.openejb.spi.ContainerSystem)35 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)29 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)29 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)29 Test (org.junit.Test)29 EjbModule (org.apache.openejb.config.EjbModule)27 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)22 Map (java.util.Map)21