Search in sources :

Example 6 with AssemblyDescriptorMetaData

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);
}
Also used : EJBBoundSecurityMetaData(org.jboss.as.ejb3.security.metadata.EJBBoundSecurityMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)

Example 7 with AssemblyDescriptorMetaData

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));
    }
}
Also used : EJBBoundCacheMetaData(org.jboss.as.ejb3.cache.EJBBoundCacheMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) CacheInfo(org.jboss.as.ejb3.cache.CacheInfo)

Example 8 with AssemblyDescriptorMetaData

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);
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) EJBBoundPoolMetaData(org.jboss.as.ejb3.pool.EJBBoundPoolMetaData)

Example 9 with AssemblyDescriptorMetaData

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);
}
Also used : ApplicationExceptions(org.jboss.as.ejb3.deployment.ApplicationExceptions) ApplicationExceptionDetails(org.jboss.as.ejb3.tx.ApplicationExceptionDetails) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) ApplicationExceptionDescriptions(org.jboss.as.ejb3.deployment.ApplicationExceptionDescriptions) ApplicationExceptionsMetaData(org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) ApplicationExceptionMetaData(org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Map(java.util.Map)

Example 10 with AssemblyDescriptorMetaData

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);
            }
        }
    }
}
Also used : MethodPermissionsMetaData(org.jboss.metadata.ejb.spec.MethodPermissionsMetaData) EjbJaccConfigurator(org.jboss.as.ejb3.security.EjbJaccConfigurator) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) ExcludeListMetaData(org.jboss.metadata.ejb.spec.ExcludeListMetaData)

Aggregations

AssemblyDescriptorMetaData (org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)12 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)12 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 EJBBoundSecurityMetaData (org.jboss.as.ejb3.security.metadata.EJBBoundSecurityMetaData)2 Map (java.util.Map)1 TransactionAttributeType (javax.ejb.TransactionAttributeType)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 CacheInfo (org.jboss.as.ejb3.cache.CacheInfo)1 EJBBoundCacheMetaData (org.jboss.as.ejb3.cache.EJBBoundCacheMetaData)1 EJBBoundClusteringMetaData (org.jboss.as.ejb3.clustering.EJBBoundClusteringMetaData)1 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)1 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)1 EJBBoundMdbDeliveryMetaData (org.jboss.as.ejb3.deliveryactive.metadata.EJBBoundMdbDeliveryMetaData)1 ApplicationExceptionDescriptions (org.jboss.as.ejb3.deployment.ApplicationExceptionDescriptions)1 ApplicationExceptions (org.jboss.as.ejb3.deployment.ApplicationExceptions)1 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)1 EJBBoundPoolMetaData (org.jboss.as.ejb3.pool.EJBBoundPoolMetaData)1 EJBBoundResourceAdapterBindingMetaData (org.jboss.as.ejb3.resourceadapterbinding.metadata.EJBBoundResourceAdapterBindingMetaData)1 EjbJaccConfigurator (org.jboss.as.ejb3.security.EjbJaccConfigurator)1 ApplicationExceptionDetails (org.jboss.as.ejb3.tx.ApplicationExceptionDetails)1