Java Code Examples for org.jboss.as.server.deployment.DeploymentUnit#hasAttachment()

The following examples show how to use org.jboss.as.server.deployment.DeploymentUnit#hasAttachment() . 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: AbstractLoggingDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public final void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // If the log context is already defined, skip the rest of the processing
    if (!hasRegisteredLogContext(deploymentUnit)) {
        if (deploymentUnit.hasAttachment(Attachments.DEPLOYMENT_ROOT)) {
            // don't process sub-deployments as they are processed by processing methods
            final ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
            if (SubDeploymentMarker.isSubDeployment(root)) return;
            processDeployment(phaseContext, deploymentUnit, root);
            // If we still don't have a context registered on the root deployment, register the current context.
            // This is done to avoid any logging from the root deployment to have access to a sub-deployments log
            // context. For example any library logging from a EAR/lib should use the EAR's configured log context,
            // not a log context from a WAR or EJB library.
            if (!hasRegisteredLogContext(deploymentUnit) && !deploymentUnit.hasAttachment(DEFAULT_LOG_CONTEXT_KEY)) {
                // Register the current log context as this could be an embedded server or overridden another way
                registerLogContext(deploymentUnit, DEFAULT_LOG_CONTEXT_KEY, deploymentUnit.getAttachment(Attachments.MODULE), LogContext.getLogContext());
            }
        }
    }
}
 
Example 2
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 3
Source File: DeploymentDependenciesProcessor.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();
    if (deploymentUnit.hasAttachment(DeploymentDependencies.ATTACHMENT_KEY)) {
        if (deploymentUnit.getParent() != null) {
            ServerLogger.DEPLOYMENT_LOGGER.deploymentDependenciesAreATopLevelElement(deploymentUnit.getName());
        } else {
            processDependencies(phaseContext, deploymentUnit);
        }
    }

    if (deploymentUnit.getParent() != null) {
        DeploymentUnit parent = deploymentUnit.getParent();
        if (parent.hasAttachment(DeploymentDependencies.ATTACHMENT_KEY)) {
            processDependencies(phaseContext, parent);
        }
    }
}
 
Example 4
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 5
Source File: AbstractLoggingDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static List<DeploymentUnit> getSubDeployments(final DeploymentUnit deploymentUnit) {
    if (deploymentUnit.hasAttachment(Attachments.SUB_DEPLOYMENTS)) {
        return new ArrayList<>(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));
    }
    return Collections.emptyList();
}
 
Example 6
Source File: AbstractLoggingDeploymentProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Checks the deployment to see if it has a registered {@link org.jboss.logmanager.LogContext log context}.
 *
 * @param deploymentUnit the deployment unit to check
 *
 * @return {@code true} if the deployment unit has a log context, otherwise {@code false}
 */
static boolean hasRegisteredLogContext(final DeploymentUnit deploymentUnit) {
    return deploymentUnit.hasAttachment(LOG_CONTEXT_KEY);
}
 
Example 7
Source File: ProcessApplicationAttachments.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Returns true if the {@link DeploymentUnit} itself is a process application (carries a processes.xml)
 * 
 */
public static boolean isProcessApplication(DeploymentUnit deploymentUnit) {
  return deploymentUnit.hasAttachment(MARKER);
}
 
Example 8
Source File: ProcessApplicationAttachments.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Returns true if the {@link DeploymentUnit} itself is a process application (carries a processes.xml)
 * 
 */
public static boolean isProcessApplication(DeploymentUnit deploymentUnit) {
  return deploymentUnit.hasAttachment(MARKER);
}