Search in sources :

Example 1 with ApplicationClientMetaDataParser

use of org.jboss.metadata.appclient.parser.spec.ApplicationClientMetaDataParser in project wildfly by wildfly.

the class ApplicationClientParsingDeploymentProcessor method parseAppClient.

private ApplicationClientMetaData parseAppClient(DeploymentUnit deploymentUnit, final PropertyReplacer propertyReplacer) throws DeploymentUnitProcessingException {
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_CLIENT_DEPLOYMENT_DESCRIPTOR);
    // Locate the descriptor
    final VirtualFile descriptor;
    if (alternateDescriptor != null) {
        descriptor = alternateDescriptor;
    } else {
        descriptor = deploymentRoot.getRoot().getChild(APP_XML);
    }
    if (descriptor.exists()) {
        InputStream is = null;
        try {
            is = descriptor.openStream();
            ApplicationClientMetaData data = new ApplicationClientMetaDataParser().parse(getXMLStreamReader(is), propertyReplacer);
            return data;
        } catch (XMLStreamException e) {
            throw AppClientLogger.ROOT_LOGGER.failedToParseXml(e, descriptor, e.getLocation().getLineNumber(), e.getLocation().getColumnNumber());
        } catch (IOException e) {
            throw new DeploymentUnitProcessingException("Failed to parse " + descriptor, e);
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } catch (IOException e) {
            // Ignore
            }
        }
    } else {
        return null;
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) XMLStreamException(javax.xml.stream.XMLStreamException) InputStream(java.io.InputStream) ApplicationClientMetaData(org.jboss.metadata.appclient.spec.ApplicationClientMetaData) IOException(java.io.IOException) ApplicationClientMetaDataParser(org.jboss.metadata.appclient.parser.spec.ApplicationClientMetaDataParser)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)1 ApplicationClientMetaDataParser (org.jboss.metadata.appclient.parser.spec.ApplicationClientMetaDataParser)1 ApplicationClientMetaData (org.jboss.metadata.appclient.spec.ApplicationClientMetaData)1 VirtualFile (org.jboss.vfs.VirtualFile)1