Search in sources :

Example 1 with AssemblyDescriptorMetaData

use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.

the class TransactionAttributeMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentDescription) throws DeploymentUnitProcessingException {
    // CMT Tx attributes
    // 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) {
        boolean wildcardAttributeSet = false;
        boolean wildcardTimeoutSet = false;
        ContainerTransactionMetaData global = null;
        final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetadata.getAssemblyDescriptor();
        if (assemblyDescriptor != null) {
            final ContainerTransactionsMetaData globalTransactions = assemblyDescriptor.getContainerTransactionsByEjbName("*");
            if (globalTransactions != null) {
                if (globalTransactions.size() > 1) {
                    throw EjbLogger.ROOT_LOGGER.mustOnlyBeSingleContainerTransactionElementWithWildcard();
                }
                global = globalTransactions.iterator().next();
                for (MethodMetaData method : global.getMethods()) {
                    if (!method.getMethodName().equals("*")) {
                        throw EjbLogger.ROOT_LOGGER.wildcardContainerTransactionElementsMustHaveWildcardMethodName();
                    }
                }
            }
            final ContainerTransactionsMetaData containerTransactions = assemblyDescriptor.getContainerTransactionsByEjbName(componentDescription.getEJBName());
            if (containerTransactions != null) {
                for (final ContainerTransactionMetaData containerTx : containerTransactions) {
                    final TransactionAttributeType txAttr = containerTx.getTransAttribute();
                    final Integer timeout = timeout(containerTx);
                    final MethodsMetaData methods = containerTx.getMethods();
                    for (final MethodMetaData method : methods) {
                        final String methodName = method.getMethodName();
                        final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                        final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                        if (methodName.equals("*")) {
                            if (txAttr != null) {
                                wildcardAttributeSet = true;
                                componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, txAttr);
                            }
                            if (timeout != null) {
                                wildcardTimeoutSet = true;
                                componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
                            }
                        } else {
                            final MethodParametersMetaData methodParams = method.getMethodParams();
                            // update the session bean description with the tx attribute info
                            if (methodParams == null) {
                                if (txAttr != null)
                                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, methodName);
                                if (timeout != null)
                                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, methodName);
                            } else {
                                if (txAttr != null)
                                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, null, methodName, this.getMethodParams(methodParams));
                                if (timeout != null)
                                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, null, methodName, this.getMethodParams(methodParams));
                            }
                        }
                    }
                }
            }
        }
        if (global != null) {
            if (!wildcardAttributeSet && global.getTransAttribute() != null) {
                for (MethodMetaData method : global.getMethods()) {
                    final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                    final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, global.getTransAttribute());
                }
            }
            final Integer timeout = timeout(global);
            if (!wildcardTimeoutSet && timeout != null) {
                for (MethodMetaData method : global.getMethods()) {
                    final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                    final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
                }
            }
        }
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) MethodMetaData(org.jboss.metadata.ejb.spec.MethodMetaData) MethodParametersMetaData(org.jboss.metadata.ejb.spec.MethodParametersMetaData) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) ContainerTransactionMetaData(org.jboss.metadata.ejb.spec.ContainerTransactionMetaData) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ContainerTransactionsMetaData(org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) MethodsMetaData(org.jboss.metadata.ejb.spec.MethodsMetaData) TransactionAttributeType(javax.ejb.TransactionAttributeType)

Example 2 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 3 with AssemblyDescriptorMetaData

use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.

the class MissingMethodPermissionsDenyAccessMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, EJBComponentDescription description) throws DeploymentUnitProcessingException {
    Boolean missingMethodPermissionsDenyAccess = null;
    Boolean missingMethodPermissionsDenyAccessApplicableForAllBeans = 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())) {
                        missingMethodPermissionsDenyAccess = securityMetaData.getMissingMethodPermissionsDenyAccess();
                        break;
                    }
                    // check missing-method-permissions-excluded-mode that's applicable for all EJBs.
                    if (securityMetaData.getEjbName().equals("*")) {
                        missingMethodPermissionsDenyAccessApplicableForAllBeans = securityMetaData.getMissingMethodPermissionsDenyAccess();
                        continue;
                    }
                }
            }
        }
    }
    if (missingMethodPermissionsDenyAccess != null) {
        description.setMissingMethodPermissionsDenyAccess(missingMethodPermissionsDenyAccess);
    } else if (missingMethodPermissionsDenyAccessApplicableForAllBeans != null) {
        description.setMissingMethodPermissionsDenyAccess(missingMethodPermissionsDenyAccessApplicableForAllBeans);
    } else {
        description.setMissingMethodPermissionsDenyAccess(denyAccessByDefault);
    }
}
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 4 with AssemblyDescriptorMetaData

use of org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData in project wildfly by wildfly.

the class ResourceAdaptorMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final MessageDrivenComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    final String ejbName = componentConfiguration.getEJBName();
    final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (metaData == null) {
        return;
    }
    final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor();
    if (assemblyDescriptor == null) {
        return;
    }
    final List<EJBBoundResourceAdapterBindingMetaData> resourceAdapterBindingDataList = assemblyDescriptor.getAny(EJBBoundResourceAdapterBindingMetaData.class);
    String configuredAdapterName = null;
    if (resourceAdapterBindingDataList != null) {
        for (EJBBoundResourceAdapterBindingMetaData resourceAdapterBindingData : resourceAdapterBindingDataList) {
            if ("*".equals(resourceAdapterBindingData.getEjbName()) && configuredAdapterName == null) {
                configuredAdapterName = resourceAdapterBindingData.getResourceAdapterName();
            } else if (ejbName.equals(resourceAdapterBindingData.getEjbName())) {
                configuredAdapterName = resourceAdapterBindingData.getResourceAdapterName();
            }
        }
    }
    if (configuredAdapterName != null) {
        final String adapterName = addEarPrefixIfRelativeName(configuredAdapterName, deploymentUnit, componentClass);
        componentConfiguration.setResourceAdapterName(adapterName);
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) EJBBoundResourceAdapterBindingMetaData(org.jboss.as.ejb3.resourceadapterbinding.metadata.EJBBoundResourceAdapterBindingMetaData)

Example 5 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.setDefinedSecurityDomain(securityDomain);
    else if (globalSecurityDomain != null)
        description.setDefinedSecurityDomain(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)

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