Search in sources :

Example 1 with DeploymentMountProvider

use of org.jboss.as.server.deployment.DeploymentMountProvider in project teiid by teiid.

the class FileRootMountProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT) != null || !deploymentUnit.getName().toLowerCase().endsWith(this.fileSuffix)) {
        return;
    }
    final DeploymentMountProvider deploymentMountProvider = deploymentUnit.getAttachment(Attachments.SERVER_DEPLOYMENT_REPOSITORY);
    if (deploymentMountProvider == null) {
        throw new DeploymentUnitProcessingException("No deployment repository available.");
    }
    final VirtualFile deploymentContents = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS);
    // internal deployments do not have any contents, so there is nothing to mount
    if (deploymentContents == null)
        return;
    String deploymentName = deploymentUnit.getName();
    final VirtualFile deploymentRoot = VFS.getChild("content/" + deploymentName);
    Closeable handle = null;
    final MountHandle mountHandle;
    boolean failed = false;
    try {
        handle = deploymentMountProvider.mountDeploymentContent(deploymentContents, deploymentRoot, MountType.REAL);
        mountHandle = new MountHandle(handle);
    } catch (IOException e) {
        failed = true;
        throw new DeploymentUnitProcessingException("Failed to mount " + this.fileSuffix + " file", e);
    } finally {
        if (failed) {
            VFSUtils.safeClose(handle);
        }
    }
    final ResourceRoot resourceRoot = new ResourceRoot(deploymentRoot, mountHandle);
    ModuleRootMarker.mark(resourceRoot);
    deploymentUnit.putAttachment(Attachments.DEPLOYMENT_ROOT, resourceRoot);
    deploymentUnit.putAttachment(Attachments.MODULE_SPECIFICATION, new ModuleSpecification());
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentMountProvider(org.jboss.as.server.deployment.DeploymentMountProvider) MountHandle(org.jboss.as.server.deployment.module.MountHandle) Closeable(java.io.Closeable) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 DeploymentMountProvider (org.jboss.as.server.deployment.DeploymentMountProvider)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)1 MountHandle (org.jboss.as.server.deployment.module.MountHandle)1 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)1 VirtualFile (org.jboss.vfs.VirtualFile)1