use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class EEDefaultPermissionsProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification attachment = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
if (attachment == null) {
return;
}
final List<PermissionFactory> permissions = attachment.getPermissionFactories();
final Enumeration<Permission> e = DEFAULT_PERMISSIONS.elements();
while (e.hasMoreElements()) {
permissions.add(new ImmediatePermissionFactory(e.nextElement()));
}
// make sure they can read the contents of the deployment
ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
try {
File file = root.getRoot().getPhysicalFile();
if (file != null && file.isDirectory()) {
FilePermission permission = new FilePermission(file.getAbsolutePath() + File.separatorChar + "-", "read");
permissions.add(new ImmediatePermissionFactory(permission));
}
} catch (IOException ex) {
throw new DeploymentUnitProcessingException(ex);
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class MessageDestinationInjectionSource method resolve.
public void resolve(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION);
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final Set<String> names = applicationDescription.resolveMessageDestination(messageDestinationName, deploymentRoot.getRoot());
if (names.isEmpty()) {
error = EeLogger.ROOT_LOGGER.noMessageDestination(messageDestinationName, bindingName);
return;
}
if (names.size() > 1) {
error = EeLogger.ROOT_LOGGER.moreThanOneMessageDestination(messageDestinationName, bindingName, names);
return;
}
resolvedLookupName = names.iterator().next();
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class EjbJarParsingDeploymentUnitProcessor method parseEjbJarXml.
private static EjbJarMetaData parseEjbJarXml(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final VirtualFile alternateDescriptor = deploymentRoot.getAttachment(org.jboss.as.ee.structure.Attachments.ALTERNATE_EJB_DEPLOYMENT_DESCRIPTOR);
// this is a bit tri
// Locate the descriptor
final VirtualFile descriptor;
if (alternateDescriptor != null) {
descriptor = alternateDescriptor;
} else {
descriptor = getDescriptor(deploymentUnit, deploymentRoot.getRoot(), EJB_JAR_XML);
}
if (descriptor == null) {
// no descriptor found, nothing to do!
return null;
}
// get the XMLStreamReader and parse the descriptor
MetaDataElementParser.DTDInfo dtdInfo = new MetaDataElementParser.DTDInfo();
InputStream stream = open(descriptor);
try {
XMLStreamReader reader = getXMLStreamReader(stream, descriptor, dtdInfo);
EjbJarMetaData ejbJarMetaData = EjbJarMetaDataParser.parse(reader, dtdInfo, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
return ejbJarMetaData;
} catch (XMLStreamException xmlse) {
throw EjbLogger.ROOT_LOGGER.failedToParse(xmlse, "ejb-jar.xml: " + descriptor.getPathName());
} finally {
try {
stream.close();
} catch (IOException ioe) {
EjbLogger.DEPLOYMENT_LOGGER.failToCloseFile(ioe);
}
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class SarSubDeploymentProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null) {
return;
}
final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot resourceRoot : resourceRoots) {
final VirtualFile rootFile = resourceRoot.getRoot();
if (!SubDeploymentMarker.isSubDeployment(resourceRoot)) {
final VirtualFile sarDescriptor = rootFile.getChild(ServiceDeploymentParsingProcessor.SERVICE_DESCRIPTOR_PATH);
if (sarDescriptor.exists()) {
SubDeploymentMarker.mark(resourceRoot);
ModuleRootMarker.mark(resourceRoot);
}
}
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class SarStructureProcessor method deploy.
@Override
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(SAR_EXTENSION)) {
return;
}
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 SarLogger.ROOT_LOGGER.failedToProcessSarChild(e, deploymentRoot);
}
}
Aggregations