Search in sources :

Example 6 with MessageDrivenBean$JAXB.readMessageDrivenBean

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

the class AutoConfig method matchContainer.

private String matchContainer(final Class<? extends ContainerInfo> containerInfoType, final EnterpriseBean bean, final Collection<ContainerInfo> list) {
    for (final ContainerInfo containerInfo : list) {
        if (containerInfo.getClass().equals(containerInfoType)) {
            // MDBs must match message listener interface type
            if (MessageDrivenBean.class.isInstance(bean)) {
                final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
                final String messagingType = messageDrivenBean.getMessagingType();
                if (containerInfo.properties.get("MessageListenerInterface").equals(messagingType)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Container {0} matches container type {1} and MessageListenerInterface {2} for bean {3}, this container will be used.", containerInfo.id, containerInfoType.getName(), messagingType, bean.getEjbName());
                    }
                    return containerInfo.id;
                } else {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Container {0} of type {1} does not have the matching MessageListenerInterface. Bean listener interface is {2}, " + "container listener interface is {3} for bean {4}. Skipping.", containerInfo.id, containerInfoType.getName(), messagingType, containerInfo.properties.get("MessageListenerInterface"), bean.getEjbName());
                    }
                }
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("Container {0} matches container type {1} for bean {2}, this container will be used.", containerInfo.id, containerInfoType.getName(), bean.getEjbName());
                }
                return containerInfo.id;
            }
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Skipping container {0} of type {1}", containerInfo.id, containerInfoType.getName());
        }
    }
    return null;
}
Also used : MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ContainerInfo(org.apache.openejb.assembler.classic.ContainerInfo) MdbContainerInfo(org.apache.openejb.assembler.classic.MdbContainerInfo)

Example 7 with MessageDrivenBean$JAXB.readMessageDrivenBean

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

the class QuartzMdbContainerTest 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
    CronBean.lifecycle.clear();
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");
    final Connector connector = new Connector("email-ra");
    final ResourceAdapter adapter = new ResourceAdapter(QuartzResourceAdapter.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(Job.class, JobSpec.class));
    listener.getActivationSpec().addRequiredConfigProperty("cronExpression");
    app.getConnectorModules().add(new ConnectorModule(connector));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new MessageDrivenBean(CronBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    final AppInfo appInfo = config.configureApplication(app);
    assembler.createApplication(appInfo);
    assertTrue(CronBean.latch.await(5, TimeUnit.SECONDS));
    final Stack<Lifecycle> lifecycle = CronBean.lifecycle;
    final List expected = Arrays.asList(Lifecycle.values());
    Assert.assertEquals(expected.get(0), lifecycle.get(0));
    Assert.assertEquals(expected.get(1), lifecycle.get(1));
}
Also used : Connector(org.apache.openejb.jee.Connector) MessageAdapter(org.apache.openejb.jee.MessageAdapter) 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) ConnectorModule(org.apache.openejb.config.ConnectorModule) AppInfo(org.apache.openejb.assembler.classic.AppInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) QuartzResourceAdapter(org.apache.openejb.resource.quartz.QuartzResourceAdapter) ResourceAdapter(org.apache.openejb.jee.ResourceAdapter) List(java.util.List) Assembler(org.apache.openejb.assembler.classic.Assembler) JobSpec(org.apache.openejb.resource.quartz.JobSpec) InboundResourceadapter(org.apache.openejb.jee.InboundResourceadapter) Job(org.apache.openejb.quartz.Job) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 8 with MessageDrivenBean$JAXB.readMessageDrivenBean

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

the class ResourceAdapterControlTest method app.

@Module
@Classes(value = Mdb.class)
public EjbModule app() {
    return new EjbModule(new EjbJar("test") {

        {
            addEnterpriseBean(new MessageDrivenBean("ejb/Mdb", Mdb.class) {

                {
                    setActivationConfig(new ActivationConfig());
                    getActivationConfig().addProperty("MdbActiveOnStartup", "false");
                    getActivationConfig().addProperty("MdbJMXControl", "default:type=test");
                }
            });
        }
    });
}
Also used : MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) ActivationConfig(org.apache.openejb.jee.ActivationConfig) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Example 9 with MessageDrivenBean$JAXB.readMessageDrivenBean

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

the class ResourceAdapterDeliveryActiveTest method app.

@Module
@Classes(value = Mdb.class)
public EjbModule app() {
    return new EjbModule(new EjbJar("test") {

        {
            addEnterpriseBean(new MessageDrivenBean("ejb/Mdb", Mdb.class) {

                {
                    setActivationConfig(new ActivationConfig());
                    getActivationConfig().addProperty("DeliveryActive", "false");
                    getActivationConfig().addProperty("MdbJMXControl", "default:type=test");
                }
            });
        }
    });
}
Also used : MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) ActivationConfig(org.apache.openejb.jee.ActivationConfig) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Example 10 with MessageDrivenBean$JAXB.readMessageDrivenBean

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

the class CheckAnnotationTest method testWebServiceWithMessageDriven.

@Keys({ @Key(value = "annotation.invalid.messagedriven.webservice", type = KeyType.WARNING) })
public AppModule testWebServiceWithMessageDriven() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
    final EjbModule ejbModule = new EjbModule(ejbJar);
    ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(Yellow.class)).link());
    final AppModule appModule = new AppModule(ejbModule);
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) Yellow(org.apache.openejb.test.annotated.Yellow) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) EjbModule(org.apache.openejb.config.EjbModule) ClassesArchive(org.apache.xbean.finder.archive.ClassesArchive) AnnotationFinder(org.apache.xbean.finder.AnnotationFinder) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)32 EjbJar (org.apache.openejb.jee.EjbJar)17 Properties (java.util.Properties)10 ActivationContainerOverwriteBothConfigurationTest (org.apache.openejb.activemq.ActivationContainerOverwriteBothConfigurationTest)9 Test (org.junit.Test)9 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)7 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)7 EjbModule (org.apache.openejb.config.EjbModule)6 ActivationConfig (org.apache.openejb.jee.ActivationConfig)6 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)6 List (java.util.List)5 OpenEJBException (org.apache.openejb.OpenEJBException)4 Assembler (org.apache.openejb.assembler.classic.Assembler)4 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)4 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)4 AppModule (org.apache.openejb.config.AppModule)4 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)4 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)4 ActivationConfigProperty (org.apache.openejb.jee.ActivationConfigProperty)4 InitialContext (javax.naming.InitialContext)3