use of org.apache.openejb.jee.ActivationConfig$JAXB.readActivationConfig in project tomee by apache.
the class MessageDrivenBean$JAXB method _read.
public static final MessageDrivenBean _read(final XoXMLStreamReader reader, RuntimeContext context) throws Exception {
// Check for xsi:nil
if (reader.isXsiNil()) {
return null;
}
if (context == null) {
context = new RuntimeContext();
}
final MessageDrivenBean messageDrivenBean = new MessageDrivenBean();
context.beforeUnmarshal(messageDrivenBean, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
ArrayList<Text> descriptions = null;
ArrayList<Text> displayNames = null;
LocalCollection<Icon> icon = null;
List<Timer> timer = null;
List<AroundInvoke> aroundInvoke = null;
List<AroundTimeout> aroundTimeout = null;
KeyedCollection<String, EnvEntry> envEntry = null;
KeyedCollection<String, EjbRef> ejbRef = null;
KeyedCollection<String, EjbLocalRef> ejbLocalRef = null;
KeyedCollection<String, ServiceRef> serviceRef = null;
KeyedCollection<String, ResourceRef> resourceRef = null;
KeyedCollection<String, ResourceEnvRef> resourceEnvRef = null;
KeyedCollection<String, MessageDestinationRef> messageDestinationRef = null;
KeyedCollection<String, PersistenceContextRef> persistenceContextRef = null;
KeyedCollection<String, PersistenceUnitRef> persistenceUnitRef = null;
List<org.apache.openejb.jee.LifecycleCallback> postConstruct = null;
List<org.apache.openejb.jee.LifecycleCallback> preDestroy = null;
KeyedCollection<String, DataSource> dataSource = null;
List<SecurityRoleRef> securityRoleRef = null;
// Check xsi:type
final QName xsiType = reader.getXsiType();
if (xsiType != null) {
if (("message-driven-beanType" != xsiType.getLocalPart()) || ("http://java.sun.com/xml/ns/javaee" != xsiType.getNamespaceURI())) {
return context.unexpectedXsiType(reader, MessageDrivenBean.class);
}
}
// Read attributes
for (final Attribute attribute : reader.getAttributes()) {
if (("id" == attribute.getLocalName()) && (("" == attribute.getNamespace()) || (attribute.getNamespace() == null))) {
// ATTRIBUTE: id
final String id = Adapters.collapsedStringAdapterAdapter.unmarshal(attribute.getValue());
context.addXmlId(reader, id, messageDrivenBean);
messageDrivenBean.id = id;
} else if (XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI != attribute.getNamespace()) {
context.unexpectedAttribute(attribute, new QName("", "id"));
}
}
// Read elements
for (final XoXMLStreamReader elementReader : reader.getChildElements()) {
if (("description" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: descriptions
final Text descriptionsItem = readText(elementReader, context);
if (descriptions == null) {
descriptions = new ArrayList<Text>();
}
descriptions.add(descriptionsItem);
} else if (("display-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: displayNames
final Text displayNamesItem = readText(elementReader, context);
if (displayNames == null) {
displayNames = new ArrayList<Text>();
}
displayNames.add(displayNamesItem);
} else if (("icon" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: icon
final Icon iconItem = readIcon(elementReader, context);
if (icon == null) {
icon = messageDrivenBean.icon;
if (icon != null) {
icon.clear();
} else {
icon = new LocalCollection<Icon>();
}
}
icon.add(iconItem);
} else if (("ejb-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbName
final String ejbNameRaw = elementReader.getElementAsString();
final String ejbName;
try {
ejbName = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.ejbName = ejbName;
} else if (("mapped-name" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: mappedName
final String mappedNameRaw = elementReader.getElementAsString();
final String mappedName;
try {
mappedName = Adapters.collapsedStringAdapterAdapter.unmarshal(mappedNameRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.mappedName = mappedName;
} else if (("ejb-class" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbClass
final String ejbClassRaw = elementReader.getElementAsString();
final String ejbClass;
try {
ejbClass = Adapters.collapsedStringAdapterAdapter.unmarshal(ejbClassRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.ejbClass = ejbClass;
} else if (("messaging-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messagingType
final String messagingTypeRaw = elementReader.getElementAsString();
final String messagingType;
try {
messagingType = Adapters.collapsedStringAdapterAdapter.unmarshal(messagingTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.messagingType = messagingType;
} else if (("timeout-method" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: timeoutMethod
final NamedMethod timeoutMethod = readNamedMethod(elementReader, context);
messageDrivenBean.timeoutMethod = timeoutMethod;
} else if (("timer" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: timer
final Timer timerItem = readTimer(elementReader, context);
if (timer == null) {
timer = messageDrivenBean.timer;
if (timer != null) {
timer.clear();
} else {
timer = new ArrayList<Timer>();
}
}
timer.add(timerItem);
} else if (("transaction-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: transactionType
final TransactionType transactionType = parseTransactionType(elementReader, context, elementReader.getElementAsString());
if (transactionType != null) {
messageDrivenBean.transactionType = transactionType;
}
} else if (("message-selector" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageSelector
final String messageSelectorRaw = elementReader.getElementAsString();
final String messageSelector;
try {
messageSelector = Adapters.collapsedStringAdapterAdapter.unmarshal(messageSelectorRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
try {
messageDrivenBean.setMessageSelector(messageSelector);
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setMessageSelector", String.class, e);
}
} else if (("acknowledge-mode" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: acknowledgeMode
final String acknowledgeModeRaw = elementReader.getElementAsString();
final String acknowledgeMode;
try {
acknowledgeMode = Adapters.collapsedStringAdapterAdapter.unmarshal(acknowledgeModeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
try {
messageDrivenBean.setAcknowledgeMode(acknowledgeMode);
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setAcknowledgeMode", String.class, e);
}
} else if (("message-driven-destination" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDrivenDestination
final MessageDrivenDestination messageDrivenDestination = readMessageDrivenDestination(elementReader, context);
try {
messageDrivenBean.setMessageDrivenDestination(messageDrivenDestination);
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setMessageDrivenDestination", MessageDrivenDestination.class, e);
}
} else if (("message-destination-type" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationType
final String messageDestinationTypeRaw = elementReader.getElementAsString();
final String messageDestinationType;
try {
messageDestinationType = Adapters.collapsedStringAdapterAdapter.unmarshal(messageDestinationTypeRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.messageDestinationType = messageDestinationType;
} else if (("message-destination-link" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationLink
final String messageDestinationLinkRaw = elementReader.getElementAsString();
final String messageDestinationLink;
try {
messageDestinationLink = Adapters.collapsedStringAdapterAdapter.unmarshal(messageDestinationLinkRaw);
} catch (final Exception e) {
context.xmlAdapterError(elementReader, CollapsedStringAdapter.class, String.class, String.class, e);
continue;
}
messageDrivenBean.messageDestinationLink = messageDestinationLink;
} else if (("activation-config" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: activationConfig
final ActivationConfig activationConfig = readActivationConfig(elementReader, context);
messageDrivenBean.activationConfig = activationConfig;
} else if (("around-invoke" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: aroundInvoke
final AroundInvoke aroundInvokeItem = readAroundInvoke(elementReader, context);
if (aroundInvoke == null) {
aroundInvoke = messageDrivenBean.aroundInvoke;
if (aroundInvoke != null) {
aroundInvoke.clear();
} else {
aroundInvoke = new ArrayList<AroundInvoke>();
}
}
aroundInvoke.add(aroundInvokeItem);
} else if (("around-timeout" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: aroundTimeout
final AroundTimeout aroundTimeoutItem = readAroundTimeout(elementReader, context);
if (aroundTimeout == null) {
aroundTimeout = messageDrivenBean.aroundTimeout;
if (aroundTimeout != null) {
aroundTimeout.clear();
} else {
aroundTimeout = new ArrayList<AroundTimeout>();
}
}
aroundTimeout.add(aroundTimeoutItem);
} else if (("env-entry" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: envEntry
final EnvEntry envEntryItem = readEnvEntry(elementReader, context);
if (envEntry == null) {
envEntry = messageDrivenBean.envEntry;
if (envEntry != null) {
envEntry.clear();
} else {
envEntry = new KeyedCollection<String, EnvEntry>();
}
}
envEntry.add(envEntryItem);
} else if (("ejb-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbRef
final EjbRef ejbRefItem = readEjbRef(elementReader, context);
if (ejbRef == null) {
ejbRef = messageDrivenBean.ejbRef;
if (ejbRef != null) {
ejbRef.clear();
} else {
ejbRef = new KeyedCollection<String, EjbRef>();
}
}
ejbRef.add(ejbRefItem);
} else if (("ejb-local-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: ejbLocalRef
final EjbLocalRef ejbLocalRefItem = readEjbLocalRef(elementReader, context);
if (ejbLocalRef == null) {
ejbLocalRef = messageDrivenBean.ejbLocalRef;
if (ejbLocalRef != null) {
ejbLocalRef.clear();
} else {
ejbLocalRef = new KeyedCollection<String, EjbLocalRef>();
}
}
ejbLocalRef.add(ejbLocalRefItem);
} else if (("service-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: serviceRef
final ServiceRef serviceRefItem = readServiceRef(elementReader, context);
if (serviceRef == null) {
serviceRef = messageDrivenBean.serviceRef;
if (serviceRef != null) {
serviceRef.clear();
} else {
serviceRef = new KeyedCollection<String, ServiceRef>();
}
}
serviceRef.add(serviceRefItem);
} else if (("resource-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resourceRef
final ResourceRef resourceRefItem = readResourceRef(elementReader, context);
if (resourceRef == null) {
resourceRef = messageDrivenBean.resourceRef;
if (resourceRef != null) {
resourceRef.clear();
} else {
resourceRef = new KeyedCollection<String, ResourceRef>();
}
}
resourceRef.add(resourceRefItem);
} else if (("resource-env-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: resourceEnvRef
final ResourceEnvRef resourceEnvRefItem = readResourceEnvRef(elementReader, context);
if (resourceEnvRef == null) {
resourceEnvRef = messageDrivenBean.resourceEnvRef;
if (resourceEnvRef != null) {
resourceEnvRef.clear();
} else {
resourceEnvRef = new KeyedCollection<String, ResourceEnvRef>();
}
}
resourceEnvRef.add(resourceEnvRefItem);
} else if (("message-destination-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: messageDestinationRef
final MessageDestinationRef messageDestinationRefItem = readMessageDestinationRef(elementReader, context);
if (messageDestinationRef == null) {
messageDestinationRef = messageDrivenBean.messageDestinationRef;
if (messageDestinationRef != null) {
messageDestinationRef.clear();
} else {
messageDestinationRef = new KeyedCollection<String, MessageDestinationRef>();
}
}
messageDestinationRef.add(messageDestinationRefItem);
} else if (("persistence-context-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceContextRef
final PersistenceContextRef persistenceContextRefItem = readPersistenceContextRef(elementReader, context);
if (persistenceContextRef == null) {
persistenceContextRef = messageDrivenBean.persistenceContextRef;
if (persistenceContextRef != null) {
persistenceContextRef.clear();
} else {
persistenceContextRef = new KeyedCollection<String, PersistenceContextRef>();
}
}
persistenceContextRef.add(persistenceContextRefItem);
} else if (("persistence-unit-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: persistenceUnitRef
final PersistenceUnitRef persistenceUnitRefItem = readPersistenceUnitRef(elementReader, context);
if (persistenceUnitRef == null) {
persistenceUnitRef = messageDrivenBean.persistenceUnitRef;
if (persistenceUnitRef != null) {
persistenceUnitRef.clear();
} else {
persistenceUnitRef = new KeyedCollection<String, PersistenceUnitRef>();
}
}
persistenceUnitRef.add(persistenceUnitRefItem);
} else if (("post-construct" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: postConstruct
final org.apache.openejb.jee.LifecycleCallback postConstructItem = readLifecycleCallback(elementReader, context);
if (postConstruct == null) {
postConstruct = messageDrivenBean.postConstruct;
if (postConstruct != null) {
postConstruct.clear();
} else {
postConstruct = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
postConstruct.add(postConstructItem);
} else if (("pre-destroy" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: preDestroy
final org.apache.openejb.jee.LifecycleCallback preDestroyItem = readLifecycleCallback(elementReader, context);
if (preDestroy == null) {
preDestroy = messageDrivenBean.preDestroy;
if (preDestroy != null) {
preDestroy.clear();
} else {
preDestroy = new ArrayList<org.apache.openejb.jee.LifecycleCallback>();
}
}
preDestroy.add(preDestroyItem);
} else if (("data-source" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: dataSource
final DataSource dataSourceItem = readDataSource(elementReader, context);
if (dataSource == null) {
dataSource = messageDrivenBean.dataSource;
if (dataSource != null) {
dataSource.clear();
} else {
dataSource = new KeyedCollection<String, DataSource>();
}
}
dataSource.add(dataSourceItem);
} else if (("security-role-ref" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: securityRoleRef
final SecurityRoleRef securityRoleRefItem = readSecurityRoleRef(elementReader, context);
if (securityRoleRef == null) {
securityRoleRef = messageDrivenBean.securityRoleRef;
if (securityRoleRef != null) {
securityRoleRef.clear();
} else {
securityRoleRef = new ArrayList<SecurityRoleRef>();
}
}
securityRoleRef.add(securityRoleRefItem);
} else if (("security-identity" == elementReader.getLocalName()) && ("http://java.sun.com/xml/ns/javaee" == elementReader.getNamespaceURI())) {
// ELEMENT: securityIdentity
final SecurityIdentity securityIdentity = readSecurityIdentity(elementReader, context);
messageDrivenBean.securityIdentity = securityIdentity;
} else {
context.unexpectedElement(elementReader, new QName("http://java.sun.com/xml/ns/javaee", "description"), new QName("http://java.sun.com/xml/ns/javaee", "display-name"), new QName("http://java.sun.com/xml/ns/javaee", "icon"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-name"), new QName("http://java.sun.com/xml/ns/javaee", "mapped-name"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-class"), new QName("http://java.sun.com/xml/ns/javaee", "messaging-type"), new QName("http://java.sun.com/xml/ns/javaee", "timeout-method"), new QName("http://java.sun.com/xml/ns/javaee", "timer"), new QName("http://java.sun.com/xml/ns/javaee", "transaction-type"), new QName("http://java.sun.com/xml/ns/javaee", "message-selector"), new QName("http://java.sun.com/xml/ns/javaee", "acknowledge-mode"), new QName("http://java.sun.com/xml/ns/javaee", "message-driven-destination"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-type"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-link"), new QName("http://java.sun.com/xml/ns/javaee", "activation-config"), new QName("http://java.sun.com/xml/ns/javaee", "around-invoke"), new QName("http://java.sun.com/xml/ns/javaee", "around-timeout"), new QName("http://java.sun.com/xml/ns/javaee", "env-entry"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-ref"), new QName("http://java.sun.com/xml/ns/javaee", "ejb-local-ref"), new QName("http://java.sun.com/xml/ns/javaee", "service-ref"), new QName("http://java.sun.com/xml/ns/javaee", "resource-ref"), new QName("http://java.sun.com/xml/ns/javaee", "resource-env-ref"), new QName("http://java.sun.com/xml/ns/javaee", "message-destination-ref"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-context-ref"), new QName("http://java.sun.com/xml/ns/javaee", "persistence-unit-ref"), new QName("http://java.sun.com/xml/ns/javaee", "post-construct"), new QName("http://java.sun.com/xml/ns/javaee", "pre-destroy"), new QName("http://java.sun.com/xml/ns/javaee", "data-source"), new QName("http://java.sun.com/xml/ns/javaee", "security-role-ref"), new QName("http://java.sun.com/xml/ns/javaee", "security-identity"));
}
}
if (descriptions != null) {
try {
messageDrivenBean.setDescriptions(descriptions.toArray(new Text[descriptions.size()]));
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setDescriptions", Text[].class, e);
}
}
if (displayNames != null) {
try {
messageDrivenBean.setDisplayNames(displayNames.toArray(new Text[displayNames.size()]));
} catch (final Exception e) {
context.setterError(reader, MessageDrivenBean.class, "setDisplayNames", Text[].class, e);
}
}
if (icon != null) {
messageDrivenBean.icon = icon;
}
if (timer != null) {
messageDrivenBean.timer = timer;
}
if (aroundInvoke != null) {
messageDrivenBean.aroundInvoke = aroundInvoke;
}
if (aroundTimeout != null) {
messageDrivenBean.aroundTimeout = aroundTimeout;
}
if (envEntry != null) {
messageDrivenBean.envEntry = envEntry;
}
if (ejbRef != null) {
messageDrivenBean.ejbRef = ejbRef;
}
if (ejbLocalRef != null) {
messageDrivenBean.ejbLocalRef = ejbLocalRef;
}
if (serviceRef != null) {
messageDrivenBean.serviceRef = serviceRef;
}
if (resourceRef != null) {
messageDrivenBean.resourceRef = resourceRef;
}
if (resourceEnvRef != null) {
messageDrivenBean.resourceEnvRef = resourceEnvRef;
}
if (messageDestinationRef != null) {
messageDrivenBean.messageDestinationRef = messageDestinationRef;
}
if (persistenceContextRef != null) {
messageDrivenBean.persistenceContextRef = persistenceContextRef;
}
if (persistenceUnitRef != null) {
messageDrivenBean.persistenceUnitRef = persistenceUnitRef;
}
if (postConstruct != null) {
messageDrivenBean.postConstruct = postConstruct;
}
if (preDestroy != null) {
messageDrivenBean.preDestroy = preDestroy;
}
if (dataSource != null) {
messageDrivenBean.dataSource = dataSource;
}
if (securityRoleRef != null) {
messageDrivenBean.securityRoleRef = securityRoleRef;
}
context.afterUnmarshal(messageDrivenBean, org.metatype.sxc.jaxb.LifecycleCallback.NONE);
return messageDrivenBean;
}
use of org.apache.openejb.jee.ActivationConfig$JAXB.readActivationConfig in project tomee by apache.
the class ActivationConfigPropertyOverride method deploy.
@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;
// override with placeholding
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);
}
}
}
// now try to use special keys
final Properties overrides = 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 we don't have any overrides, skip to the next
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;
}
Aggregations