Search in sources :

Example 6 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class ManagedBeanSubDeploymentMarkingProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot resourceRoot : potentialSubDeployments) {
        if (ModuleRootMarker.isModuleRoot(resourceRoot)) {
            // module roots cannot be managed bean jars
            continue;
        }
        final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
        if (index != null) {
            if (!index.getAnnotations(MANAGED_BEAN).isEmpty()) {
                //this is a managed bean deployment
                SubDeploymentMarker.mark(resourceRoot);
                ModuleRootMarker.mark(resourceRoot);
            }
        }
    }
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Index(org.jboss.jandex.Index) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 7 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class EjbInjectionSource method getViews.

private Set<ViewDescription> getViews() {
    final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION);
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
    final Set<ViewDescription> componentsForViewName;
    if (beanName != null) {
        componentsForViewName = applicationDescription.getComponents(beanName, typeName, deploymentRoot.getRoot());
    } else {
        componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot());
    }
    return componentsForViewName;
}
Also used : EEApplicationDescription(org.jboss.as.ee.component.EEApplicationDescription) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription)

Example 8 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class RaOperationUtil method installRaServicesAndDeployFromModule.

public static void installRaServicesAndDeployFromModule(OperationContext context, String name, ModifiableResourceAdapter resourceAdapter, String fullModuleName, final List<ServiceController<?>> newControllers) throws OperationFailedException {
    ServiceName raServiceName = installRaServices(context, name, resourceAdapter, newControllers);
    final boolean resolveProperties = true;
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final String moduleName;
    //load module
    String slot = "main";
    if (fullModuleName.contains(":")) {
        slot = fullModuleName.substring(fullModuleName.indexOf(":") + 1);
        moduleName = fullModuleName.substring(0, fullModuleName.indexOf(":"));
    } else {
        moduleName = fullModuleName;
    }
    Module module;
    try {
        ModuleIdentifier moduleId = ModuleIdentifier.create(moduleName, slot);
        module = Module.getCallerModuleLoader().loadModule(moduleId);
    } catch (ModuleLoadException e) {
        throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToLoadModuleRA(moduleName), e);
    }
    URL path = module.getExportedResource("META-INF/ra.xml");
    Closeable closable = null;
    try {
        VirtualFile child;
        if (path.getPath().contains("!")) {
            throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.compressedRarNotSupportedInModuleRA(moduleName));
        } else {
            child = VFS.getChild(path.getPath().split("META-INF")[0]);
            closable = VFS.mountReal(new File(path.getPath().split("META-INF")[0]), child);
        }
        //final Closeable closable = VFS.mountZip((InputStream) new JarInputStream(new FileInputStream(path.getPath().split("!")[0].split(":")[1])), path.getPath().split("!")[0].split(":")[1], child, TempFileProviderService.provider());
        final MountHandle mountHandle = new MountHandle(closable);
        final ResourceRoot resourceRoot = new ResourceRoot(child, mountHandle);
        final VirtualFile deploymentRoot = resourceRoot.getRoot();
        if (deploymentRoot == null || !deploymentRoot.exists())
            return;
        ConnectorXmlDescriptor connectorXmlDescriptor = RaDeploymentParsingProcessor.process(resolveProperties, deploymentRoot, null, name);
        IronJacamarXmlDescriptor ironJacamarXmlDescriptor = IronJacamarDeploymentParsingProcessor.process(deploymentRoot, resolveProperties);
        RaNativeProcessor.process(deploymentRoot);
        Map<ResourceRoot, Index> annotationIndexes = new HashMap<ResourceRoot, Index>();
        ResourceRootIndexer.indexResourceRoot(resourceRoot);
        Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
        if (index != null) {
            annotationIndexes.put(resourceRoot, index);
        }
        if (ironJacamarXmlDescriptor != null) {
            ConnectorLogger.SUBSYSTEM_RA_LOGGER.forceIJToNull();
            ironJacamarXmlDescriptor = null;
        }
        final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName());
        final ServiceController<?> deployerService = context.getServiceRegistry(true).getService(deployerServiceName);
        if (deployerService == null) {
            ServiceBuilder builder = ParsedRaDeploymentProcessor.process(connectorXmlDescriptor, ironJacamarXmlDescriptor, module.getClassLoader(), serviceTarget, annotationIndexes, RAR_MODULE.append(name), null, null);
            newControllers.add(builder.addDependency(raServiceName).setInitialMode(ServiceController.Mode.ACTIVE).install());
        }
        String rarName = resourceAdapter.getArchive();
        if (fullModuleName.equals(rarName)) {
            ServiceName serviceName = ConnectorServices.INACTIVE_RESOURCE_ADAPTER_SERVICE.append(name);
            InactiveResourceAdapterDeploymentService service = new InactiveResourceAdapterDeploymentService(connectorXmlDescriptor, module, name, name, RAR_MODULE.append(name), null, serviceTarget, null);
            newControllers.add(serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).install());
        }
    } catch (Exception e) {
        throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToLoadModuleRA(moduleName), e);
    } finally {
        if (closable != null) {
            try {
                closable.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) VirtualFile(org.jboss.vfs.VirtualFile) InactiveResourceAdapterDeploymentService(org.jboss.as.connector.services.resourceadapters.deployment.InactiveResourceAdapterDeploymentService) MountHandle(org.jboss.as.server.deployment.module.MountHandle) HashMap(java.util.HashMap) ServiceTarget(org.jboss.msc.service.ServiceTarget) Closeable(java.io.Closeable) OperationFailedException(org.jboss.as.controller.OperationFailedException) ConnectorXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.ConnectorXmlDescriptor) Index(org.jboss.jandex.Index) IOException(java.io.IOException) URL(java.net.URL) IOException(java.io.IOException) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModuleLoadException(org.jboss.modules.ModuleLoadException) ValidateException(org.jboss.jca.common.api.validator.ValidateException) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ServiceName(org.jboss.msc.service.ServiceName) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) IronJacamarXmlDescriptor(org.jboss.as.connector.metadata.xmldescriptors.IronJacamarXmlDescriptor) Module(org.jboss.modules.Module) File(java.io.File) VirtualFile(org.jboss.vfs.VirtualFile)

