@Test public void testAddActivationConfigPropertyIfNotAlreadyPresent() throws OpenEJBException { System.setProperty("ENTERPRISEBEAN.mdb.activation.destinationType", "testString"); 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"); }
@Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { final Properties system = new Properties(); system.putAll(SystemInstance.get().getProperties()); system.putAll(appModule.getProperties()); system.putAll(JavaSecurityManagers.getSystemProperties()); for (final EjbModule ejbModule : appModule.getEjbModules()) { final EjbJar ejbJar = ejbModule.getEjbJar(); final OpenejbJar openejbJar = ejbModule.getOpenejbJar(); final Properties module = new Properties(); module.putAll(openejbJar.getProperties()); module.putAll(system); final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName(); for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { final String ejbName = bean.getEjbName(); final EjbDeployment ejbDeployment = deployments.get(ejbName); if (!(bean instanceof MessageDrivenBean)) { continue; } final Properties properties = new Properties(); properties.putAll(module); properties.putAll(ejbDeployment.getProperties()); final MessageDrivenBean mdb = (MessageDrivenBean) bean; if (mdb.getActivationConfig() != null) { for (final ActivationConfigProperty property : mdb.getActivationConfig().getActivationConfigProperty()) { final String originalValue = property.getActivationConfigPropertyValue(); final String value = PropertyPlaceHolderHelper.simpleValue(originalValue); if (value != null && !originalValue.equals(value)) { property.setActivationConfigPropertyValue(value); } } } final Properties overrides = new Properties(); final MdbContainerDetails mdbContainer = getMdbContainer(appModule, ejbDeployment.getContainerId(), appModule.getModuleId()); if (mdbContainer != null) { overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.container." + mdbContainer.getContainerId() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(mdbContainer.getProperties(), "activation", "EnterpriseBean")); } overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, mdb.getMessagingType() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbName + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbDeployment.getDeploymentId() + ".activation", "EnterpriseBean")); if (overrides.size() == 0) { continue; } if (mdb.getActivationConfig() == null) { mdb.setActivationConfig(new ActivationConfig()); } final List<ActivationConfigProperty> activationConfigList = mdb.getActivationConfig().getActivationConfigProperty(); for (final Map.Entry<Object, Object> entry : overrides.entrySet()) { final Object property = String.valueOf(entry.getKey()); final Object value = String.valueOf(entry.getValue()); ActivationConfigProperty activationConfigProperty = this.findActivationProperty(activationConfigList, property.toString()); if (activationConfigProperty != null) { logger.info(String.format("Found %s bean with activation-config property %s=%s to override", ejbName, activationConfigProperty.getActivationConfigPropertyName(), activationConfigProperty.getActivationConfigPropertyValue())); logger.info(String.format("Overriding %s bean activation-config property.%s=%s", ejbName, property, value)); activationConfigProperty.setActivationConfigPropertyValue(entry.getValue().toString()); } else { logger.info(String.format("Adding %s bean activation-config property %s=%s", ejbName, property, value)); activationConfigProperty = new ActivationConfigProperty(); activationConfigProperty.setActivationConfigPropertyName(property.toString()); activationConfigProperty.setActivationConfigPropertyValue(value.toString()); activationConfigList.add(activationConfigProperty); } } } } return appModule; }
ActivationConfigPropertyOverride implements DynamicDeployer { @Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { final Properties system = new Properties(); system.putAll(SystemInstance.get().getProperties()); system.putAll(appModule.getProperties()); system.putAll(JavaSecurityManagers.getSystemProperties()); for (final EjbModule ejbModule : appModule.getEjbModules()) { final EjbJar ejbJar = ejbModule.getEjbJar(); final OpenejbJar openejbJar = ejbModule.getOpenejbJar(); final Properties module = new Properties(); module.putAll(openejbJar.getProperties()); module.putAll(system); final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName(); for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { final String ejbName = bean.getEjbName(); final EjbDeployment ejbDeployment = deployments.get(ejbName); if (!(bean instanceof MessageDrivenBean)) { continue; } final Properties properties = new Properties(); properties.putAll(module); properties.putAll(ejbDeployment.getProperties()); final MessageDrivenBean mdb = (MessageDrivenBean) bean; if (mdb.getActivationConfig() != null) { for (final ActivationConfigProperty property : mdb.getActivationConfig().getActivationConfigProperty()) { final String originalValue = property.getActivationConfigPropertyValue(); final String value = PropertyPlaceHolderHelper.simpleValue(originalValue); if (value != null && !originalValue.equals(value)) { property.setActivationConfigPropertyValue(value); } } } final Properties overrides = new Properties(); final MdbContainerDetails mdbContainer = getMdbContainer(appModule, ejbDeployment.getContainerId(), appModule.getModuleId()); if (mdbContainer != null) { overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.container." + mdbContainer.getContainerId() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(mdbContainer.getProperties(), "activation", "EnterpriseBean")); } overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, mdb.getMessagingType() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbName + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbDeployment.getDeploymentId() + ".activation", "EnterpriseBean")); if (overrides.size() == 0) { continue; } if (mdb.getActivationConfig() == null) { mdb.setActivationConfig(new ActivationConfig()); } final List<ActivationConfigProperty> activationConfigList = mdb.getActivationConfig().getActivationConfigProperty(); for (final Map.Entry<Object, Object> entry : overrides.entrySet()) { final Object property = String.valueOf(entry.getKey()); final Object value = String.valueOf(entry.getValue()); ActivationConfigProperty activationConfigProperty = this.findActivationProperty(activationConfigList, property.toString()); if (activationConfigProperty != null) { logger.info(String.format("Found %s bean with activation-config property %s=%s to override", ejbName, activationConfigProperty.getActivationConfigPropertyName(), activationConfigProperty.getActivationConfigPropertyValue())); logger.info(String.format("Overriding %s bean activation-config property.%s=%s", ejbName, property, value)); activationConfigProperty.setActivationConfigPropertyValue(entry.getValue().toString()); } else { logger.info(String.format("Adding %s bean activation-config property %s=%s", ejbName, property, value)); activationConfigProperty = new ActivationConfigProperty(); activationConfigProperty.setActivationConfigPropertyName(property.toString()); activationConfigProperty.setActivationConfigPropertyValue(value.toString()); activationConfigList.add(activationConfigProperty); } } } } return appModule; } }
ActivationConfigPropertyOverride implements DynamicDeployer { @Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { final Properties system = new Properties(); system.putAll(SystemInstance.get().getProperties()); system.putAll(appModule.getProperties()); system.putAll(JavaSecurityManagers.getSystemProperties()); for (final EjbModule ejbModule : appModule.getEjbModules()) { final EjbJar ejbJar = ejbModule.getEjbJar(); final OpenejbJar openejbJar = ejbModule.getOpenejbJar(); final Properties module = new Properties(); module.putAll(openejbJar.getProperties()); module.putAll(system); final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName(); for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { final String ejbName = bean.getEjbName(); final EjbDeployment ejbDeployment = deployments.get(ejbName); if (!(bean instanceof MessageDrivenBean)) { continue; } final Properties properties = new Properties(); properties.putAll(module); properties.putAll(ejbDeployment.getProperties()); final MessageDrivenBean mdb = (MessageDrivenBean) bean; if (mdb.getActivationConfig() != null) { for (final ActivationConfigProperty property : mdb.getActivationConfig().getActivationConfigProperty()) { final String originalValue = property.getActivationConfigPropertyValue(); final String value = PropertyPlaceHolderHelper.simpleValue(originalValue); if (value != null && !originalValue.equals(value)) { property.setActivationConfigPropertyValue(value); } } } final Properties overrides = new Properties(); final MdbContainerDetails mdbContainer = getMdbContainer(appModule, ejbDeployment.getContainerId(), appModule.getModuleId()); if (mdbContainer != null) { overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.container." + mdbContainer.getContainerId() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(mdbContainer.getProperties(), "activation", "EnterpriseBean")); } overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, mdb.getMessagingType() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbName + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbDeployment.getDeploymentId() + ".activation", "EnterpriseBean")); if (overrides.size() == 0) { continue; } if (mdb.getActivationConfig() == null) { mdb.setActivationConfig(new ActivationConfig()); } final List<ActivationConfigProperty> activationConfigList = mdb.getActivationConfig().getActivationConfigProperty(); for (final Map.Entry<Object, Object> entry : overrides.entrySet()) { final Object property = String.valueOf(entry.getKey()); final Object value = String.valueOf(entry.getValue()); ActivationConfigProperty activationConfigProperty = this.findActivationProperty(activationConfigList, property.toString()); if (activationConfigProperty != null) { logger.info(String.format("Found %s bean with activation-config property %s=%s to override", ejbName, activationConfigProperty.getActivationConfigPropertyName(), activationConfigProperty.getActivationConfigPropertyValue())); logger.info(String.format("Overriding %s bean activation-config property.%s=%s", ejbName, property, value)); activationConfigProperty.setActivationConfigPropertyValue(entry.getValue().toString()); } else { logger.info(String.format("Adding %s bean activation-config property %s=%s", ejbName, property, value)); activationConfigProperty = new ActivationConfigProperty(); activationConfigProperty.setActivationConfigPropertyName(property.toString()); activationConfigProperty.setActivationConfigPropertyValue(value.toString()); activationConfigList.add(activationConfigProperty); } } } } return appModule; }  }
ActivationConfigPropertyOverride implements DynamicDeployer { @Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { final Properties system = new Properties(); system.putAll(SystemInstance.get().getProperties()); system.putAll(appModule.getProperties()); system.putAll(JavaSecurityManagers.getSystemProperties()); for (final EjbModule ejbModule : appModule.getEjbModules()) { final EjbJar ejbJar = ejbModule.getEjbJar(); final OpenejbJar openejbJar = ejbModule.getOpenejbJar(); final Properties module = new Properties(); module.putAll(openejbJar.getProperties()); module.putAll(system); final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName(); for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { final String ejbName = bean.getEjbName(); final EjbDeployment ejbDeployment = deployments.get(ejbName); if (!(bean instanceof MessageDrivenBean)) { continue; } final Properties properties = new Properties(); properties.putAll(module); properties.putAll(ejbDeployment.getProperties()); final MessageDrivenBean mdb = (MessageDrivenBean) bean; if (mdb.getActivationConfig() != null) { for (final ActivationConfigProperty property : mdb.getActivationConfig().getActivationConfigProperty()) { final String originalValue = property.getActivationConfigPropertyValue(); final String value = PropertyPlaceHolderHelper.simpleValue(originalValue); if (value != null && !originalValue.equals(value)) { property.setActivationConfigPropertyValue(value); } } } final Properties overrides = new Properties(); final MdbContainerDetails mdbContainer = getMdbContainer(appModule, ejbDeployment.getContainerId(), appModule.getModuleId()); if (mdbContainer != null) { overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.container." + mdbContainer.getContainerId() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(mdbContainer.getProperties(), "activation", "EnterpriseBean")); } overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, mdb.getMessagingType() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbName + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbDeployment.getDeploymentId() + ".activation", "EnterpriseBean")); if (overrides.size() == 0) { continue; } if (mdb.getActivationConfig() == null) { mdb.setActivationConfig(new ActivationConfig()); } final List<ActivationConfigProperty> activationConfigList = mdb.getActivationConfig().getActivationConfigProperty(); for (final Map.Entry<Object, Object> entry : overrides.entrySet()) { final Object property = String.valueOf(entry.getKey()); final Object value = String.valueOf(entry.getValue()); ActivationConfigProperty activationConfigProperty = this.findActivationProperty(activationConfigList, property.toString()); if (activationConfigProperty != null) { logger.info(String.format("Found %s bean with activation-config property %s=%s to override", ejbName, activationConfigProperty.getActivationConfigPropertyName(), activationConfigProperty.getActivationConfigPropertyValue())); logger.info(String.format("Overriding %s bean activation-config property.%s=%s", ejbName, property, value)); activationConfigProperty.setActivationConfigPropertyValue(entry.getValue().toString()); } else { logger.info(String.format("Adding %s bean activation-config property %s=%s", ejbName, property, value)); activationConfigProperty = new ActivationConfigProperty(); activationConfigProperty.setActivationConfigPropertyName(property.toString()); activationConfigProperty.setActivationConfigPropertyValue(value.toString()); activationConfigList.add(activationConfigProperty); } } } } return appModule; }  @Override AppModule deploy(final AppModule appModule); }
ActivationConfigPropertyOverride implements DynamicDeployer { @Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { final Properties system = new Properties(); system.putAll(SystemInstance.get().getProperties()); system.putAll(appModule.getProperties()); system.putAll(JavaSecurityManagers.getSystemProperties()); for (final EjbModule ejbModule : appModule.getEjbModules()) { final EjbJar ejbJar = ejbModule.getEjbJar(); final OpenejbJar openejbJar = ejbModule.getOpenejbJar(); final Properties module = new Properties(); module.putAll(openejbJar.getProperties()); module.putAll(system); final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName(); for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) { final String ejbName = bean.getEjbName(); final EjbDeployment ejbDeployment = deployments.get(ejbName); if (!(bean instanceof MessageDrivenBean)) { continue; } final Properties properties = new Properties(); properties.putAll(module); properties.putAll(ejbDeployment.getProperties()); final MessageDrivenBean mdb = (MessageDrivenBean) bean; if (mdb.getActivationConfig() != null) { for (final ActivationConfigProperty property : mdb.getActivationConfig().getActivationConfigProperty()) { final String originalValue = property.getActivationConfigPropertyValue(); final String value = PropertyPlaceHolderHelper.simpleValue(originalValue); if (value != null && !originalValue.equals(value)) { property.setActivationConfigPropertyValue(value); } } } final Properties overrides = new Properties(); final MdbContainerDetails mdbContainer = getMdbContainer(appModule, ejbDeployment.getContainerId(), appModule.getModuleId()); if (mdbContainer != null) { overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.container." + mdbContainer.getContainerId() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(mdbContainer.getProperties(), "activation", "EnterpriseBean")); } overrides.putAll(ConfigurationFactory.getOverrides(properties, "mdb.activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, mdb.getMessagingType() + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbName + ".activation", "EnterpriseBean")); overrides.putAll(ConfigurationFactory.getOverrides(properties, ejbDeployment.getDeploymentId() + ".activation", "EnterpriseBean")); if (overrides.size() == 0) { continue; } if (mdb.getActivationConfig() == null) { mdb.setActivationConfig(new ActivationConfig()); } final List<ActivationConfigProperty> activationConfigList = mdb.getActivationConfig().getActivationConfigProperty(); for (final Map.Entry<Object, Object> entry : overrides.entrySet()) { final Object property = String.valueOf(entry.getKey()); final Object value = String.valueOf(entry.getValue()); ActivationConfigProperty activationConfigProperty = this.findActivationProperty(activationConfigList, property.toString()); if (activationConfigProperty != null) { logger.info(String.format("Found %s bean with activation-config property %s=%s to override", ejbName, activationConfigProperty.getActivationConfigPropertyName(), activationConfigProperty.getActivationConfigPropertyValue())); logger.info(String.format("Overriding %s bean activation-config property.%s=%s", ejbName, property, value)); activationConfigProperty.setActivationConfigPropertyValue(entry.getValue().toString()); } else { logger.info(String.format("Adding %s bean activation-config property %s=%s", ejbName, property, value)); activationConfigProperty = new ActivationConfigProperty(); activationConfigProperty.setActivationConfigPropertyName(property.toString()); activationConfigProperty.setActivationConfigPropertyValue(value.toString()); activationConfigList.add(activationConfigProperty); } } } } return appModule; }  @Override AppModule deploy(final AppModule appModule);  }