Search in sources :

Example 1 with DsXmlParser

use of org.jboss.as.connector.deployers.ds.DsXmlParser in project wildfly by wildfly.

the class DsXmlDeploymentParsingProcessor method deploy.

/**
     * Process a deployment for standard ra deployment files. Will parse the xml
     * file and attach a configuration discovered during processing.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
    final PropertyResolver propertyResolver = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_RESOLVER);
    final PropertyReplacer propertyReplacer = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_REPLACER);
    final Set<VirtualFile> files = dataSources(deploymentUnit);
    boolean loggedDeprication = false;
    for (VirtualFile f : files) {
        InputStream xmlStream = null;
        try {
            xmlStream = new FileInputStream(f.getPhysicalFile());
            DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer);
            parser.setSystemPropertiesResolved(resolveProperties);
            DataSources dataSources = parser.parse(xmlStream);
            if (dataSources != null) {
                if (!loggedDeprication) {
                    loggedDeprication = true;
                    ConnectorLogger.ROOT_LOGGER.deprecated();
                }
                for (DataSource ds : dataSources.getDataSource()) {
                    if (ds.getDriver() == null) {
                        throw ConnectorLogger.ROOT_LOGGER.FailedDeployDriverNotSpecified(ds.getJndiName());
                    }
                }
                deploymentUnit.addToAttachmentList(DATA_SOURCES_ATTACHMENT_KEY, dataSources);
            }
        } catch (Exception e) {
            throw new DeploymentUnitProcessingException(e.getMessage(), e);
        } finally {
            VFSUtils.safeClose(xmlStream);
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) PropertyResolver(org.jboss.metadata.property.PropertyResolver) FileInputStream(java.io.FileInputStream) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource) DataSources(org.jboss.jca.common.api.metadata.ds.DataSources) DsXmlParser(org.jboss.as.connector.deployers.ds.DsXmlParser) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 DsXmlParser (org.jboss.as.connector.deployers.ds.DsXmlParser)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 DataSource (org.jboss.jca.common.api.metadata.ds.DataSource)1 DataSources (org.jboss.jca.common.api.metadata.ds.DataSources)1 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)1 PropertyResolver (org.jboss.metadata.property.PropertyResolver)1 VirtualFile (org.jboss.vfs.VirtualFile)1