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

The following examples show how to use org.jboss.as.server.deployment.DeploymentUnit#removeAttachment() . 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
private void unregisterLogContext(final DeploymentUnit deploymentUnit, final AttachmentKey<LogContext> attachmentKey, final Module module) {
    final LogContext logContext = deploymentUnit.removeAttachment(attachmentKey);
    if (logContext != null) {
        final boolean success;
        if (WildFlySecurityManager.isChecking()) {
            success = WildFlySecurityManager.doUnchecked(new PrivilegedAction<Boolean>() {
                @Override
                public Boolean run() {
                    return logContextSelector.unregisterLogContext(module.getClassLoader(), logContext);
                }
            });
        } else {
            success = logContextSelector.unregisterLogContext(module.getClassLoader(), logContext);
        }
        if (success) {
            LoggingLogger.ROOT_LOGGER.tracef("Removed LogContext '%s' from '%s'", logContext, module);
        } else {
            LoggingLogger.ROOT_LOGGER.logContextNotRemoved(logContext, deploymentUnit.getName());
        }
    }
}
 
Example 2
Source File: CamelDeploymentSettingsProcessor.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();

        CamelDeploymentSettings.Builder depSettingsBuilder = depUnit
                .removeAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY);
        if (depSettingsBuilder != null && depUnit.getParent() == null) {
            /*
             * We do this only for parentless deployments because for ones that have a parent the build and attachment
             * is done by CamelDeploymentSettings.Builder.build() if the parent
             */
            final CamelDeploymentSettings depSettings = depSettingsBuilder.build();
            depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, depSettings);
        }

    }
 
Example 3
Source File: CleanupAnnotationIndexProcessor.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();
    deploymentUnit.removeAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    for(final ResourceRoot root : DeploymentUtils.allResourceRoots(deploymentUnit)) {
        root.removeAttachment(Attachments.ANNOTATION_INDEX);
    }

}
 
Example 4
Source File: DeploymentRootMountProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void undeploy(DeploymentUnit context) {
    final ResourceRoot resourceRoot = context.removeAttachment(Attachments.DEPLOYMENT_ROOT);
    if (resourceRoot != null) {
        final Closeable mountHandle = resourceRoot.getMountHandle();
        VFSUtils.safeClose(mountHandle);
    }
}
 
Example 5
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);
}
 
Example 6
Source File: PackageScanResolverProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
public void undeploy(DeploymentUnit depUnit) {
    ContextCreateHandlerRegistry createHandlerRegistry = depUnit.getAttachment(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_KEY);
    if (createHandlerRegistry != null) {
        final ContextCreateHandler handler = depUnit.removeAttachment(PACKAGE_SCAN_ASSOCIATION_HANDLER_ATTACHMENT_KEY);
        if (handler != null) {
            final ModuleClassLoader classLoader = depUnit.getAttachment(Attachments.MODULE).getClassLoader();
            createHandlerRegistry.removeContextCreateHandler(classLoader, handler);
        }
    }
}
 
Example 7
Source File: CamelDeploymentSettingsBuilderProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();

        CamelDeploymentSettings.Builder depSettingsBuilder = depUnit.getAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY);
        if (depSettingsBuilder == null) {
            depSettingsBuilder = new CamelDeploymentSettings.Builder();
            depUnit.putAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY, depSettingsBuilder);
        } else if (depSettingsBuilder.isDisabledByJbossAll()) {
            // Camel is explicitly disabled in jboss-all.xml
            return;
        }

        depSettingsBuilder.deploymentName(getDeploymentName(depUnit));
        depSettingsBuilder.deploymentValid(isDeploymentValid(depUnit));
        depSettingsBuilder.camelActivationAnnotationPresent(hasCamelActivationAnnotations(depUnit));

        final DeploymentUnit parentDepUnit = depUnit.getParent();
        if (parentDepUnit != null) {
            final CamelDeploymentSettings.Builder parentDepSettingsBuilder = parentDepUnit.getAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY);
            if (parentDepSettingsBuilder != null) {
                // This consumer is called by CamelDeploymentSettings.Builder.build() right after the child settings are built
                Consumer<CamelDeploymentSettings> consumer = (CamelDeploymentSettings ds) -> {
                    depUnit.removeAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY);
                    depUnit.putAttachment(CamelDeploymentSettings.ATTACHMENT_KEY, ds);
                };
                parentDepSettingsBuilder.child(depSettingsBuilder, consumer);
            }
        }
    }
 
Example 8
Source File: KeycloakProviderDeploymentProcessor.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public void undeploy(DeploymentUnit context) {
    ProviderManager pm = context.getAttachment(ATTACHMENT_KEY);
    if (pm != null) {
        logger.infov("Undeploying Keycloak provider: {0}", context.getName());
        ProviderManagerRegistry.SINGLETON.undeploy(pm);
        context.removeAttachment(ATTACHMENT_KEY);
    }
}
 
Example 9
Source File: CompositeIndexProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void undeploy(DeploymentUnit deploymentUnit) {
    deploymentUnit.removeAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
}
 
Example 10
Source File: ModuleSpecProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void undeploy(final DeploymentUnit deploymentUnit) {
    deploymentUnit.removeAttachment(Attachments.MODULE);
    deploymentUnit.removeAttachment(Attachments.MODULE_PERMISSIONS);
    deploymentUnit.removeAttachment(DelegatingClassFileTransformer.ATTACHMENT_KEY);
}
 
Example 11
Source File: JBossAllXmlParserRegisteringProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void undeploy(final DeploymentUnit unit) {
    unit.removeAttachment(JBossAllXMLParserDescription.ATTACHMENT_KEY);
}
 
Example 12
Source File: JBossAllXMLParsingProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void undeploy(final DeploymentUnit context) {
    for(JBossAllXMLParserDescription<?> parser : context.getAttachmentList(JBossAllXMLParserDescription.ATTACHMENT_KEY)) {
        context.removeAttachment(parser.getAttachmentKey());
    }
}
 
Example 13
Source File: InstallReflectionIndexProcessor.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void undeploy(final DeploymentUnit context) {
    context.removeAttachment(Attachments.REFLECTION_INDEX);
}