use of org.jboss.metadata.property.PropertyReplacer in project wildfly by wildfly.
the class EjbResourceInjectionAnnotationProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(EJB_ANNOTATION_NAME);
PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
for (AnnotationInstance annotation : resourceAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(annotation, propertyReplacer);
if (annotationTarget instanceof FieldInfo) {
processField(deploymentUnit, annotationWrapper, (FieldInfo) annotationTarget, moduleDescription);
} else if (annotationTarget instanceof MethodInfo) {
processMethod(deploymentUnit, annotationWrapper, (MethodInfo) annotationTarget, moduleDescription);
} else if (annotationTarget instanceof ClassInfo) {
processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
}
}
final List<AnnotationInstance> ejbsAnnotations = index.getAnnotations(EJBS_ANNOTATION_NAME);
for (AnnotationInstance annotation : ejbsAnnotations) {
final AnnotationTarget annotationTarget = annotation.target();
if (annotationTarget instanceof ClassInfo) {
final AnnotationValue annotationValue = annotation.value();
final AnnotationInstance[] ejbAnnotations = annotationValue.asNestedArray();
for (AnnotationInstance ejbAnnotation : ejbAnnotations) {
final EJBResourceWrapper annotationWrapper = new EJBResourceWrapper(ejbAnnotation, propertyReplacer);
processClass(deploymentUnit, annotationWrapper, (ClassInfo) annotationTarget, moduleDescription);
}
} else {
throw EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(EJBs.class.getName(), annotation.target());
}
}
}
use of org.jboss.metadata.property.PropertyReplacer 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.metadata.property.PropertyReplacer in project wildfly by wildfly.
the class SessionBeanComponentDescriptionFactory method processSessionBeans.
private void processSessionBeans(final DeploymentUnit deploymentUnit, final List<AnnotationInstance> sessionBeanAnnotations, final SessionBeanComponentDescription.SessionBeanType annotatedSessionBeanType) {
final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName();
PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
// process these session bean annotations and create component descriptions out of it
for (final AnnotationInstance sessionBeanAnnotation : sessionBeanAnnotations) {
final AnnotationTarget target = sessionBeanAnnotation.target();
if (!(target instanceof ClassInfo)) {
// Let's just WARN and move on. No need to throw an error
EjbLogger.DEPLOYMENT_LOGGER.warn(EjbLogger.ROOT_LOGGER.annotationOnlyAllowedOnClass(sessionBeanAnnotation.name().toString(), target).getMessage());
continue;
}
final ClassInfo sessionBeanClassInfo = (ClassInfo) target;
// skip if it's not a valid class for session bean
if (!assertSessionBeanClassValidity(sessionBeanClassInfo)) {
continue;
}
final String ejbName = sessionBeanClassInfo.name().local();
final AnnotationValue nameValue = sessionBeanAnnotation.value("name");
final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString());
final SessionBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, SessionBeanMetaData.class);
final SessionBeanComponentDescription.SessionBeanType sessionBeanType;
final String beanClassName;
if (beanMetaData != null) {
beanClassName = override(sessionBeanClassInfo.name().toString(), beanMetaData.getEjbClass());
sessionBeanType = override(annotatedSessionBeanType, descriptionOf(((SessionBeanMetaData) beanMetaData).getSessionType()));
} else {
beanClassName = sessionBeanClassInfo.name().toString();
sessionBeanType = annotatedSessionBeanType;
}
final SessionBeanComponentDescription sessionBeanDescription;
switch(sessionBeanType) {
case STATELESS:
sessionBeanDescription = new StatelessComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, beanMetaData);
break;
case STATEFUL:
sessionBeanDescription = new StatefulComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, beanMetaData);
// If passivation is disabled for the SFSB, either via annotation or via DD, then setup the component
// description appropriately
final boolean passivationCapableAnnotationValue = sessionBeanAnnotation.value("passivationCapable") == null ? true : sessionBeanAnnotation.value("passivationCapable").asBoolean();
final Boolean passivationCapableDeploymentDescriptorValue;
if ((beanMetaData instanceof SessionBean32MetaData)) {
passivationCapableDeploymentDescriptorValue = ((SessionBean32MetaData) beanMetaData).isPassivationCapable();
} else {
passivationCapableDeploymentDescriptorValue = null;
}
final boolean passivationApplicable = override(passivationCapableDeploymentDescriptorValue, passivationCapableAnnotationValue);
((StatefulComponentDescription) sessionBeanDescription).setPassivationApplicable(passivationApplicable);
break;
case SINGLETON:
sessionBeanDescription = new SingletonComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, beanMetaData);
break;
default:
throw EjbLogger.ROOT_LOGGER.unknownSessionBeanType(sessionBeanType.name());
}
addComponent(deploymentUnit, sessionBeanDescription);
}
EjbDeploymentMarker.mark(deploymentUnit);
}
use of org.jboss.metadata.property.PropertyReplacer in project wildfly by wildfly.
the class DsXmlDeploymentParsingProcessor method deploy.
/**
* Process a deployment for standard ra deployment files. Will parse the xml
* file and attach a configuration discovered during processing.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*
*/
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
final PropertyResolver propertyResolver = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_RESOLVER);
final PropertyReplacer propertyReplacer = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_REPLACER);
final Set<VirtualFile> files = dataSources(deploymentUnit);
boolean loggedDeprication = false;
for (VirtualFile f : files) {
InputStream xmlStream = null;
try {
xmlStream = new FileInputStream(f.getPhysicalFile());
DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer);
parser.setSystemPropertiesResolved(resolveProperties);
DataSources dataSources = parser.parse(xmlStream);
if (dataSources != null) {
if (!loggedDeprication) {
loggedDeprication = true;
ConnectorLogger.ROOT_LOGGER.deprecated();
}
for (DataSource ds : dataSources.getDataSource()) {
if (ds.getDriver() == null) {
throw ConnectorLogger.ROOT_LOGGER.FailedDeployDriverNotSpecified(ds.getJndiName());
}
}
deploymentUnit.addToAttachmentList(DATA_SOURCES_ATTACHMENT_KEY, dataSources);
}
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e.getMessage(), e);
} finally {
VFSUtils.safeClose(xmlStream);
}
}
}
use of org.jboss.metadata.property.PropertyReplacer in project wildfly by wildfly.
the class CDIDeploymentProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
if (WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
WeldPortableExtensions extensions = WeldPortableExtensions.getPortableExtensions(parent);
extensions.registerExtensionInstance(new JMSCDIExtension(propertyReplacer), parent);
}
}
Aggregations