Search in sources :

Example 66 with ResourceRoot

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);
    }
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Index(org.jboss.jandex.Index) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 67 with ResourceRoot

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);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL)

Example 68 with ResourceRoot

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;
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot)

Example 69 with ResourceRoot

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();
}
Also used : EEApplicationDescription(org.jboss.as.ee.component.EEApplicationDescription) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 70 with ResourceRoot

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);
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ImmediatePermissionFactory(org.jboss.modules.security.ImmediatePermissionFactory) PermissionFactory(org.jboss.modules.security.PermissionFactory) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) Permission(java.security.Permission) FilePermission(java.io.FilePermission) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) ImmediatePermissionFactory(org.jboss.modules.security.ImmediatePermissionFactory) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) File(java.io.File) FilePermission(java.io.FilePermission)

Aggregations

ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)71 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)49 VirtualFile (org.jboss.vfs.VirtualFile)37 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)12 HashMap (java.util.HashMap)10 PersistenceUnitMetadataHolder (org.jboss.as.jpa.config.PersistenceUnitMetadataHolder)10 WarMetaData (org.jboss.as.web.common.WarMetaData)10 MountHandle (org.jboss.as.server.deployment.module.MountHandle)9 Index (org.jboss.jandex.Index)8 Closeable (java.io.Closeable)7 URL (java.net.URL)7 HashSet (java.util.HashSet)7 Module (org.jboss.modules.Module)7 InputStream (java.io.InputStream)6 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)6 ServiceName (org.jboss.msc.service.ServiceName)6 XMLStreamException (javax.xml.stream.XMLStreamException)5 EEApplicationDescription (org.jboss.as.ee.component.EEApplicationDescription)5