Search in sources :

Example 21 with MessageDrivenBean

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

the class ActivationConfigPropertyOverrideTest method testNotOverridden.

public void testNotOverridden() 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 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 : TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) MessageDrivenBeanInfo(org.apache.openejb.assembler.classic.MessageDrivenBeanInfo) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 22 with MessageDrivenBean

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

the class ActivationConfigPropertyOverrideTest method testMdbOverrideOpenejbJar.

public void testMdbOverrideOpenejbJar() 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) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) MessageDrivenBeanInfo(org.apache.openejb.assembler.classic.MessageDrivenBeanInfo) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 23 with MessageDrivenBean

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

the class AutoConfigMdbContainerTest method _testJmsMdbNoContainerConfigured.

public void _testJmsMdbNoContainerConfigured() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new MessageDrivenBean(JmsBean.class));
    final EjbJarInfo info = config.configureApplication(ejbJar);
//        assembler.createApplication(info);
}
Also used : MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 24 with MessageDrivenBean

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

the class CustomMdbContainerTest 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));
    // Setup the descriptor information
    EmailBean.lifecycle.clear();
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");
    final Connector connector = new Connector("email-ra");
    final ResourceAdapter adapter = new ResourceAdapter(EmailResourceAdapter.class);
    connector.setResourceAdapter(adapter);
    final InboundResourceadapter inbound = adapter.setInboundResourceAdapter(new InboundResourceadapter());
    final MessageAdapter messageAdapter = inbound.setMessageAdapter(new MessageAdapter());
    final MessageListener listener = messageAdapter.addMessageListener(new MessageListener(EmailConsumer.class, EmailAccountInfo.class));
    listener.getActivationSpec().addRequiredConfigProperty("address");
    app.getConnectorModules().add(new ConnectorModule(connector));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new MessageDrivenBean(EmailBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    final AppInfo appInfo = config.configureApplication(app);
    assembler.createApplication(appInfo);
    final InitialContext initialContext = new InitialContext();
    final EmailResourceAdapter ra = (EmailResourceAdapter) initialContext.lookup("java:openejb/Resource/email-raRA");
    final Properties headers = new Properties();
    headers.put("To", "dblevins@apache.org");
    headers.put("From", "dblevins@visi.com");
    headers.put("Subject", "Hello");
    ra.deliverEmail(headers, "How's it going?");
    final Stack<Lifecycle> lifecycle = EmailBean.lifecycle;
    final List expected = Arrays.asList(Lifecycle.values());
    Assert.assertEquals(Join.join("\n", expected), Join.join("\n", lifecycle));
}
Also used : Connector(org.apache.openejb.jee.Connector) AppModule(org.apache.openejb.config.AppModule) MessageListener(org.apache.openejb.jee.MessageListener) EjbModule(org.apache.openejb.config.EjbModule) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) Properties(java.util.Properties) ConnectorModule(org.apache.openejb.config.ConnectorModule) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) ResourceAdapter(org.apache.openejb.jee.ResourceAdapter) List(java.util.List) InboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) MessageAdapter(org.apache.openejb.jee.MessageAdapter) InitialContext(javax.naming.InitialContext) AppInfo(org.apache.openejb.assembler.classic.AppInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) Assembler(org.apache.openejb.assembler.classic.Assembler)

Example 25 with MessageDrivenBean

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

the class JmsMdbContainerTest 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();
    // define props for RA in order to change the default activeMQ port
    final Properties props = new Properties();
    final String brokerAddress = NetworkUtil.getLocalAddress("tcp://", "");
    final String brokerXmlConfig = "broker:(" + brokerAddress + ")?useJmx=false";
    props.put("BrokerXmlConfig", brokerXmlConfig);
    props.put("StartupTimeout", 10000);
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    assembler.createResource(config.configureService(ResourceInfo.class, "Default Unmanaged JDBC Database", new Properties(), "Default Unmanaged JDBC Database", "DataSource"));
    assembler.createResource(config.configureService(ResourceInfo.class, "Default JMS Resource Adapter", props, "Default JMS Resource Adapter", "ActiveMQResourceAdapter"));
    // Setup the descriptor information
    WidgetBean.lifecycle.clear();
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new MessageDrivenBean(WidgetBean.class));
    assembler.createApplication(config.configureApplication(ejbJar));
    final InitialContext initialContext = new InitialContext();
    final ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("java:openejb/Resource/Default JMS Connection Factory");
    sendMessage(connectionFactory, "WidgetBean", "test");
    final Stack<Lifecycle> lifecycle = WidgetBean.lifecycle;
    final List expected = Arrays.asList(Lifecycle.values());
    assertEquals(join("\n", expected), join("\n", lifecycle));
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) ConnectionFactory(javax.jms.ConnectionFactory) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) List(java.util.List) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)26 EjbJar (org.apache.openejb.jee.EjbJar)13 Properties (java.util.Properties)9 Assembler (org.apache.openejb.assembler.classic.Assembler)8 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)8 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)8 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)7 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)7 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)7 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)6 MessageDrivenBeanInfo (org.apache.openejb.assembler.classic.MessageDrivenBeanInfo)5 List (java.util.List)4 OpenEJBException (org.apache.openejb.OpenEJBException)4 ActivationConfig (org.apache.openejb.jee.ActivationConfig)4 ActivationConfigProperty (org.apache.openejb.jee.ActivationConfigProperty)4 AppModule (org.apache.openejb.config.AppModule)3 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)3 EjbModule (org.apache.openejb.config.EjbModule)3 AppModuleBuilder (org.apache.openejb.core.builder.AppModuleBuilder)3 MdbBuilder (org.apache.openejb.core.builder.MdbBuilder)3