use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.
the class SecurityDomainMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription description) throws DeploymentUnitProcessingException {
String securityDomain = getJBossAppSecurityDomain(deploymentUnit);
String globalSecurityDomain = null;
final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData != null) {
final AssemblyDescriptorMetaData assemblyMetadata = ejbJarMetaData.getAssemblyDescriptor();
if (assemblyMetadata != null) {
final List<EJBBoundSecurityMetaData> securityMetaDatas = assemblyMetadata.getAny(EJBBoundSecurityMetaData.class);
if (securityMetaDatas != null) {
for (final EJBBoundSecurityMetaData securityMetaData : securityMetaDatas) {
if (securityMetaData.getEjbName().equals(description.getComponentName())) {
securityDomain = securityMetaData.getSecurityDomain();
break;
}
// check global security domain
if (securityMetaData.getEjbName().equals("*")) {
globalSecurityDomain = securityMetaData.getSecurityDomain();
continue;
}
}
}
}
}
if (securityDomain != null)
description.setSecurityDomain(securityDomain);
else if (globalSecurityDomain != null)
description.setSecurityDomain(globalSecurityDomain);
}
use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.
the class CacheMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, StatefulComponentDescription description) throws DeploymentUnitProcessingException {
final String ejbName = description.getEJBName();
final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (metaData == null) {
return;
}
final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor();
if (assemblyDescriptor == null) {
return;
}
// get the pool metadata
final List<EJBBoundCacheMetaData> caches = assemblyDescriptor.getAny(EJBBoundCacheMetaData.class);
String cacheName = null;
if (caches != null) {
for (final EJBBoundCacheMetaData cacheMetaData : caches) {
// for the specific bean (i.e. via an ejb-name match)
if ("*".equals(cacheMetaData.getEjbName()) && cacheName == null) {
cacheName = cacheMetaData.getCacheName();
} else if (ejbName.equals(cacheMetaData.getEjbName())) {
cacheName = cacheMetaData.getCacheName();
}
}
}
if (cacheName != null) {
description.setCache(new CacheInfo(cacheName));
}
}
use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.
the class AbstractPoolMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, T description) throws DeploymentUnitProcessingException {
final String ejbName = description.getEJBName();
final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (metaData == null) {
return;
}
final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor();
if (assemblyDescriptor == null) {
return;
}
// get the pool metadata
final List<EJBBoundPoolMetaData> pools = assemblyDescriptor.getAny(EJBBoundPoolMetaData.class);
String poolName = null;
if (pools != null) {
for (final EJBBoundPoolMetaData poolMetaData : pools) {
// for the specific bean (i.e. via an ejb-name match)
if ("*".equals(poolMetaData.getEjbName()) && poolName == null) {
poolName = poolMetaData.getPoolName();
} else if (ejbName.equals(poolMetaData.getEjbName())) {
poolName = poolMetaData.getPoolName();
}
}
}
if (poolName != null) {
this.setPoolName(description, poolName);
}
}
use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.
the class ApplicationExceptionMergingProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!EjbDeploymentMarker.isEjbDeployment(deploymentUnit)) {
return;
}
final List<DeploymentUnit> accessibleSubDeployments = deploymentUnit.getAttachment(Attachments.ACCESSIBLE_SUB_DEPLOYMENTS);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final ApplicationExceptions applicationExceptions = new ApplicationExceptions();
for (DeploymentUnit unit : accessibleSubDeployments) {
//we want to get the details for classes from all sub deployments we have access to
final ApplicationExceptionDescriptions exceptionDescriptions = unit.getAttachment(EjbDeploymentAttachmentKeys.APPLICATION_EXCEPTION_DESCRIPTIONS);
if (exceptionDescriptions != null) {
for (Map.Entry<String, org.jboss.as.ejb3.tx.ApplicationExceptionDetails> exception : exceptionDescriptions.getApplicationExceptions().entrySet()) {
try {
final Class<?> index = ClassLoadingUtils.loadClass(exception.getKey(), module);
applicationExceptions.addApplicationException(index, exception.getValue());
} catch (ClassNotFoundException e) {
ROOT_LOGGER.debug("Could not load application exception class", e);
}
}
}
}
//now add the exceptions from the assembly descriptor
EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
if (ejbJarMetaData != null) {
// process assembly-descriptor stuff
AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetaData.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
// process application-exception(s)
ApplicationExceptionsMetaData ddAppExceptions = assemblyDescriptor.getApplicationExceptions();
if (ddAppExceptions != null && !ddAppExceptions.isEmpty()) {
for (ApplicationExceptionMetaData applicationException : ddAppExceptions) {
String exceptionClassName = applicationException.getExceptionClass();
try {
final Class<?> index = ClassLoadingUtils.loadClass(exceptionClassName, module);
boolean rollback = applicationException.isRollback();
// by default inherited is true
boolean inherited = applicationException.isInherited() == null ? true : applicationException.isInherited();
// add the application exception to the ejb jar description
applicationExceptions.addApplicationException(index, new ApplicationExceptionDetails(exceptionClassName, inherited, rollback));
} catch (ClassNotFoundException e) {
throw EjbLogger.ROOT_LOGGER.failToLoadAppExceptionClassInEjbJarXml(exceptionClassName, e);
}
}
}
}
}
deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.APPLICATION_EXCEPTION_DETAILS, applicationExceptions);
}
use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.
the class MethodPermissionsMergingProcessor method handleDeploymentDescriptor.
@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentDescription) throws DeploymentUnitProcessingException {
//Add the configurator that calculates JACC permissions
//TODO: should this be elsewhere?
componentDescription.getConfigurators().add(new EjbJaccConfigurator());
//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) {
final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetadata.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
//handle wildcard exclude-list
final ExcludeListMetaData wildCardExcludeList = assemblyDescriptor.getExcludeListByEjbName("*");
if (wildCardExcludeList != null && wildCardExcludeList.getMethods() != null) {
handleExcludeMethods(componentDescription, wildCardExcludeList);
}
//handle ejb-specific exclude-list
final ExcludeListMetaData excludeList = assemblyDescriptor.getExcludeListByEjbName(componentDescription.getEJBName());
if (excludeList != null && excludeList.getMethods() != null) {
handleExcludeMethods(componentDescription, excludeList);
}
//handle wildcard method permissions
final MethodPermissionsMetaData wildCardMethodPermissions = assemblyDescriptor.getMethodPermissionsByEjbName("*");
if (wildCardMethodPermissions != null) {
handleMethodPermissions(componentDescription, wildCardMethodPermissions);
}
//handle ejb-specific method permissions
final MethodPermissionsMetaData methodPermissions = assemblyDescriptor.getMethodPermissionsByEjbName(componentDescription.getEJBName());
if (methodPermissions != null) {
handleMethodPermissions(componentDescription, methodPermissions);
}
}
}
}
Aggregations