use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.
the class AbstractDeploymentUnitProcessor method getEjbJarDescription.
protected static EjbJarDescription getEjbJarDescription(final DeploymentUnit deploymentUnit) {
EjbJarDescription ejbJarDescription = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION);
final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
if (ejbJarDescription == null) {
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
ejbJarDescription = new EjbJarDescription(moduleDescription, applicationClassesDescription, deploymentUnit.getName().endsWith(".war"));
deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbJarDescription);
}
return ejbJarDescription;
}
use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.
the class AbstractDeploymentUnitProcessor method processDeploymentDescriptor.
protected void processDeploymentDescriptor(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
// find the EJB jar metadata and start processing it
final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData == null) {
return;
}
final SimpleSet<String> annotatedEJBs;
if (appclient) {
final List<ComponentDescription> additionalComponents = deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS);
annotatedEJBs = new SimpleSet<String>() {
@Override
public boolean contains(Object o) {
for (final ComponentDescription component : additionalComponents) {
if (component.getComponentName().equals(o)) {
return true;
}
}
return false;
}
};
} else {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
annotatedEJBs = new SimpleSet<String>() {
@Override
public boolean contains(Object o) {
return ejbJarDescription.hasComponent((String) o);
}
};
}
// process EJBs
final EnterpriseBeansMetaData ejbs = ejbJarMetaData.getEnterpriseBeans();
if (ejbs != null && !ejbs.isEmpty()) {
for (final EnterpriseBeanMetaData ejb : ejbs) {
final String beanName = ejb.getName();
// the important bit is to skip already processed EJBs via annotations
if (annotatedEJBs.contains(beanName)) {
continue;
}
processBeanMetaData(deploymentUnit, ejb);
}
}
EjbDeploymentMarker.mark(deploymentUnit);
}
use of org.jboss.as.ejb3.deployment.EjbJarDescription 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.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.
the class SessionBeanComponentDescriptionFactory method processSessionBeanMetaData.
private void processSessionBeanMetaData(final DeploymentUnit deploymentUnit, final SessionBeanMetaData sessionBean) throws DeploymentUnitProcessingException {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
final CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
final String beanName = sessionBean.getName();
SessionType sessionType = sessionBean.getSessionType();
if (sessionType == null && sessionBean instanceof GenericBeanMetaData) {
final GenericBeanMetaData bean = (GenericBeanMetaData) sessionBean;
if (bean.getEjbType() == EjbType.SESSION) {
sessionType = determineSessionType(sessionBean.getEjbClass(), compositeIndex);
if (sessionType == null) {
throw EjbLogger.ROOT_LOGGER.sessionTypeNotSpecified(beanName);
}
} else {
// it is not a session bean, so we ignore it
return;
}
} else if (sessionType == null) {
sessionType = determineSessionType(sessionBean.getEjbClass(), compositeIndex);
if (sessionType == null) {
throw EjbLogger.ROOT_LOGGER.sessionTypeNotSpecified(beanName);
}
}
final String beanClassName = sessionBean.getEjbClass();
final SessionBeanComponentDescription sessionBeanDescription;
switch(sessionType) {
case Stateless:
sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean, defaultSlsbPoolAvailable);
break;
case Stateful:
sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean);
if (sessionBean instanceof SessionBean32MetaData && ((SessionBean32MetaData) sessionBean).isPassivationCapable() != null) {
((StatefulComponentDescription) sessionBeanDescription).setPassivationApplicable(((SessionBean32MetaData) sessionBean).isPassivationCapable());
}
break;
case Singleton:
sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit, sessionBean);
break;
default:
throw EjbLogger.ROOT_LOGGER.unknownSessionBeanType(sessionType.name());
}
addComponent(deploymentUnit, sessionBeanDescription);
}
use of org.jboss.as.ejb3.deployment.EjbJarDescription in project wildfly by wildfly.
the class AssemblyDescriptorProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
// get the deployment unit
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
// find the Jakarta Enterprise Beans jar metadata and start processing it
final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData == null) {
return;
}
// process assembly-descriptor stuff
final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetaData.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
// get hold of the ejb jar description (to which we'll be adding this assembly description metadata)
final EjbJarDescription ejbJarDescription = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION);
final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
// process security-role(s)
this.processSecurityRoles(assemblyDescriptor.getSecurityRoles(), ejbJarDescription);
final MessageDestinationsMetaData destinations = assemblyDescriptor.getMessageDestinations();
if (destinations != null) {
processMessageDestinations(destinations, eeModuleDescription);
}
}
}
Aggregations