Search in sources :

Example 21 with EjbJar

use of org.apache.openejb.jee.EjbJar in project tomee by apache.

the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideOpenejbJar.

@Test
public void testEjbNameOverrideOpenejbJar() throws Exception {
    SystemInstance.reset();
    final Assembler assembler = new Assembler();
    final ConfigurationFactory config = new ConfigurationFactory();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    {
        final EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
        final OpenejbJar openejbJar = new OpenejbJar();
        final Properties properties = openejbJar.getProperties();
        properties.setProperty("mdb.activation.maxSessions", "20");
        properties.setProperty("mdb.activation.maxMessagesPerSessions", "100");
        properties.setProperty("mdb.activation.destinationType", "javax.jms.Queue");
        properties.setProperty("mdb.activation.destination", "OVERRIDDEN.QUEUE");
        final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
        final EjbJarInfo ejbJarInfo = config.configureApplication(ejbModule);
        assertEquals(2, ejbJarInfo.enterpriseBeans.size());
        final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
        final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
        assertEquals("20", orange.activationProperties.get("maxSessions"));
        assertEquals("100", orange.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
        assertEquals("OVERRIDDEN.QUEUE", orange.activationProperties.get("destination"));
        assertEquals("20", yellow.activationProperties.get("maxSessions"));
        assertEquals("100", yellow.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Queue", yellow.activationProperties.get("destinationType"));
        assertEquals("OVERRIDDEN.QUEUE", yellow.activationProperties.get("destination"));
    }
    // Verify the openejb-jar level overrides do not affect other apps
    {
        final EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
        ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
        final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
        assertEquals(2, ejbJarInfo.enterpriseBeans.size());
        final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
        final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
        assertEquals("7", orange.activationProperties.get("maxSessions"));
        assertEquals("4", orange.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
        assertEquals("ORANGE.QUEUE", orange.activationProperties.get("destination"));
        assertEquals("5", yellow.activationProperties.get("maxSessions"));
        assertEquals("10", yellow.activationProperties.get("maxMessagesPerSessions"));
        assertEquals("javax.jms.Topic", yellow.activationProperties.get("destinationType"));
        assertEquals("YELLOW.TOPIC", yellow.activationProperties.get("destination"));
    }
}
Also used : OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) Properties(java.util.Properties) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test) ActivationContainerOverwriteBothConfigurationTest(org.apache.openejb.activemq.ActivationContainerOverwriteBothConfigurationTest)

Example 22 with EjbJar

use of org.apache.openejb.jee.EjbJar in project tomee by apache.

the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideSystem.

@Test
public void testEjbNameOverrideSystem() throws Exception {
    SystemInstance.reset();
    final Properties properties = SystemInstance.get().getProperties();
    properties.setProperty("Orange.activation.maxSessions", "20");
    properties.setProperty("Orange.activation.maxMessagesPerSessions", "100");
    properties.setProperty("Orange.activation.destinationType", "javax.jms.Queue");
    properties.setProperty("Orange.activation.destination", "OVERRIDDEN.QUEUE");
    final Assembler assembler = new Assembler();
    final ConfigurationFactory config = new ConfigurationFactory();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    // just to make sure class name is not used
    ejbJar.addEnterpriseBean(new MessageDrivenBean("Yellow", Orange.class));
    // just to make sure class name is not used
    ejbJar.addEnterpriseBean(new MessageDrivenBean("Orange", Yellow.class));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assertEquals(2, ejbJarInfo.enterpriseBeans.size());
    final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
    final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
    assertEquals("7", orange.activationProperties.get("maxSessions"));
    assertEquals("4", orange.activationProperties.get("maxMessagesPerSessions"));
    assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
    assertEquals("ORANGE.QUEUE", orange.activationProperties.get("destination"));
    assertEquals("20", yellow.activationProperties.get("maxSessions"));
    assertEquals("100", yellow.activationProperties.get("maxMessagesPerSessions"));
    assertEquals("javax.jms.Queue", yellow.activationProperties.get("destinationType"));
    assertEquals("OVERRIDDEN.QUEUE", yellow.activationProperties.get("destination"));
}
Also used : MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) Properties(java.util.Properties) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test) ActivationContainerOverwriteBothConfigurationTest(org.apache.openejb.activemq.ActivationContainerOverwriteBothConfigurationTest)