Example 9 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class ComponentTypeInjectionSource method getResourceValue.

public void getResourceValue(final ResolutionContext resolutionContext, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(EE_APPLICATION_DESCRIPTION);
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
    final Set<ViewDescription> componentsForViewName = applicationDescription.getComponentsForViewName(typeName, deploymentRoot.getRoot());
    final Iterator<ViewDescription> iterator = componentsForViewName.iterator();
    if (!iterator.hasNext()) {
        throw EeLogger.ROOT_LOGGER.componentNotFound(typeName);
    }
    final ViewDescription description = iterator.next();
    if (iterator.hasNext()) {
        throw EeLogger.ROOT_LOGGER.multipleComponentsFound(typeName);
    }
    //TODO: should ComponentView also be a managed reference factory?
    serviceBuilder.addDependency(description.getServiceName(), ComponentView.class, new ViewManagedReferenceFactory.Injector(injector));
}
Also used : ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 10 with ResourceRoot

use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.

the class EjbJarDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
    if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    //cause this could come from a jboss-app.xml instead
    if (deploymentRoot.getRoot().getChild("META-INF/application.xml").exists()) {
        //if we have an application.xml we don't scan
        return;
    }
    // TODO: deal with application clients, we need the manifest information
    List<ResourceRoot> potentialSubDeployments = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
    for (ResourceRoot resourceRoot : potentialSubDeployments) {
        if (ModuleRootMarker.isModuleRoot(resourceRoot)) {
            // module roots cannot be ejb jars
            continue;
        }
        VirtualFile ejbJarFile = resourceRoot.getRoot().getChild("META-INF/ejb-jar.xml");
        if (ejbJarFile.exists()) {
            SubDeploymentMarker.mark(resourceRoot);
            ModuleRootMarker.mark(resourceRoot);
        } else {
            final Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
            if (index != null) {
                if (!index.getAnnotations(STATEFUL).isEmpty() || !index.getAnnotations(STATELESS).isEmpty() || !index.getAnnotations(MESSAGE_DRIVEN).isEmpty() || !index.getAnnotations(SINGLETON).isEmpty()) {
                    //this is an EJB deployment
                    //TODO: we need to mark EJB sub deployments so the sub deployers know they are EJB deployments
                    SubDeploymentMarker.mark(resourceRoot);
                    ModuleRootMarker.mark(resourceRoot);
                }
            }
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) Index(org.jboss.jandex.Index) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

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