use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class WSHandlerChainAnnotationProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
List<ResourceRoot> resourceRoots = ASHelper.getResourceRoots(unit);
if (resourceRoots == null) {
return;
}
final WSEndpointHandlersMapping mapping = new WSEndpointHandlersMapping();
Index index = null;
for (final ResourceRoot resourceRoot : resourceRoots) {
index = resourceRoot.getAttachment(ANNOTATION_INDEX);
if (index != null) {
// process @HandlerChain annotations
processHandlerChainAnnotations(resourceRoot, resourceRoots, index, mapping);
}
}
if (!mapping.isEmpty()) {
unit.putAttachment(WS_ENDPOINT_HANDLERS_MAPPING_KEY, mapping);
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class WSHandlerChainAnnotationProcessor method getInputStream.
private static InputStream getInputStream(final ResourceRoot currentResourceRoot, final List<ResourceRoot> resourceRoots, final String handlerChainConfigFile, final String annotatedClassName) throws IOException {
if (handlerChainConfigFile.startsWith("file://") || handlerChainConfigFile.startsWith("http://")) {
return new URL(handlerChainConfigFile).openStream();
} else {
URI classURI = null;
try {
classURI = new URI(annotatedClassName.replace('.', '/'));
} catch (final URISyntaxException ignore) {
}
final String handlerChainConfigFileResourcePath = classURI.resolve(handlerChainConfigFile).toString();
VirtualFile config = currentResourceRoot.getRoot().getChild(handlerChainConfigFileResourcePath);
if (config.exists() && config.isFile()) {
return config.openStream();
} else {
for (ResourceRoot rr : resourceRoots) {
config = rr.getRoot().getChild(handlerChainConfigFileResourcePath);
if (config.exists() && config.isFile()) {
return config.openStream();
}
}
}
throw WSLogger.ROOT_LOGGER.missingHandlerChainConfigFile(handlerChainConfigFileResourcePath, currentResourceRoot);
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class ASHelper method getResourceRoots.
public static List<ResourceRoot> getResourceRoots(DeploymentUnit unit) {
// wars define resource roots
AttachmentList<ResourceRoot> resourceRoots = unit.getAttachment(RESOURCE_ROOTS);
if (!unit.getName().endsWith(".war") && EjbDeploymentMarker.isEjbDeployment(unit)) {
// ejb archives don't define resource roots, using root resource
resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class);
final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT);
resourceRoots.add(root);
}
return resourceRoots;
}
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 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);
}
}
Aggregations