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());
}
Aggregations