Search in sources :

Example 1 with JBossClientMetaData

use of org.jboss.metadata.appclient.jboss.JBossClientMetaData in project wildfly by wildfly.

the class ApplicationClientParsingDeploymentProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit)) {
        return;
    }
    final ApplicationClientMetaData appClientMD = parseAppClient(deploymentUnit, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
    final JBossClientMetaData jbossClientMD = parseJBossClient(deploymentUnit, JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
    final JBossClientMetaData merged;
    if (appClientMD == null && jbossClientMD == null) {
        return;
    } else if (appClientMD == null) {
        merged = jbossClientMD;
    } else {
        merged = new JBossClientMetaData();
        merged.setEnvironmentRefsGroupMetaData(new AppClientEnvironmentRefsGroupMetaData());
        merged.merge(jbossClientMD, appClientMD);
    }
    if (merged.isMetadataComplete()) {
        MetadataCompleteMarker.setMetadataComplete(deploymentUnit, true);
    }
    deploymentUnit.putAttachment(AppClientAttachments.APPLICATION_CLIENT_META_DATA, merged);
    final DeploymentDescriptorEnvironment environment = new DeploymentDescriptorEnvironment("java:module/env/", merged.getEnvironmentRefsGroupMetaData());
    deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT, environment);
    //override module name if applicable
    if (merged.getModuleName() != null && !merged.getModuleName().isEmpty()) {
        final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
        description.setModuleName(merged.getModuleName());
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) ApplicationClientMetaData(org.jboss.metadata.appclient.spec.ApplicationClientMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) JBossClientMetaData(org.jboss.metadata.appclient.jboss.JBossClientMetaData) AppClientEnvironmentRefsGroupMetaData(org.jboss.metadata.appclient.spec.AppClientEnvironmentRefsGroupMetaData)

Example 2 with JBossClientMetaData

use of org.jboss.metadata.appclient.jboss.JBossClientMetaData in project wildfly by wildfly.

the class ApplicationClientParsingDeploymentProcessor method parseJBossClient.

private JBossClientMetaData parseJBossClient(DeploymentUnit deploymentUnit, final PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException {
    final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
    final VirtualFile appXml = deploymentRoot.getChild(JBOSS_CLIENT_XML);
    if (appXml.exists()) {
        InputStream is = null;
        try {
            is = appXml.openStream();
            JBossClientMetaData data = new JBossClientMetaDataParser().parse(getXMLStreamReader(is), propertyReplacer);
            return data;
        } catch (XMLStreamException e) {
            throw AppClientLogger.ROOT_LOGGER.failedToParseXml(e, appXml, e.getLocation().getLineNumber(), e.getLocation().getColumnNumber());
        } catch (IOException e) {
            throw AppClientLogger.ROOT_LOGGER.failedToParseXml(e, appXml);
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (IOException e) {
            // Ignore
            }
        }
    } else {
        //we may already have this info from jboss-all.xml
        return deploymentUnit.getAttachment(AppClientJBossAllParser.ATTACHMENT_KEY);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) JBossClientMetaDataParser(org.jboss.metadata.appclient.parser.jboss.JBossClientMetaDataParser) IOException(java.io.IOException) JBossClientMetaData(org.jboss.metadata.appclient.jboss.JBossClientMetaData)

Aggregations

JBossClientMetaData (org.jboss.metadata.appclient.jboss.JBossClientMetaData)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 JBossClientMetaDataParser (org.jboss.metadata.appclient.parser.jboss.JBossClientMetaDataParser)1 AppClientEnvironmentRefsGroupMetaData (org.jboss.metadata.appclient.spec.AppClientEnvironmentRefsGroupMetaData)1 ApplicationClientMetaData (org.jboss.metadata.appclient.spec.ApplicationClientMetaData)1 VirtualFile (org.jboss.vfs.VirtualFile)1