use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class RaStructureProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
if (resourceRoot == null) {
return;
}
final VirtualFile deploymentRoot = resourceRoot.getRoot();
if (deploymentRoot == null || !deploymentRoot.exists()) {
return;
}
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
if (!deploymentRootName.endsWith(RAR_EXTENSION)) {
return;
}
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
moduleSpecification.setPublicModule(true);
//this violates the spec, but everyone expects it to work
ModuleRootMarker.mark(resourceRoot, true);
Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);
try {
final List<VirtualFile> childArchives = deploymentRoot.getChildren(CHILD_ARCHIVE_FILTER);
for (final VirtualFile child : childArchives) {
String relativeName = child.getPathNameRelativeTo(deploymentRoot);
MountedDeploymentOverlay overlay = overlays.get(relativeName);
Closeable closable = NO_OP_CLOSEABLE;
if (overlay != null) {
overlay.remountAsZip(false);
} else if (child.isFile()) {
closable = VFS.mountZip(child, child, TempFileProviderService.provider());
}
final MountHandle mountHandle = new MountHandle(closable);
final ResourceRoot childResource = new ResourceRoot(child, mountHandle);
ModuleRootMarker.mark(childResource);
deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, childResource);
resourceRoot.addToAttachmentList(Attachments.INDEX_IGNORE_PATHS, child.getPathNameRelativeTo(deploymentRoot));
}
} catch (IOException e) {
throw ConnectorLogger.ROOT_LOGGER.failedToProcessRaChild(e, deploymentRoot);
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class StructureDriverProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
for (ResourceRoot resourceRoot : resourceRoots) {
final VirtualFile deploymentRoot = resourceRoot.getRoot();
if (deploymentRoot.getChild("META-INF/services/java.sql.Driver").exists()) {
DEPLOYER_JDBC_LOGGER.debugf("SQL driver detected: %s", deploymentUnit.getName());
break;
}
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class IronJacamarDeploymentParsingProcessor method deploy.
/**
* Process a deployment for iron-jacamar.xml files. Will parse the xml file
* and attach metadata discovered during processing.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*/
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ResourceRoot resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final VirtualFile deploymentRoot = resourceRoot.getRoot();
final boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
IronJacamarXmlDescriptor xmlDescriptor = process(deploymentRoot, resolveProperties);
if (xmlDescriptor != null) {
deploymentUnit.putAttachment(IronJacamarXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class RaDeploymentParsingProcessor 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();
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final boolean resolveProperties = Util.shouldResolveSpec(deploymentUnit);
final VirtualFile file = deploymentRoot.getRoot();
if (file == null || !file.exists())
return;
final String deploymentRootName = file.getName().toLowerCase(Locale.ENGLISH);
if (!deploymentRootName.endsWith(".rar")) {
return;
}
final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_CONNECTOR_DEPLOYMENT_DESCRIPTOR);
String prefix = "";
if (deploymentUnit.getParent() != null) {
prefix = deploymentUnit.getParent().getName() + "#";
}
String deploymentName = prefix + file.getName();
ConnectorXmlDescriptor xmlDescriptor = process(resolveProperties, file, alternateDescriptor, deploymentName);
phaseContext.getDeploymentUnit().putAttachment(ConnectorXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class JSFManagedBeanProcessor method getConfigurationFiles.
public Set<VirtualFile> getConfigurationFiles(DeploymentUnit deploymentUnit) {
final Set<VirtualFile> ret = new HashSet<VirtualFile>();
final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
for (final ResourceRoot resourceRoot : resourceRoots) {
final VirtualFile webInfFacesConfig = resourceRoot.getRoot().getChild(WEB_INF_FACES_CONFIG);
if (webInfFacesConfig.exists()) {
ret.add(webInfFacesConfig);
}
//look for files that end in .faces-config.xml
final VirtualFile metaInf = resourceRoot.getRoot().getChild("META-INF");
if (metaInf.exists() && metaInf.isDirectory()) {
for (final VirtualFile file : metaInf.getChildren()) {
if (file.getName().equals("faces-config.xml") || file.getName().endsWith(".faces-config.xml")) {
ret.add(file);
}
}
}
}
String configFiles = null;
//now look for files in the javax.faces.CONFIG_FILES context param
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData != null) {
final WebMetaData webMetaData = warMetaData.getWebMetaData();
if (webMetaData != null) {
final List<ParamValueMetaData> contextParams = webMetaData.getContextParams();
if (contextParams != null) {
for (final ParamValueMetaData param : contextParams) {
if (param.getParamName().equals(CONFIG_FILES)) {
configFiles = param.getParamValue();
break;
}
}
}
}
}
if (configFiles != null) {
final String[] files = configFiles.split(",");
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
if (deploymentRoot != null) {
for (final String file : files) {
final VirtualFile configFile = deploymentRoot.getRoot().getChild(file);
if (configFile.exists()) {
ret.add(configFile);
}
}
}
}
return ret;
}
Aggregations