org.jboss.as.server.deployment.DeploymentUnit Java Examples

The following examples show how to use org.jboss.as.server.deployment.DeploymentUnit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DriverDependenciesProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    if (deploymentUnit.hasAttachment(Attachments.RESOURCE_ROOTS)) {
        final List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
        for (ResourceRoot root : resourceRoots) {
            VirtualFile child = root.getRoot().getChild(SERVICE_FILE_NAME);
            if (child.exists()) {
                moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JTA, false, false, false, false));
                break;
            }
        }
    }
}
 
Example #2
Source File: VirtualSecurityDomainProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.getParent() != null || !isVirtualDomainRequired(deploymentUnit)) {
        return;  // Only interested in installation if this is really the root deployment.
    }

    ServiceName virtualDomainName = virtualDomainName(deploymentUnit);
    ServiceTarget serviceTarget = phaseContext.getServiceTarget();

    ServiceBuilder<?> serviceBuilder = serviceTarget.addService(virtualDomainName);

    final SecurityDomain virtualDomain = SecurityDomain.builder().build();
    final Consumer<SecurityDomain> consumer = serviceBuilder.provides(virtualDomainName);

    serviceBuilder.setInstance(Service.newInstance(consumer, virtualDomain));
    serviceBuilder.setInitialMode(Mode.ON_DEMAND);
    serviceBuilder.install();
}
 
Example #3
Source File: KeycloakAdapterConfigDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
    if (service.isSecureDeployment(deploymentUnit) && service.isDeploymentConfigured(deploymentUnit)) {
        addKeycloakAuthData(phaseContext, service);
    }

    addConfigurationListener(phaseContext);

    // FYI, Undertow Extension will find deployments that have auth-method set to KEYCLOAK

    // todo notsure if we need this
    // addSecurityDomain(deploymentUnit, service);
}
 
Example #4
Source File: ProcessEngineStartProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
  
  if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
    return;
  }
  
  List<ProcessesXmlWrapper> processesXmls = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);
  for (ProcessesXmlWrapper wrapper : processesXmls) {            
    for (ProcessEngineXml processEngineXml : wrapper.getProcessesXml().getProcessEngines()) {
      startProcessEngine(processEngineXml, phaseContext);      
    }
  }
  
}
 
Example #5
Source File: KeycloakAdapterConfigDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private String getXML(DeploymentUnit deploymentUnit) throws XMLStreamException {
    ModelNode node = Configuration.INSTANCE.getSecureDeployment(deploymentUnit);
    if (node != null) {
        KeycloakSubsystemParser writer = new KeycloakSubsystemParser();
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        XMLExtendedStreamWriter streamWriter = new FormattingXMLStreamWriter(XMLOutputFactory.newInstance().createXMLStreamWriter(output));
        try {
            streamWriter.writeStartElement("keycloak-saml-adapter");
            writer.writeSps(streamWriter, node);
            streamWriter.writeEndElement();
        } finally {
            streamWriter.close();
        }
        return new String(output.toByteArray(), Charset.forName("utf-8"));
    }
    return null;
}
 
Example #6
Source File: KeycloakProviderDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService config = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (config.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    KeycloakDeploymentInfo info = getKeycloakProviderDeploymentInfo(deploymentUnit);
    if (info.hasServices()) {
        final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
        final ModuleLoader moduleLoader = Module.getBootModuleLoader();
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_SERVER_SPI_PRIVATE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAXRS, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, RESTEASY, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, APACHE, false, false, false, false));
        moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JPA, false, false, false, false));
    }
}
 
Example #7
Source File: AbstractLoggingDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void registerLogContext(final DeploymentUnit deploymentUnit, final AttachmentKey<LogContext> attachmentKey, final Module module, final LogContext logContext) {
    LoggingLogger.ROOT_LOGGER.tracef("Registering LogContext %s for deployment %s", logContext, deploymentUnit.getName());
    if (WildFlySecurityManager.isChecking()) {
        WildFlySecurityManager.doUnchecked(new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                logContextSelector.registerLogContext(module.getClassLoader(), logContext);
                return null;
            }
        });
    } else {
        logContextSelector.registerLogContext(module.getClassLoader(), logContext);
    }
    // Add the log context to the sub-deployment unit for later removal
    deploymentUnit.putAttachment(attachmentKey, logContext);
}
 
Example #8
Source File: KeycloakServerDeploymentProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    KeycloakAdapterConfigService configService = KeycloakAdapterConfigService.INSTANCE;
    String deploymentName = deploymentUnit.getName();

    if (!configService.isKeycloakServerDeployment(deploymentName)) {
        return;
    }

    final EEModuleDescription description = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    String webContext = configService.getWebContext();
    if (webContext == null) {
        throw new DeploymentUnitProcessingException("Can't determine web context/module for Keycloak Server");
    }
    description.setModuleName(webContext);

    addInfinispanCaches(phaseContext);
    addConfiguration(deploymentUnit, configService);
}
 
