use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testNoOverrideSetShouldNotOverride.
public void testNoOverrideSetShouldNotOverride() throws OpenEJBException {
if (SystemInstance.get().getProperties().containsKey("ENTERPRISEBEAN.mdb.activation.destinationType")) {
SystemInstance.get().getProperties().remove("ENTERPRISEBEAN.mdb.activation.destinationType");
}
System.clearProperty("ENTERPRISEBEAN.mdb.activation.destinationType");
final MessageDrivenBean mdb = new MdbBuilder().anMdb().withActivationProperty("destinationType", "shouldNotBeOverriddenString").build();
final AppModule appModule = new AppModuleBuilder().anAppModule().withAnMdb(mdb).build();
final ActivationConfigPropertyOverride activationPropertyOverride = new ActivationConfigPropertyOverride();
activationPropertyOverride.deploy(appModule);
assertTrue(containsActivationKeyValuePair(mdb, "destinationType", "shouldNotBeOverriddenString"));
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideSystem.
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"));
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideOpenejbJar.
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"));
}
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testAddActivationConfigPropertyIfNotAlreadyPresent.
/**
* If activation property was not present initially, then add the specified
* one.
*
* @throws OpenEJBException
*/
public void testAddActivationConfigPropertyIfNotAlreadyPresent() throws OpenEJBException {
// set overrides
System.setProperty("ENTERPRISEBEAN.mdb.activation.destinationType", "testString");
// deploy with an mdb that has no "destinationType" activationConfigProp
final MessageDrivenBean mdb = new MdbBuilder().anMdb().build();
final AppModule appModule = new AppModuleBuilder().anAppModule().withAnMdb(mdb).build();
final ActivationConfigPropertyOverride activationPropertyOverride = new ActivationConfigPropertyOverride();
activationPropertyOverride.deploy(appModule);
assertTrue(containsActivationKeyValuePair(mdb, "destinationType", "testString"));
assertTrue(mdb.getActivationConfig().getActivationConfigProperty().size() == 1);
System.clearProperty("ENTERPRISEBEAN.mdb.activation.destinationType");
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class DebuggableVmHackery method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
ejbJar.setRelationships(null);
final List<String> removed = new ArrayList<String>();
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
final String ejbName = bean.getEjbName();
final EjbDeployment ejbDeployment = deployments.get(ejbName);
pruneRefs(bean, ejbDeployment);
// }
if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
continue;
}
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
removed.add(ejbName);
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
for (final Method method : copy(permission.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
permission.getMethod().remove(method);
}
}
if (permission.getMethod().size() == 0) {
assemblyDescriptor.getMethodPermission().remove(permission);
}
}
for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
for (final Method method : copy(transaction.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
transaction.getMethod().remove(method);
}
}
if (transaction.getMethod().size() == 0) {
assemblyDescriptor.getContainerTransaction().remove(transaction);
}
}
for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
if (binding.getEjbName().equals(ejbName)) {
assemblyDescriptor.getInterceptorBinding().remove(binding);
}
}
}
}
// Drop any ejb ref to with an ejb-link to a removed ejb
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
bean.getEjbLocalRefMap().keySet().removeAll(removed);
bean.getEjbRefMap().keySet().removeAll(removed);
}
for (final Interceptor interceptor : ejbJar.getInterceptors()) {
pruneRefs(interceptor, new EjbDeployment());
}
}
return appModule;
}
Aggregations