use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class DeploymentDescriptorMethodProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (eeModuleDescription != null) {
for (final ComponentDescription component : eeModuleDescription.getComponentDescriptions()) {
if (component instanceof EJBComponentDescription) {
try {
if (component instanceof SessionBeanComponentDescription || component instanceof MessageDrivenComponentDescription)
handleSessionBean((EJBComponentDescription) component, module, reflectionIndex);
if (component instanceof StatelessComponentDescription || component instanceof MessageDrivenComponentDescription) {
handleStatelessSessionBean((EJBComponentDescription) component, module, reflectionIndex);
}
} catch (ClassNotFoundException e) {
throw EjbLogger.ROOT_LOGGER.failToLoadComponentClass(e, component.getComponentName());
}
}
}
}
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class MessageDrivenComponentDescriptionFactory method processMessageBeans.
private void processMessageBeans(final DeploymentUnit deploymentUnit, final Collection<AnnotationInstance> messageBeanAnnotations, final CompositeIndex compositeIndex) throws DeploymentUnitProcessingException {
if (messageBeanAnnotations.isEmpty())
return;
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
final PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName();
DeploymentDescriptorEnvironment deploymentDescriptorEnvironment = null;
for (final AnnotationInstance messageBeanAnnotation : messageBeanAnnotations) {
final AnnotationTarget target = messageBeanAnnotation.target();
final ClassInfo beanClassInfo = (ClassInfo) target;
if (!assertMDBClassValidity(beanClassInfo)) {
continue;
}
final String ejbName = beanClassInfo.name().local();
final AnnotationValue nameValue = messageBeanAnnotation.value("name");
final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString());
final MessageDrivenBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, MessageDrivenBeanMetaData.class);
final String beanClassName;
final String messageListenerInterfaceName;
final Properties activationConfigProperties = getActivationConfigProperties(messageBeanAnnotation, propertyReplacer);
final String messagingType;
if (beanMetaData != null) {
beanClassName = override(beanClassInfo.name().toString(), beanMetaData.getEjbClass());
deploymentDescriptorEnvironment = new DeploymentDescriptorEnvironment("java:comp/env/", beanMetaData);
if (beanMetaData instanceof MessageDrivenBeanMetaData) {
//It may actually be GenericBeanMetadata instance
final MessageDrivenBeanMetaData mdb = (MessageDrivenBeanMetaData) beanMetaData;
messagingType = mdb.getMessagingType();
final ActivationConfigMetaData activationConfigMetaData = mdb.getActivationConfig();
if (activationConfigMetaData != null) {
final ActivationConfigPropertiesMetaData propertiesMetaData = activationConfigMetaData.getActivationConfigProperties();
if (propertiesMetaData != null) {
for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
activationConfigProperties.put(propertyMetaData.getKey(), propertyMetaData.getValue());
}
}
}
} else if (beanMetaData instanceof JBossGenericBeanMetaData) {
//TODO: fix the hierarchy so this is not needed
final JBossGenericBeanMetaData mdb = (JBossGenericBeanMetaData) beanMetaData;
messagingType = mdb.getMessagingType();
final ActivationConfigMetaData activationConfigMetaData = mdb.getActivationConfig();
if (activationConfigMetaData != null) {
final ActivationConfigPropertiesMetaData propertiesMetaData = activationConfigMetaData.getActivationConfigProperties();
if (propertiesMetaData != null) {
for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
activationConfigProperties.put(propertyMetaData.getKey(), propertyMetaData.getValue());
}
}
}
} else {
messagingType = null;
}
messageListenerInterfaceName = messagingType != null ? messagingType : getMessageListenerInterface(compositeIndex, messageBeanAnnotation);
} else {
beanClassName = beanClassInfo.name().toString();
messageListenerInterfaceName = getMessageListenerInterface(compositeIndex, messageBeanAnnotation);
}
final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
final MessageDrivenComponentDescription beanDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, messageListenerInterfaceName, activationConfigProperties, defaultResourceAdapterName, beanMetaData);
beanDescription.setDeploymentDescriptorEnvironment(deploymentDescriptorEnvironment);
addComponent(deploymentUnit, beanDescription);
}
EjbDeploymentMarker.mark(deploymentUnit);
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class TransactionAttributeMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentDescription) throws DeploymentUnitProcessingException {
// CMT Tx attributes
//DO NOT USE componentConfiguration.getDescriptorData()
//It will return null if there is no <enterprise-beans/> declaration even if there is an assembly descriptor entry
EjbJarMetaData ejbJarMetadata = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetadata != null) {
boolean wildcardAttributeSet = false;
boolean wildcardTimeoutSet = false;
ContainerTransactionMetaData global = null;
final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetadata.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
final ContainerTransactionsMetaData globalTransactions = assemblyDescriptor.getContainerTransactionsByEjbName("*");
if (globalTransactions != null) {
if (globalTransactions.size() > 1) {
throw EjbLogger.ROOT_LOGGER.mustOnlyBeSingleContainerTransactionElementWithWildcard();
}
global = globalTransactions.iterator().next();
for (MethodMetaData method : global.getMethods()) {
if (!method.getMethodName().equals("*")) {
throw EjbLogger.ROOT_LOGGER.wildcardContainerTransactionElementsMustHaveWildcardMethodName();
}
}
}
final ContainerTransactionsMetaData containerTransactions = assemblyDescriptor.getContainerTransactionsByEjbName(componentDescription.getEJBName());
if (containerTransactions != null) {
for (final ContainerTransactionMetaData containerTx : containerTransactions) {
final TransactionAttributeType txAttr = containerTx.getTransAttribute();
final Integer timeout = timeout(containerTx);
final MethodsMetaData methods = containerTx.getMethods();
for (final MethodMetaData method : methods) {
final String methodName = method.getMethodName();
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
if (methodName.equals("*")) {
if (txAttr != null) {
wildcardAttributeSet = true;
componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, txAttr);
}
if (timeout != null) {
wildcardTimeoutSet = true;
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
}
} else {
final MethodParametersMetaData methodParams = method.getMethodParams();
// update the session bean description with the tx attribute info
if (methodParams == null) {
if (txAttr != null)
componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, methodName);
if (timeout != null)
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, methodName);
} else {
if (txAttr != null)
componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, null, methodName, this.getMethodParams(methodParams));
if (timeout != null)
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, null, methodName, this.getMethodParams(methodParams));
}
}
}
}
}
}
if (global != null) {
if (!wildcardAttributeSet && global.getTransAttribute() != null) {
for (MethodMetaData method : global.getMethods()) {
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, global.getTransAttribute());
}
}
final Integer timeout = timeout(global);
if (!wildcardTimeoutSet && timeout != null) {
for (MethodMetaData method : global.getMethods()) {
final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
}
}
}
}
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class ClusteredSingletonMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, MessageDrivenComponentDescription componentDescription) throws DeploymentUnitProcessingException {
final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
Boolean allBeansClusteredSingleton = null;
if (ejbJarMetaData != null) {
final AssemblyDescriptorMetaData assemblyMetadata = ejbJarMetaData.getAssemblyDescriptor();
if (assemblyMetadata != null) {
final List<EJBBoundClusteringMetaData> clusteringMetaDatas = assemblyMetadata.getAny(EJBBoundClusteringMetaData.class);
if (clusteringMetaDatas != null) {
for (final EJBBoundClusteringMetaData clusteringMetaData : clusteringMetaDatas) {
if ("*".equals(clusteringMetaData.getEjbName())) {
allBeansClusteredSingleton = clusteringMetaData.isClusteredSingleton();
} else if (componentDescription.getComponentName().equals(clusteringMetaData.getEjbName())) {
componentDescription.setClusteredSingleton(clusteringMetaData.isClusteredSingleton());
return;
}
}
}
}
}
if (allBeansClusteredSingleton != null && allBeansClusteredSingleton) {
componentDescription.setClusteredSingleton(true);
}
}
use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription in project wildfly by wildfly.
the class MdbDeliveryMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final MessageDrivenComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
final String ejbName = componentConfiguration.getEJBName();
final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (metaData == null) {
return;
}
final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor();
if (assemblyDescriptor == null) {
return;
}
Boolean deliveryActive = null;
String deliveryGroup = null;
final List<EJBBoundMdbDeliveryMetaData> deliveryMetaDataList = assemblyDescriptor.getAny(EJBBoundMdbDeliveryMetaData.class);
if (deliveryMetaDataList != null) {
for (EJBBoundMdbDeliveryMetaData deliveryMetaData : deliveryMetaDataList) {
if ("*".equals(deliveryMetaData.getEjbName()) && deliveryActive == null && deliveryGroup == null) {
deliveryActive = deliveryMetaData.isDeliveryActive();
deliveryGroup = deliveryMetaData.getDeliveryGroup();
} else if (ejbName.equals(deliveryMetaData.getEjbName())) {
deliveryActive = deliveryMetaData.isDeliveryActive();
deliveryGroup = deliveryMetaData.getDeliveryGroup();
}
}
}
// delivery group configuration has precedence over deliveryActive
if (deliveryGroup != null) {
componentConfiguration.setDeliveryGroup(deliveryGroup);
} else if (deliveryActive != null) {
componentConfiguration.setDeliveryActive(deliveryActive);
}
}
Aggregations