Example #9
Source File: KeycloakAdapterConfigService.java    From keycloak with Apache License 2.0 6 votes vote down vote up
private String preferredDeploymentName(DeploymentUnit deploymentUnit) {
    String deploymentName = deploymentUnit.getName();
    WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
    if (warMetaData == null) {
        return deploymentName;
    }
    
    JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
    if (webMetaData == null) {
        return deploymentName;
    }
    
    String moduleName = webMetaData.getModuleName();
    if (moduleName != null) return moduleName + ".war";
    
    return deploymentName;
}
 
Example #10
Source File: AnnotationIndexUtils.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Map<ResourceRoot, Index> getAnnotationIndexes(final DeploymentUnit deploymentUnit) {
    final List<ResourceRoot> allResourceRoots = new ArrayList<ResourceRoot>();
    allResourceRoots.addAll(deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS));
    allResourceRoots.add(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT));
    Map<ResourceRoot, Index> indexes = new HashMap<ResourceRoot, Index>();
    for (ResourceRoot resourceRoot : allResourceRoots) {
        if (resourceRoot == null)
            continue;

        Index index = resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX);
        if (index != null) {
            indexes.put(resourceRoot, index);
        }
    }
    return indexes;
}
 
Example #11
Source File: ManifestClassPathProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void handlingExistingClassPathEntry(final ArrayDeque<RootEntry> resourceRoots, final DeploymentUnit topLevelDeployment, final VirtualFile topLevelRoot, final Map<VirtualFile, ResourceRoot> subDeployments, final Map<VirtualFile, AdditionalModuleSpecification> additionalModules, final Set<VirtualFile> existingAccessibleRoots, final ResourceRoot resourceRoot, final Attachable target, final VirtualFile classPathFile) throws DeploymentUnitProcessingException {
    if (existingAccessibleRoots.contains(classPathFile)) {
        ServerLogger.DEPLOYMENT_LOGGER.debugf("Class-Path entry %s in %s ignored, as target is already accessible", classPathFile, resourceRoot.getRoot());
    } else if (additionalModules.containsKey(classPathFile)) {
        final AdditionalModuleSpecification moduleSpecification = additionalModules.get(classPathFile);
        //as class path entries are exported, transitive dependencies will also be available
        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, moduleSpecification.getModuleIdentifier());
    } else if (subDeployments.containsKey(classPathFile)) {
        //now we need to calculate the sub deployment module identifier
        //unfortunately the sub deployment has not been setup yet, so we cannot just
        //get it from the sub deployment directly
        final ResourceRoot otherRoot = subDeployments.get(classPathFile);
        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, ModuleIdentifierProcessor.createModuleIdentifier(otherRoot.getRootName(), otherRoot, topLevelDeployment, topLevelRoot, false));
    } else {
        ModuleIdentifier identifier = createAdditionalModule(resourceRoot, topLevelDeployment, topLevelRoot, additionalModules, classPathFile, resourceRoots);
        target.addToAttachmentList(Attachments.CLASS_PATH_ENTRIES, identifier);
    }
}
 
Example #12
Source File: KeycloakDependencyProcessor.java    From keycloak with Apache License 2.0 6 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if (Configuration.INSTANCE.getSecureDeployment(deploymentUnit) == null) {
        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            return;
        }
        JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
        if (webMetaData == null) {
            return;
        }
        LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
        if (loginConfig == null) return;
        if (loginConfig.getAuthMethod() == null) return;
        if (!loginConfig.getAuthMethod().equals("KEYCLOAK-SAML")) return;
    }

    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    addCommonModules(moduleSpecification, moduleLoader);
    addPlatformSpecificModules(moduleSpecification, moduleLoader);
}
 
Example #13
Source File: ProcessEngineStartProcessor.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
  
  final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
  
  if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
    return;
  }
  
  List<ProcessesXmlWrapper> processesXmls = ProcessApplicationAttachments.getProcessesXmls(deploymentUnit);
  for (ProcessesXmlWrapper wrapper : processesXmls) {            
    for (ProcessEngineXml processEngineXml : wrapper.getProcessesXml().getProcessEngines()) {
      startProcessEngine(processEngineXml, phaseContext);      
    }
  }
  
}
 
Example #14
Source File: LoggingDependencyDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();
    // Add the logging modules
    for (String moduleId : DUP_INJECTED_LOGGING_MODULES) {
        try {
            LoggingLogger.ROOT_LOGGER.tracef("Adding module '%s' to deployment '%s'", moduleId, deploymentUnit.getName());
            moduleLoader.loadModule(moduleId);
            moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleId, false, false, false, false));
        } catch (ModuleLoadException ex) {
            LoggingLogger.ROOT_LOGGER.debugf("Module not found: %s", moduleId);
        }
    }
}
 
