use of org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData 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 (!EjbValidationsUtil.assertEjbClassValidity(beanClassInfo).isEmpty()) {
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);
messagingType = beanMetaData.getMessagingType();
final ActivationConfigMetaData activationConfigMetaData = beanMetaData.getActivationConfig();
if (activationConfigMetaData != null) {
final ActivationConfigPropertiesMetaData propertiesMetaData = activationConfigMetaData.getActivationConfigProperties();
if (propertiesMetaData != null) {
for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
activationConfigProperties.put(propertyMetaData.getKey(), propertyMetaData.getValue());
}
}
}
messageListenerInterfaceName = messagingType != null ? messagingType : getMessageListenerInterface(compositeIndex, messageBeanAnnotation, deploymentUnit);
} else {
beanClassName = beanClassInfo.name().toString();
messageListenerInterfaceName = getMessageListenerInterface(compositeIndex, messageBeanAnnotation, deploymentUnit);
}
final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
final MessageDrivenComponentDescription beanDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, messageListenerInterfaceName, activationConfigProperties, defaultResourceAdapterName, beanMetaData, defaultMdbPoolAvailable);
beanDescription.setDeploymentDescriptorEnvironment(deploymentDescriptorEnvironment);
addComponent(deploymentUnit, beanDescription);
final AnnotationValue mappedNameValue = messageBeanAnnotation.value("mappedName");
if (mappedNameValue != null && !mappedNameValue.asString().isEmpty()) {
EjbLogger.ROOT_LOGGER.mappedNameNotSupported(mappedNameValue != null ? mappedNameValue.asString() : "", ejbName);
}
}
EjbDeploymentMarker.mark(deploymentUnit);
}
use of org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData in project wildfly by wildfly.
the class DeploymentDescriptorMethodProcessor method handleSessionBean.
private void handleSessionBean(final EJBComponentDescription component, final Module module, final DeploymentReflectionIndex reflectionIndex) throws ClassNotFoundException, DeploymentUnitProcessingException {
if (component.getDescriptorData() == null) {
return;
}
final Class<?> componentClass = ClassLoadingUtils.loadClass(component.getComponentClassName(), module);
final EnterpriseBeanMetaData metaData = component.getDescriptorData();
AroundInvokesMetaData aroundInvokes = null;
if (metaData instanceof SessionBeanMetaData) {
aroundInvokes = ((SessionBeanMetaData) metaData).getAroundInvokes();
} else if (metaData instanceof MessageDrivenBeanMetaData) {
aroundInvokes = ((MessageDrivenBeanMetaData) metaData).getAroundInvokes();
}
if (aroundInvokes != null) {
for (AroundInvokeMetaData aroundInvoke : aroundInvokes) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
String methodName = aroundInvoke.getMethodName();
MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class);
builder.setAroundInvoke(methodIdentifier);
if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(aroundInvoke.getClassName(), builder.build());
}
}
}
// post-construct(s) of the interceptor configured (if any) in the deployment descriptor
LifecycleCallbacksMetaData postConstructs = metaData.getPostConstructs();
if (postConstructs != null) {
for (LifecycleCallbackMetaData postConstruct : postConstructs) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
String methodName = postConstruct.getMethodName();
MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPostConstruct(methodIdentifier);
if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(postConstruct.getClassName(), builder.build());
}
}
}
// pre-destroy(s) of the interceptor configured (if any) in the deployment descriptor
final LifecycleCallbacksMetaData preDestroys = metaData.getPreDestroys();
if (preDestroys != null) {
for (final LifecycleCallbackMetaData preDestroy : preDestroys) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
final String methodName = preDestroy.getMethodName();
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPreDestroy(methodIdentifier);
if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(preDestroy.getClassName(), builder.build());
}
}
}
if (component.isStateful()) {
final SessionBeanMetaData sessionBeanMetadata = (SessionBeanMetaData) metaData;
// pre-passivate(s) of the interceptor configured (if any) in the deployment descriptor
final LifecycleCallbacksMetaData prePassivates = sessionBeanMetadata.getPrePassivates();
if (prePassivates != null) {
for (final LifecycleCallbackMetaData prePassivate : prePassivates) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
final String methodName = prePassivate.getMethodName();
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPrePassivate(methodIdentifier);
if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(prePassivate.getClassName(), builder.build());
}
}
}
final LifecycleCallbacksMetaData postActivates = sessionBeanMetadata.getPostActivates();
if (postActivates != null) {
for (final LifecycleCallbackMetaData postActivate : postActivates) {
final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
final String methodName = postActivate.getMethodName();
final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName);
builder.setPostActivate(methodIdentifier);
if (postActivate.getClassName() == null || postActivate.getClassName().isEmpty()) {
final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass, methodIdentifier).getDeclaringClass().getName();
component.addInterceptorMethodOverride(className, builder.build());
} else {
component.addInterceptorMethodOverride(postActivate.getClassName(), builder.build());
}
}
}
}
}
use of org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData in project wildfly by wildfly.
the class MessageDrivenBeanRuntimeHandler method executeReadAttribute.
@Override
protected void executeReadAttribute(String attributeName, OperationContext context, MessageDrivenComponent component, PathAddress address) {
final MessageDrivenComponentDescription componentDescription = (MessageDrivenComponentDescription) component.getComponentDescription();
final ModelNode result = context.getResult();
if (DELIVERY_ACTIVE.getName().equals(attributeName)) {
result.set(component.isDeliveryActive());
} else if (MESSAGING_TYPE.getName().equals(attributeName)) {
result.set(componentDescription.getMessageListenerInterfaceName());
} else if (MESSAGE_DESTINATION_TYPE.getName().equals(attributeName)) {
final MessageDrivenBeanMetaData descriptorData = componentDescription.getDescriptorData();
if (descriptorData != null) {
final String destinationType = descriptorData.getMessageDestinationType();
if (destinationType != null) {
result.set(destinationType);
}
}
} else if (MESSAGE_DESTINATION_LINK.getName().equals(attributeName)) {
final MessageDrivenBeanMetaData descriptorData = componentDescription.getDescriptorData();
if (descriptorData != null) {
final String messageDestinationLink = descriptorData.getMessageDestinationLink();
if (messageDestinationLink != null) {
result.set(messageDestinationLink);
}
}
} else if (ACTIVATION_CONFIG.getName().equals(attributeName)) {
final Properties activationProps = componentDescription.getActivationProps();
for (String k : activationProps.stringPropertyNames()) {
result.add(k, activationProps.getProperty(k));
}
} else {
super.executeReadAttribute(attributeName, context, component, address);
}
}
Aggregations