Example 23 with EjbJar

use of org.apache.openejb.jee.EjbJar in project tomee by apache.

the class AnnotationDeployerTest method testLocalBean.

/**
 * For https://issues.apache.org/jira/browse/OPENEJB-1188
 *
 * @throws Exception
 */
@Test
public void testLocalBean() throws Exception {
    final EjbModule ejbModule = testModule();
    final EjbJar ejbJar = ejbModule.getEjbJar();
    AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), "myapp");
    appModule.getEjbModules().add(ejbModule);
    final AnnotationDeployer annotationDeployer = new AnnotationDeployer();
    appModule = annotationDeployer.deploy(appModule);
    EnterpriseBean bean = ejbJar.getEnterpriseBean("TestLocalBean");
    assert bean != null;
    assert (((SessionBean) bean).getLocalBean() != null);
    bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
    assert bean != null;
    assert (((SessionBean) bean).getLocalBean() == null);
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) SessionBean(org.apache.openejb.jee.SessionBean) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 24 with EjbJar

use of org.apache.openejb.jee.EjbJar in project tomee by apache.

the class AnnotationDeployerTest method interceptingGenericBusinessMethodCalls.

/**
 * For https://issues.apache.org/jira/browse/OPENEJB-1128
 */
@Test
public void interceptingGenericBusinessMethodCalls() throws Exception {
    EjbModule ejbModule = testModule();
    final EjbJar ejbJar = ejbModule.getEjbJar();
    final AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
    ejbModule = discvrAnnBeans.deploy(ejbModule);
    final EnterpriseBean bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
    assert bean != null;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 25 with EjbJar

use of org.apache.openejb.jee.EjbJar in project tomee by apache.

the class AppInfoBuilderTest method testShouldCreateContainer.

public void testShouldCreateContainer() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final OpenejbJar openejbJar = new OpenejbJar();
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    final AppModule appModule = new AppModule(ejbModule);
    appModule.getContainers().add(new Container("my-container", "MESSAGE", null));
    final AppInfo appInfo = new AppInfoBuilder(new ConfigurationFactory()).build(appModule);
    assertEquals(1, appInfo.containers.size());
    final ContainerInfo containerInfo = appInfo.containers.get(0);
    assertEquals(appInfo.appId + "/my-container", containerInfo.id);
    assertEquals(1, containerInfo.types.size());
    assertEquals("MESSAGE", containerInfo.types.get(0));
    assertEquals(MdbContainerFactory.class.getName(), containerInfo.className);
    assertEquals("Default JMS Resource Adapter", containerInfo.properties.get("ResourceAdapter"));
    assertEquals(MessageListener.class.getName(), containerInfo.properties.get("MessageListenerInterface"));
    assertEquals(TomEEMessageActivationSpec.class.getName(), containerInfo.properties.get("ActivationSpecClass"));
    assertEquals("10", containerInfo.properties.get("InstanceLimit"));
    assertEquals("true", containerInfo.properties.get("FailOnUnknownActivationSpec"));
}
Also used : TomEEMessageActivationSpec(org.apache.openejb.resource.activemq.TomEEMessageActivationSpec) MdbContainer(org.apache.openejb.core.mdb.MdbContainer) Container(org.apache.openejb.config.sys.Container) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) MdbContainerFactory(org.apache.openejb.core.mdb.MdbContainerFactory) ContainerInfo(org.apache.openejb.assembler.classic.ContainerInfo) MessageListener(javax.jms.MessageListener) EjbJar(org.apache.openejb.jee.EjbJar) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Aggregations

EjbJar (org.apache.openejb.jee.EjbJar)253 StatelessBean (org.apache.openejb.jee.StatelessBean)120 Assembler (org.apache.openejb.assembler.classic.Assembler)93 EjbModule (org.apache.openejb.config.EjbModule)87 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)81 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)65 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)65 Properties (java.util.Properties)52 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)52 SingletonBean (org.apache.openejb.jee.SingletonBean)49 InitialContext (javax.naming.InitialContext)44 AppModule (org.apache.openejb.config.AppModule)43 Module (org.apache.openejb.testing.Module)35 StatefulBean (org.apache.openejb.jee.StatefulBean)33 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)32 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)27 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)26 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)26 Test (org.junit.Test)26 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)22