Example #15
Source File: ProcessesXmlProcessor.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    if(!ProcessApplicationAttachments.isProcessApplication(deploymentUnit)) {
      return;
    }

    final Module module = deploymentUnit.getAttachment(MODULE);

    // read @ProcessApplication annotation of PA-component
    String[] deploymentDescriptors = getDeploymentDescriptors(deploymentUnit);

    // load all processes.xml files
    List<URL> deploymentDescriptorURLs = getDeploymentDescriptorUrls(module, deploymentDescriptors);

    for (URL processesXmlResource : deploymentDescriptorURLs) {
      VirtualFile processesXmlFile = getFile(processesXmlResource);

      // parse processes.xml metadata.
      ProcessesXml processesXml = null;
      if(isEmptyFile(processesXmlResource)) {
        processesXml = ProcessesXml.EMPTY_PROCESSES_XML;
      } else {
        processesXml = parseProcessesXml(processesXmlResource);
      }

      // add the parsed metadata to the attachment list
      ProcessApplicationAttachments.addProcessesXml(deploymentUnit, new ProcessesXmlWrapper(processesXml, processesXmlFile));
    }
  }
 
Example #16
Source File: Configuration.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public ModelNode getSecureDeployment(DeploymentUnit deploymentUnit) {
    String name = preferredDeploymentName(deploymentUnit);
    ModelNode secureDeployment = config.get("subsystem").get("keycloak-saml").get(Constants.Model.SECURE_DEPLOYMENT);
    if (secureDeployment.hasDefined(name)) {
        return secureDeployment.get(name);
    }
    return null;
}
 
Example #17
Source File: ManifestAttachmentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Process the deployment root for the manifest.
 *
 * @param phaseContext the deployment unit context
 * @throws DeploymentUnitProcessingException
 */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
    for (ResourceRoot resourceRoot : resourceRoots) {
        if (IgnoreMetaInfMarker.isIgnoreMetaInf(resourceRoot)) {
            continue;
        }
        Manifest manifest = getManifest(resourceRoot);
        if (manifest != null)
            resourceRoot.putAttachment(Attachments.MANIFEST, manifest);
    }
}
 
Example #18
Source File: CamelIntegrationProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);

    // No camel dependencies if camel is disabled
    if (!depSettings.isEnabled()) {
        return;
    }

    phaseContext.addDeploymentDependency(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_KEY);
    phaseContext.addDeploymentDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelConstants.CAMEL_CONTEXT_REGISTRY_KEY);
    phaseContext.addDeploymentDependency(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, CamelConstants.CAMEL_CONTEXT_FACTORY_KEY);
}
 
Example #19
Source File: VirtualDomainMarkerUtility.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static DeploymentUnit toRoot(final DeploymentUnit deploymentUnit) {
    DeploymentUnit result = deploymentUnit;
    DeploymentUnit parent = result.getParent();
    while (parent != null) {
        result = parent;
        parent = result.getParent();
    }

    return result;
}
 
Example #20
Source File: DeploymentDependenciesParserV_1_0.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public DeploymentDependencies parse(final XMLExtendedStreamReader reader, final DeploymentUnit deploymentUnit) throws XMLStreamException {
    final DeploymentDependencies dependencies = new DeploymentDependencies();
    final int count = reader.getAttributeCount();
    if (count != 0) {
        throw ParseUtils.unexpectedAttribute(reader, 0);
    }
    // xsd:sequence
    while (reader.hasNext()) {
        switch (reader.nextTag()) {
            case XMLStreamConstants.END_ELEMENT: {
                return dependencies;
            }
            case XMLStreamConstants.START_ELEMENT: {
                final Element element = Element.of(reader.getName());
                switch (element) {
                    case DEPENDENCY:
                        parseDependency(reader, dependencies);
                        break;
                    default:
                        throw ParseUtils.unexpectedElement(reader);
                }
                break;
            }
        }
    }
    throw ParseUtils.unexpectedEndElement(reader);
}
 
Example #21
Source File: KeycloakAdapterConfigService.java    From keycloak with Apache License 2.0 5 votes vote down vote up
protected boolean isDeploymentConfigured(DeploymentUnit deploymentUnit) {
    ModelNode deployment = getSecureDeployment(deploymentUnit);
    if (! deployment.isDefined()) {
        return false;
    }
    ModelNode resource = deployment.get(SecureDeploymentDefinition.RESOURCE.getName());
    return resource.isDefined();
}
 
