Java Code Examples for org.jboss.as.server.deployment.DeploymentUnit#getAttachment()
The following examples show how to use
org.jboss.as.server.deployment.DeploymentUnit#getAttachment() .
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: KeycloakAdapterConfigService.java From keycloak with Apache License 2.0 | 6 votes |
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 2
Source File: ProcessApplicationProcessor.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); // must be EE Module if(eeModuleDescription == null) { return; } // discover user-provided component ComponentDescription paComponent = detectExistingComponent(deploymentUnit); if(paComponent != null) { log.log(Level.INFO, "Detected user-provided @"+ProcessApplication.class.getSimpleName()+" component with name '"+paComponent.getComponentName()+"'."); // mark this to be a process application ProcessApplicationAttachments.attachProcessApplicationComponent(deploymentUnit, paComponent); ProcessApplicationAttachments.mark(deploymentUnit); ProcessApplicationAttachments.markPartOfProcessApplication(deploymentUnit); } }
Example 3
Source File: KeycloakDependencyProcessor.java From keycloak with Apache License 2.0 | 6 votes |
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!KeycloakAdapterConfigService.getInstance().isSecureDeployment(deploymentUnit)) { 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")) return; } final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); addCommonModules(moduleSpecification, moduleLoader); addPlatformSpecificModules(phaseContext, moduleSpecification, moduleLoader); }
Example 4
Source File: KeycloakAdapterConfigDeploymentProcessor.java From keycloak with Apache License 2.0 | 6 votes |
protected void addSecurityDomain(DeploymentUnit deploymentUnit, KeycloakAdapterConfigService service) { if (!service.isSecureDeployment(deploymentUnit)) { return; } 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 || !loginConfig.getAuthMethod().equalsIgnoreCase("KEYCLOAK")) { return; } webMetaData.setSecurityDomain("keycloak"); }
Example 5
Source File: LoggingDependencyDeploymentProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@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 6
Source File: CompositeIndexProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Map<ModuleIdentifier, DeploymentUnit> buildSubdeploymentDependencyMap(DeploymentUnit deploymentUnit) { Set<ModuleIdentifier> depModuleIdentifiers = new HashSet<>(); for (ModuleDependency dep: deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION).getAllDependencies()) { depModuleIdentifiers.add(dep.getIdentifier()); } DeploymentUnit top = deploymentUnit.getParent()==null?deploymentUnit:deploymentUnit.getParent(); Map<ModuleIdentifier, DeploymentUnit> res = new HashMap<>(); AttachmentList<DeploymentUnit> subDeployments = top.getAttachment(Attachments.SUB_DEPLOYMENTS); if (subDeployments != null) { for (DeploymentUnit subDeployment : subDeployments) { ModuleIdentifier moduleIdentifier = subDeployment.getAttachment(Attachments.MODULE_IDENTIFIER); if (depModuleIdentifiers.contains(moduleIdentifier)) { res.put(moduleIdentifier, subDeployment); } } } return res; }
Example 7
Source File: KeycloakDependencyProcessor.java From keycloak with Apache License 2.0 | 6 votes |
@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; } // Next phase, need to detect if this is a Keycloak deployment. If not, don't add the modules. final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); addCommonModules(moduleSpecification, moduleLoader); addPlatformSpecificModules(phaseContext, moduleSpecification, moduleLoader); }
Example 8
Source File: ProcessesXmlProcessor.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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 9
Source File: ProcessApplicationDeploymentProcessor.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected Map<String, byte[]> getDeploymentResources(ProcessArchiveXml processArchive, DeploymentUnit deploymentUnit, VirtualFile processesXmlFile) { final Module module = deploymentUnit.getAttachment(MODULE); Map<String, byte[]> resources = new HashMap<String, byte[]>(); // first, add all resources listed in the processe.xml List<String> process = processArchive.getProcessResourceNames(); ModuleClassLoader classLoader = module.getClassLoader(); for (String resource : process) { InputStream inputStream = null; try { inputStream = classLoader.getResourceAsStream(resource); resources.put(resource, IoUtil.readInputStream(inputStream, resource)); } finally { IoUtil.closeSilently(inputStream); } } // scan for process definitions if(PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_SCAN_FOR_PROCESS_DEFINITIONS, process.isEmpty())) { //always use VFS scanner on JBoss final VfsProcessApplicationScanner scanner = new VfsProcessApplicationScanner(); String resourceRootPath = processArchive.getProperties().get(ProcessArchiveXml.PROP_RESOURCE_ROOT_PATH); String[] additionalResourceSuffixes = StringUtil.split(processArchive.getProperties().get(ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES), ProcessArchiveXml.PROP_ADDITIONAL_RESOURCE_SUFFIXES_SEPARATOR); URL processesXmlUrl = vfsFileAsUrl(processesXmlFile); resources.putAll(scanner.findResources(classLoader, resourceRootPath, processesXmlUrl, additionalResourceSuffixes)); } return resources; }
Example 10
Source File: CamelDeploymentSettingsBuilderProcessor.java From wildfly-camel with Apache License 2.0 | 5 votes |
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 11
Source File: KeycloakAdapterConfigDeploymentProcessor.java From keycloak with Apache License 2.0 | 5 votes |
private void addConfigurationListener(DeploymentPhaseContext phaseContext) { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { return; } JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData(); if (webMetaData == null) { webMetaData = new JBossWebMetaData(); warMetaData.setMergedJBossWebMetaData(webMetaData); } LoginConfigMetaData loginConfig = webMetaData.getLoginConfig(); if (loginConfig == null) { return; } if (!loginConfig.getAuthMethod().equals("KEYCLOAK-SAML")) { return; } if (isElytronEnabled(phaseContext)) { ListenerMetaData listenerMetaData = new ListenerMetaData(); listenerMetaData.setListenerClass(KeycloakConfigurationServletListener.class.getName()); webMetaData.getListeners().add(listenerMetaData); } }
Example 12
Source File: DeploymentDependenciesProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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 13
Source File: ProcessesXmlProcessor.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected String[] getDeploymentDescriptors(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final ComponentDescription processApplicationComponent = ProcessApplicationAttachments.getProcessApplicationComponent(deploymentUnit); final String paClassName = processApplicationComponent.getComponentClassName(); String[] deploymentDescriptorResourceNames = null; Module module = deploymentUnit.getAttachment(MODULE); Class<?> paClass = null; try { paClass = (Class<?>) module.getClassLoader().loadClass(paClassName); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException("Unable to load process application class '"+paClassName+"'."); } ProcessApplication annotation = paClass.getAnnotation(ProcessApplication.class); if(annotation == null) { deploymentDescriptorResourceNames = new String[]{ PROCESSES_XML }; } else { deploymentDescriptorResourceNames = annotation.deploymentDescriptors(); } return deploymentDescriptorResourceNames; }
Example 14
Source File: KeycloakProviderDeploymentProcessor.java From keycloak with Apache License 2.0 | 5 votes |
@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 15
Source File: Seam2Processor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null) { return; } final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>(); deploymentUnits.add(deploymentUnit); deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)); for (DeploymentUnit unit : deploymentUnits) { final ResourceRoot mainRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT); if (mainRoot == null) continue; VirtualFile root = mainRoot.getRoot(); for (String path : SEAM_FILES) { if (root.getChild(path).exists()) { final ModuleSpecification moduleSpecification = deploymentUnit .getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, VFS_MODULE, false, false, false, false)); // for VFS scanner try { ResourceLoader resourceLoader = ResourceLoaders.createJarResourceLoader(SEAM_INT_JAR, new JarFile( getSeamIntResourceRoot().getRoot().getPathName())); moduleSpecification.addResourceLoader(ResourceLoaderSpec.createResourceLoaderSpec(resourceLoader)); } catch (Exception e) { throw new DeploymentUnitProcessingException(e); } unit.addToAttachmentList(Attachments.RESOURCE_ROOTS, getSeamIntResourceRoot()); return; } } } }
Example 16
Source File: KeycloakProviderDependencyProcessor.java From keycloak with Apache License 2.0 | 5 votes |
public static KeycloakDeploymentInfo getKeycloakProviderDeploymentInfo(DeploymentUnit du) { KeycloakDeploymentInfo info = KeycloakDeploymentInfo.create(); info.name(du.getName()); final ResourceRoot resourceRoot = du.getAttachment(Attachments.DEPLOYMENT_ROOT); if (resourceRoot != null) { final VirtualFile deploymentRoot = resourceRoot.getRoot(); if (deploymentRoot != null && deploymentRoot.exists()) { if (deploymentRoot.getChild("META-INF/keycloak-themes.json").exists() && deploymentRoot.getChild("theme").exists()) { info.themes(); } if (deploymentRoot.getChild("theme-resources").exists()) { info.themeResources(); } VirtualFile services = deploymentRoot.getChild("META-INF/services"); if(services.exists()) { try { List<VirtualFile> archives = services.getChildren(new AbstractVirtualFileFilterWithAttributes() { @Override public boolean accepts(VirtualFile file) { return file.getName().startsWith("org.keycloak"); } }); if (!archives.isEmpty()) { info.services(); } } catch (IOException e) { e.printStackTrace(); } } } } return info; }
Example 17
Source File: CamelContextActivationProcessor.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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(); }
Example 18
Source File: VirtualDomainMarkerUtility.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public static boolean isVirtualDomainRequired(final DeploymentUnit deploymentUnit) { DeploymentUnit rootUnit = toRoot(deploymentUnit); Boolean required = rootUnit.getAttachment(REQUIRED); return required == null ? false : required.booleanValue(); }
Example 19
Source File: ModuleDependencyProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public void undeploy(final DeploymentUnit context) { final Module module = context.getAttachment(Attachments.MODULE); if (module != null) { REGISTRY.release(module.getClassLoader()); } }
Example 20
Source File: DeploymentRootMountProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if(deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT) != null) { return; } final DeploymentMountProvider deploymentMountProvider = deploymentUnit.getAttachment(Attachments.SERVER_DEPLOYMENT_REPOSITORY); if(deploymentMountProvider == null) { throw ServerLogger.ROOT_LOGGER.noDeploymentRepositoryAvailable(); } final String deploymentName = deploymentUnit.getName(); final VirtualFile deploymentContents = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS); // internal deployments do not have any contents, so there is nothing to mount if (deploymentContents == null) return; final VirtualFile deploymentRoot; final MountHandle mountHandle; if (deploymentContents.isDirectory()) { // use the contents directly deploymentRoot = deploymentContents; // nothing was mounted mountHandle = null; ExplodedDeploymentMarker.markAsExplodedDeployment(deploymentUnit); } else { // The mount point we will use for the repository file deploymentRoot = VFS.getChild("content/" + deploymentName); boolean failed = false; Closeable handle = null; try { final boolean mountExploded = MountExplodedMarker.isMountExploded(deploymentUnit); final MountType type; if(mountExploded) { type = MountType.EXPANDED; } else if (deploymentName.endsWith(".xml")) { type = MountType.REAL; } else { type = MountType.ZIP; } handle = deploymentMountProvider.mountDeploymentContent(deploymentContents, deploymentRoot, type); mountHandle = MountHandle.create(handle); } catch (IOException e) { failed = true; throw ServerLogger.ROOT_LOGGER.deploymentMountFailed(e); } finally { if(failed) { VFSUtils.safeClose(handle); } } } final ResourceRoot resourceRoot = new ResourceRoot(deploymentRoot, mountHandle); ModuleRootMarker.mark(resourceRoot); deploymentUnit.putAttachment(Attachments.DEPLOYMENT_ROOT, resourceRoot); deploymentUnit.putAttachment(Attachments.MODULE_SPECIFICATION, new ModuleSpecification()); }