Search in sources :

Example 11 with DeploymentUnit

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

the class JaccEarDeploymentProcessor method deploy.

/**
     * {@inheritDoc}
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    AbstractSecurityDeployer<?> deployer = null;
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        deployer = new EarSecurityDeployer();
        JaccService<?> service = deployer.deploy(deploymentUnit);
        if (service != null) {
            final ServiceName jaccServiceName = deploymentUnit.getServiceName().append(JaccService.SERVICE_NAME);
            final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
            ServiceBuilder<?> builder = serviceTarget.addService(jaccServiceName, service);
            if (deploymentUnit.getParent() != null) {
                // add dependency to parent policy
                final DeploymentUnit parentDU = deploymentUnit.getParent();
                builder.addDependency(parentDU.getServiceName().append(JaccService.SERVICE_NAME), PolicyConfiguration.class, service.getParentPolicyInjector());
            }
            builder.setInitialMode(Mode.ACTIVE).install();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 12 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.

the class CamelContextActivationProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    if (!depSettings.isEnabled()) {
        return;
    }
    String runtimeName = depUnit.getName();
    ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    ServiceName camelActivationServiceName = depUnit.getServiceName().append(CAMEL_CONTEXT_ACTIVATION_SERVICE_NAME.append(runtimeName));
    List<SpringCamelContextBootstrap> camelctxBootstrapList = depUnit.getAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY);
    CamelContextActivationService activationService = new CamelContextActivationService(camelctxBootstrapList, runtimeName);
    ServiceBuilder builder = serviceTarget.addService(camelActivationServiceName, activationService);
    // Ensure all camel contexts in the deployment are started before constructing servlets etc
    depUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, camelActivationServiceName);
    // Add JNDI binding dependencies to CamelContextActivationService
    for (SpringCamelContextBootstrap bootstrap : camelctxBootstrapList) {
        for (String jndiName : bootstrap.getJndiNames()) {
            if (jndiName.startsWith("${")) {
                // Don't add the binding if it appears to be a Spring property placeholder value
                // these can't be resolved before refresh() has been called on the ApplicationContext
                LOGGER.warn("Skipping JNDI binding dependency for property placeholder value: {}", jndiName);
            } else {
                LOGGER.debug("Add CamelContextActivationService JNDI binding dependency for {}", jndiName);
                installBindingDependency(builder, jndiName);
            }
        }
    }
    builder.install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) CamelContextActivationService(org.wildfly.extension.camel.service.CamelContextActivationService) SpringCamelContextBootstrap(org.wildfly.extension.camel.SpringCamelContextBootstrap) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Example 13 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.

the class CamelContextDescriptorsProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    final String runtimeName = depUnit.getName();
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    if (depSettings.isDisabledByJbossAll() || !depSettings.isDeploymentValid() || runtimeName.endsWith(".ear")) {
        return;
    }
    try {
        if (runtimeName.endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX)) {
            URL fileURL = depUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS).asFileURL();
            addConditionally(depUnit, fileURL);
        } else {
            VirtualFileFilter filter = new VirtualFileFilter() {

                public boolean accepts(VirtualFile child) {
                    return child.isFile() && child.getName().endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX);
                }
            };
            VirtualFile rootFile = depUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
            for (VirtualFile vfile : rootFile.getChildrenRecursively(filter)) {
                addConditionally(depUnit, vfile.asFileURL());
            }
        }
        if (!depSettings.getCamelContextUrls().isEmpty()) {
            LOGGER.info("Camel context descriptors found");
        }
    } catch (IOException ex) {
        throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) IOException(java.io.IOException) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) URL(java.net.URL)

Example 14 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.

the class CDIBeanArchiveProcessor method deploy.

@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 with 1 or more sub-deployments
    if (depUnit.getName().endsWith(".ear") && subDeployments.isEmpty()) {
        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);
        }
    }
}
Also used : CamelDeploymentSettings(org.wildfly.extension.camel.deployment.CamelDeploymentSettings) BeanDeploymentArchiveImpl(org.jboss.as.weld.deployment.BeanDeploymentArchiveImpl) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 15 with DeploymentUnit

use of org.jboss.as.server.deployment.DeploymentUnit in project wildfly-camel by wildfly-extras.

the class CamelDeploymentSettingsProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
    if (depSettings == null) {
        depSettings = new CamelDeploymentSettings();
        depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, depSettings);
    } else {
        if (depSettings.isDisabledByJbossAll()) {
            // Camel is explicitly disabled in jboss-all.xml
            return;
        }
    }
    depSettings.setDeploymentValid(isDeploymentValid(depUnit));
    depSettings.setCamelAnnotationPresent(hasCamelActivationAnnotations(depUnit));
    synchronized (deploymentSettingsMap) {
        deploymentSettingsMap.put(getDeploymentName(depUnit), depSettings);
    }
    final DeploymentUnit parent = depUnit.getParent();
    if (parent != null) {
        final String parentDeploymentName = getDeploymentName(parent);
        CamelDeploymentSettings parentDepSettings = getDeploymentSettings(parentDeploymentName);
        if (parentDepSettings != null) {
            parentDepSettings.addChild(depSettings);
        }
    }
}
Also used : DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)359 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)84 Module (org.jboss.modules.Module)70 ServiceName (org.jboss.msc.service.ServiceName)62 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)56 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)56 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)47 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)45 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)40 VirtualFile (org.jboss.vfs.VirtualFile)39 ArrayList (java.util.ArrayList)37 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)37 ModuleLoader (org.jboss.modules.ModuleLoader)35 ServiceTarget (org.jboss.msc.service.ServiceTarget)34 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)33 WarMetaData (org.jboss.as.web.common.WarMetaData)31 HashMap (java.util.HashMap)30 HashSet (java.util.HashSet)30 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)20 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)20