Example #22
Source File: ModuleExtensionNameProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
public void undeploy(final DeploymentUnit deploymentUnit) {
    final ExtensionInfo extensionInfo = deploymentUnit.getAttachment(Attachments.EXTENSION_INFORMATION);
    if (extensionInfo == null) {
        return;
    }
    // we need to remove the extension on undeploy
    final ServiceController<?> extensionIndexController = deploymentUnit.getServiceRegistry().getRequiredService(
            Services.JBOSS_DEPLOYMENT_EXTENSION_INDEX);
    final ExtensionIndex extensionIndexService = (ExtensionIndex) extensionIndexController.getValue();
    final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);

    extensionIndexService.removeDeployedExtension(extensionInfo.getName(), moduleIdentifier);

}
 
Example #23
Source File: ModuleExtensionNameProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** {@inheritDoc} */
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();

    final ExtensionInfo extensionInfo = deploymentUnit.getAttachment(Attachments.EXTENSION_INFORMATION);
    if (extensionInfo == null) {
        return;
    }
    final ServiceController<?> extensionIndexController = phaseContext.getServiceRegistry().getRequiredService(
            Services.JBOSS_DEPLOYMENT_EXTENSION_INDEX);
    final ExtensionIndex extensionIndexService = (ExtensionIndex) extensionIndexController.getValue();
    final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
    extensionIndexService.addDeployedExtension(moduleIdentifier, extensionInfo);
}
 
Example #24
Source File: CamelDeploymentSettingsBuilderProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private AnnotationInstance getAnnotation(DeploymentUnit depUnit, String className) {
    List<AnnotationInstance> annotations = getAnnotations(depUnit, className);
    if (annotations.size() > 1) {
        LOGGER.warn("Multiple annotations found: {}", annotations);
    }
    return annotations.size() > 0 ? annotations.get(0) : null;
}
 
Example #25
Source File: ProcessApplicationAttachments.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * return true if the deployment unit is either itself a process 
 * application or part of a process application.
 */
public static boolean isPartOfProcessApplication(DeploymentUnit unit) {
  if(isProcessApplication(unit)) {
    return true;
  }
  if(unit.getParent() != null && unit.getParent() != unit) {
    return unit.getParent().hasAttachment(PART_OF_MARKER);
  }
  return false;
}
 
Example #26
Source File: DeploymentDependenciesProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void processDependencies(final DeploymentPhaseContext phaseContext, final DeploymentUnit deploymentUnit) {
    final DeploymentDependencies deps = deploymentUnit.getAttachment(DeploymentDependencies.ATTACHMENT_KEY);
    if (!deps.getDependencies().isEmpty()) {
        for (final String deployment : deps.getDependencies()) {
            final ServiceName name =  DeploymentCompleteServiceProcessor.serviceName(Services.deploymentUnitName(deployment));
            phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, name);
        }
    }
}
 
Example #27
Source File: CDIBeanArchiveProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit depUnit = phaseContext.getDeploymentUnit();

    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    List<DeploymentUnit> subDeployments = depUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);

    // Return if camel disabled or not a CDI deployment
    if (!depSettings.isEnabled() || !WeldDeploymentMarker.isPartOfWeldDeployment(depUnit)) {
        return;
    }

    // Return if we're not an EAR deployment
    if (!DeploymentTypeMarker.isType(DeploymentType.EAR, depUnit)) {
        return;
    }

    // Make sure external bean archives from the camel-cdi module are visible to sub deployments
    List<BeanDeploymentArchiveImpl> deploymentArchives = depUnit.getAttachmentList(WeldAttachments.ADDITIONAL_BEAN_DEPLOYMENT_MODULES);
    BeanDeploymentArchiveImpl rootArchive = depUnit.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE);

    for (BeanDeploymentArchiveImpl bda : deploymentArchives) {
        if (bda.getBeanArchiveType().equals(BeanDeploymentArchiveImpl.BeanArchiveType.EXTERNAL)) {
            for (BeanDeploymentArchive topLevelBda : rootArchive.getBeanDeploymentArchives()) {
                bda.addBeanDeploymentArchive(topLevelBda);
            }
        }

        for (DeploymentUnit subDepUnit : subDeployments) {
            BeanDeploymentArchive subBda = subDepUnit.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE);
            bda.addBeanDeploymentArchive(subBda);
        }
    }
}
 
Example #28
Source File: ModuleSpecProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (deploymentUnit.hasAttachment(Attachments.MODULE))
        return;
    deployModuleSpec(phaseContext);
}
 
Example #29
Source File: DependencyProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
    final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
    final ModuleLoader moduleLoader = Module.getBootModuleLoader();

    moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, elytronIdentifier, false, false, true, false));
}
 
Example #30
Source File: DeploymentStructureDescriptorParser.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void undeploy(final DeploymentUnit context) {
    //any processors from these subsystems that run before this DUP
    //will have run, so we need to clear this to make sure their undeploy
    //will be called
    context.removeAttachment(Attachments.EXCLUDED_SUBSYSTEMS);
}