Search in sources :

Example 11 with EjbJarMetaData

use of org.jboss.metadata.ejb.spec.EjbJarMetaData 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 12 with EjbJarMetaData

use of org.jboss.metadata.ejb.spec.EjbJarMetaData 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 13 with EjbJarMetaData

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

the class EjbJarParsingDeploymentUnitProcessor method deploy.

/**
     * Finds an ejb-jar.xml (at WEB-INF of a .war or META-INF of a .jar) parses the file and creates
     * metadata out of it. The metadata is then attached to the deployment unit.
     *
     * @param deploymentPhase
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext deploymentPhase) throws DeploymentUnitProcessingException {
    // get hold of the deployment unit.
    final DeploymentUnit deploymentUnit = deploymentPhase.getDeploymentUnit();
    // get the root of the deployment unit
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final EEApplicationClasses applicationClassesDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final EjbJarMetaData ejbJarMetaData;
    final EjbJarMetaData specMetaData = parseEjbJarXml(deploymentUnit);
    final EjbJarMetaData jbossMetaData = parseJBossEjb3Xml(deploymentUnit);
    if (specMetaData == null) {
        if (jbossMetaData == null)
            return;
        ejbJarMetaData = jbossMetaData;
    } else if (jbossMetaData == null) {
        ejbJarMetaData = specMetaData;
    } else {
        ejbJarMetaData = jbossMetaData.createMerged(specMetaData);
    }
    // Mark it as an EJB deployment
    EjbDeploymentMarker.mark(deploymentUnit);
    if (!deploymentUnit.hasAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION)) {
        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        final EjbJarDescription ejbModuleDescription = new EjbJarDescription(moduleDescription, applicationClassesDescription, deploymentUnit.getName().endsWith(".war"));
        deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_DESCRIPTION, ejbModuleDescription);
    }
    // attach the EjbJarMetaData to the deployment unit
    deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA, ejbJarMetaData);
    // if the jboss-ejb3.xml has a distinct-name configured then attach it to the deployment unit
    if (jbossMetaData != null && jbossMetaData.getDistinctName() != null) {
        deploymentUnit.putAttachment(org.jboss.as.ee.structure.Attachments.DISTINCT_NAME, jbossMetaData.getDistinctName());
    }
    if (ejbJarMetaData.getModuleName() != null) {
        eeModuleDescription.setModuleName(ejbJarMetaData.getModuleName());
    }
    if (ejbJarMetaData.isMetadataComplete()) {
        MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
    }
    if (!ejbJarMetaData.isEJB3x()) {
        //EJB spec 20.5.1, we do not process annotations for older deployments
        MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
    }
    if (ejbJarMetaData.getEnterpriseBeans() != null) {
        //check for entity beans
        StringBuilder beans = new StringBuilder();
        boolean error = false;
        for (AbstractEnterpriseBeanMetaData bean : ejbJarMetaData.getEnterpriseBeans()) {
            if (bean.getEjbType() == EjbType.ENTITY) {
                if (!error) {
                    error = true;
                } else {
                    beans.append(", ");
                }
                beans.append(bean.getEjbName());
            }
        }
        if (error) {
            throw EjbLogger.ROOT_LOGGER.entityBeansAreNotSupported(beans.toString());
        }
    }
}
Also used : AbstractEnterpriseBeanMetaData(org.jboss.metadata.ejb.spec.AbstractEnterpriseBeanMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 14 with EjbJarMetaData

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

the class EjbIIOPDeploymentUnitProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!IIOPDeploymentMarker.isIIOPDeployment(deploymentUnit)) {
        return;
    }
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (!EjbDeploymentMarker.isEjbDeployment(deploymentUnit)) {
        return;
    }
    // a bean-name -> IIOPMetaData map, reflecting the assembly descriptor IIOP configuration.
    Map<String, IIOPMetaData> iiopMetaDataMap = new HashMap<String, IIOPMetaData>();
    final EjbJarMetaData ejbMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbMetaData != null && ejbMetaData.getAssemblyDescriptor() != null) {
        List<IIOPMetaData> iiopMetaDatas = ejbMetaData.getAssemblyDescriptor().getAny(IIOPMetaData.class);
        if (iiopMetaDatas != null && iiopMetaDatas.size() > 0) {
            for (IIOPMetaData metaData : iiopMetaDatas) {
                iiopMetaDataMap.put(metaData.getEjbName(), metaData);
            }
        }
    }
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (moduleDescription != null) {
        for (final ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
            if (componentDescription instanceof EJBComponentDescription) {
                final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentDescription;
                if (ejbComponentDescription.getEjbRemoteView() != null && ejbComponentDescription.getEjbHomeView() != null) {
                    // check if there is IIOP metadata for the bean - first using the bean name, then the wildcard "*" if needed.
                    IIOPMetaData iiopMetaData = iiopMetaDataMap.get(ejbComponentDescription.getEJBName());
                    if (iiopMetaData == null) {
                        iiopMetaData = iiopMetaDataMap.get(IIOPMetaData.WILDCARD_BEAN_NAME);
                    }
                    // has been enabled by default in the EJB3 subsystem.
                    if (iiopMetaData != null || settingsService.isEnabledByDefault()) {
                        processEjb(ejbComponentDescription, deploymentReflectionIndex, module, phaseContext.getServiceTarget(), iiopMetaData);
                    }
                }
            }
        }
    }
}
Also used : EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) HashMap(java.util.HashMap) IIOPMetaData(org.jboss.metadata.ejb.jboss.IIOPMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription)

Example 15 with EjbJarMetaData

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

the class AbstractDeploymentModelBuilder method propagateAttachments.

private void propagateAttachments(final DeploymentUnit unit, final ArchiveDeployment dep) {
    dep.addAttachment(DeploymentUnit.class, unit);
    unit.putAttachment(DEPLOYMENT_KEY, dep);
    final JBossWebMetaData webMD = getJBossWebMetaData(unit);
    dep.addAttachment(JBossWebMetaData.class, webMD);
    final WebservicesMetaData webservicesMD = getOptionalAttachment(unit, WEBSERVICES_METADATA_KEY);
    dep.addAttachment(WebservicesMetaData.class, webservicesMD);
    JBossWebservicesMetaData jbossWebservicesMD = getOptionalAttachment(unit, JBOSS_WEBSERVICES_METADATA_KEY);
    if (unit.getParent() != null) {
        jbossWebservicesMD = JBossWebservicesMetaData.merge(getOptionalAttachment(unit.getParent(), JBOSS_WEBSERVICES_METADATA_KEY), jbossWebservicesMD);
    }
    dep.addAttachment(JBossWebservicesMetaData.class, jbossWebservicesMD);
    final JAXWSDeployment jaxwsDeployment = getOptionalAttachment(unit, JAXWS_ENDPOINTS_KEY);
    dep.addAttachment(JAXWSDeployment.class, jaxwsDeployment);
    final EjbJarMetaData ejbJarMD = getOptionalAttachment(unit, EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    dep.addAttachment(EjbJarMetaData.class, ejbJarMD);
    final RejectionRule rr = getOptionalAttachment(unit, REJECTION_RULE_KEY);
    if (rr != null) {
        dep.addAttachment(RejectionRule.class, rr);
    }
}
Also used : JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) ASHelper.getJBossWebMetaData(org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData) RejectionRule(org.jboss.wsf.spi.invocation.RejectionRule) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) JBossWebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData) JBossWebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData) WebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment)

Aggregations

EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)25 AssemblyDescriptorMetaData (org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)12 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)10 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)7 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)5 Module (org.jboss.modules.Module)5 HashMap (java.util.HashMap)4 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)4 Map (java.util.Map)3 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)3 EJBBoundSecurityMetaData (org.jboss.as.ejb3.security.metadata.EJBBoundSecurityMetaData)3 MethodIdentifier (org.jboss.invocation.proxy.MethodIdentifier)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2