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;
}
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));
}
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");
}
});
}
});
}
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");
}
});
}
});
}
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;
}
Aggregations