/** * Add the EE APIs as a dependency to all deployments * * @param phaseContext the deployment unit context * @throws DeploymentUnitProcessingException * */ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); //add jboss-invocation classes needed by the proxies ModuleDependency invocation = new ModuleDependency(moduleLoader, JBOSS_INVOCATION_ID, false, false, false, false); invocation.addImportFilter(PathFilters.is("org/jboss/invocation/proxy/classloading"), true); invocation.addImportFilter(PathFilters.acceptAll(), false); moduleSpecification.addSystemDependency(invocation); ModuleDependency ee = new ModuleDependency(moduleLoader, JBOSS_AS_EE, false, false, false, false); ee.addImportFilter(PathFilters.is("org/jboss/as/ee/component/serialization"), true); ee.addImportFilter(PathFilters.is("org/jboss/as/ee/concurrent"), true); ee.addImportFilter(PathFilters.is("org/jboss/as/ee/concurrent/handle"), true); ee.addImportFilter(PathFilters.acceptAll(), false); moduleSpecification.addSystemDependency(ee); // add dep for naming permission moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.wildfly.naming"), false, false, false, false)); //we always add all Java EE API modules, as the platform spec requires them to always be available //we do not just add the javaee.api module, as this breaks excludes for (final ModuleIdentifier moduleIdentifier : JAVA_EE_API_MODULES) { moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, moduleIdentifier, true, false, true, false)); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final List<GlobalModule> globalMods = this.globalModules; for (final GlobalModule module : globalMods) { final ModuleDependency dependency = new ModuleDependency(Module.getBootModuleLoader(), module.getModuleIdentifier(), false, false, module.isServices(), false); if (module.isMetaInf()) { dependency.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true); dependency.addImportFilter(PathFilters.getMetaInfFilter(), true); } if(module.isAnnotations()) { deploymentUnit.addToAttachmentList(Attachments.ADDITIONAL_ANNOTATION_INDEXES, module.getModuleIdentifier()); } moduleSpecification.addSystemDependency(dependency); } }
/** * Add POJO module if we have any bean factories. * * @param phaseContext the deployment unit context * @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException */ @Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit unit = phaseContext.getDeploymentUnit(); final List<KernelDeploymentXmlDescriptor> kdXmlDescriptors = unit.getAttachment(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY); if (kdXmlDescriptors == null || kdXmlDescriptors.isEmpty()) return; for (KernelDeploymentXmlDescriptor kdxd : kdXmlDescriptors) { if (kdxd.getBeanFactoriesCount() > 0) { final ModuleSpecification moduleSpecification = unit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); ModuleDependency dependency = new ModuleDependency(moduleLoader, POJO_MODULE, false, false, false, false); PathFilter filter = PathFilters.isChildOf(BaseBeanFactory.class.getPackage().getName()); dependency.addImportFilter(filter, true); dependency.addImportFilter(PathFilters.rejectAll(), false); moduleSpecification.addSystemDependency(dependency); return; } } }
private void addJSFInjection(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) throws DeploymentUnitProcessingException { if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL)) return; ModuleIdentifier jsfInjectionModule = moduleIdFactory.getInjectionModId(jsfVersion); ModuleDependency jsfInjectionDependency = new ModuleDependency(moduleLoader, jsfInjectionModule, false, true, true, false); try { if (isJSF12(jsfInjectionDependency, jsfInjectionModule.toString())) { JSFLogger.ROOT_LOGGER.loadingJsf12(); jsfInjectionDependency.addImportFilter(PathFilters.is("META-INF/faces-config.xml"), false); jsfInjectionDependency.addImportFilter(PathFilters.is("META-INF/1.2/faces-config.xml"), true); } else { JSFLogger.ROOT_LOGGER.loadingJsf2x(); jsfInjectionDependency.addImportFilter(PathFilters.getMetaInfFilter(), true); // Exclude JSF 1.2 faces-config.xml to make extra sure it won't interfere with JSF 2.0 deployments jsfInjectionDependency.addImportFilter(PathFilters.is("META-INF/1.2/faces-config.xml"), false); } } catch (ModuleLoadException e) { throw JSFLogger.ROOT_LOGGER.jsfInjectionFailed(jsfVersion); } moduleSpecification.addSystemDependency(jsfInjectionDependency); }
private static void parsePath(final XMLStreamReader reader, final boolean include, final MultiplePathFilterBuilder builder) throws XMLStreamException { String path = null; final Set<Attribute> required = EnumSet.of(Attribute.PATH); final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); required.remove(attribute); switch (attribute) { case PATH: path = reader.getAttributeValue(i); break; default: if (literal) { if (path.charAt(path.length() - 1) == '/') { builder.addFilter(PathFilters.isChildOf(path), include); } else { builder.addFilter(PathFilters.is(path), include); builder.addFilter(PathFilters.match(path), include);
private static void parseSystemDependency(final XMLStreamReader reader, final ModuleStructureSpec specBuilder) throws XMLStreamException { boolean export = false; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final Attribute attribute = Attribute.of(reader.getAttributeName(i)); switch (attribute) { case EXPORT: export = Boolean.parseBoolean(reader.getAttributeValue(i)); break; default: final MultiplePathFilterBuilder exportBuilder = PathFilters.multiplePathFilterBuilder(export); while (reader.hasNext()) { switch (reader.nextTag()) { if (export) { exportBuilder.addFilter(PathFilters.getMetaInfSubdirectoriesFilter(), false); exportBuilder.addFilter(PathFilters.getMetaInfFilter(), false); final PathFilter exportFilter = exportBuilder.create(); specBuilder.addSystemDependency(DependencySpec.createSystemDependencySpec(PathFilters.getDefaultImportFilter(), exportFilter, paths)); return;
private static void parseSet(final XMLStreamReader reader, final boolean include, final List<FilterSpecification> filters) throws XMLStreamException { final Set<String> set = new HashSet<String>(); // xsd:choice while (reader.hasNext()) { switch (reader.nextTag()) { case XMLStreamConstants.END_ELEMENT: { filters.add(new FilterSpecification(PathFilters.in(set), include)); return; } case XMLStreamConstants.START_ELEMENT: { switch (Element.of(reader.getName())) { case PATH: parsePathName(reader, set); break; } } } } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) { return; // Skip non web deployments final ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); if (moduleSpecification == null) { return; deploymentResourceRoot.getExportFilters().add(new FilterSpecification(PathFilters.getMetaInfFilter(), true)); deploymentResourceRoot.getExportFilters().add(new FilterSpecification(PathFilters.getMetaInfSubdirectoriesFilter(), true)); deploymentResourceRoot.getExportFilters().add(new FilterSpecification(PathFilters.acceptAll(), false)); ModuleRootMarker.mark(deploymentResourceRoot, true); deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, root);
/** * Add dependencies for modules required for weld deployments, if managed weld configurations are attached to the deployment * */ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); final ModuleLoader moduleLoader = Module.getBootModuleLoader(); addDependency(moduleSpecification, moduleLoader, JAVAX_ENTERPRISE_API); addDependency(moduleSpecification, moduleLoader, JAVAX_INJECT_API); if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) { return; // Skip if there are no beans.xml files in the deployment } addDependency(moduleSpecification, moduleLoader, JAVAX_PERSISTENCE_API_ID); addDependency(moduleSpecification, moduleLoader, WELD_CORE_ID); addDependency(moduleSpecification, moduleLoader, WELD_PROBE_ID, true); addDependency(moduleSpecification, moduleLoader, WELD_API_ID); addDependency(moduleSpecification, moduleLoader, WELD_SPI_ID); ModuleDependency weldSubsystemDependency = new ModuleDependency(moduleLoader, JBOSS_AS_WELD_ID, false, false, false, false); weldSubsystemDependency.addImportFilter(PathFilters.getMetaInfFilter(), true); weldSubsystemDependency.addImportFilter(PathFilters.is("org/jboss/as/weld/injection"), true); weldSubsystemDependency.addImportFilter(PathFilters.acceptAll(), false); weldSubsystemDependency.addExportFilter(PathFilters.getMetaInfFilter(), true); moduleSpecification.addSystemDependency(weldSubsystemDependency); // Due to serialization of EJBs ModuleDependency weldEjbDependency = new ModuleDependency(moduleLoader, JBOSS_AS_WELD_EJB_ID, true, false, false, false); weldEjbDependency.addImportFilter(PathFilters.is("org/jboss/as/weld/ejb"), true); weldEjbDependency.addImportFilter(PathFilters.acceptAll(), false); moduleSpecification.addSystemDependency(weldEjbDependency); }
private void addDeploymentDependencies(DeploymentUnit depUnit, CamelDeploymentSettings depSettings) { ModuleLoader moduleLoader = depUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER); ModuleSpecification moduleSpec = depUnit.getAttachment(Attachments.MODULE_SPECIFICATION); moduleSpec.addUserDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create(WILDFLY_CAMEL_MODULE), false, false, false, false)); // Add camel aggregator dependency ModuleDependency moddep = new ModuleDependency(moduleLoader, ModuleIdentifier.create(APACHE_CAMEL_MODULE), false, false, true, false); moddep.addImportFilter(PathFilters.getMetaInfFilter(), true); moduleSpec.addUserDependency(moddep); List<String> deploymentDefinedModules = depSettings.getModuleDependencies(); if (!deploymentDefinedModules.isEmpty()) { for (String modid : deploymentDefinedModules) { moduleSpec.addUserDependency(new ModuleDependency(moduleLoader, modid, false, false, true, false)); } } else { moddep = new ModuleDependency(moduleLoader, ModuleIdentifier.create(APACHE_CAMEL_COMPONENT_MODULE), false, false, true, false); moddep.addImportFilter(PathFilters.getMetaInfFilter(), true); moddep.addImportFilter(PathFilters.isOrIsChildOf("META-INF/cxf"), true); moduleSpec.addUserDependency(moddep); moddep = new ModuleDependency(moduleLoader, ModuleIdentifier.create(APACHE_CAMEL_COMPONENT_CDI_MODULE), true, false, false, false); moddep.addImportFilter(PathFilters.getMetaInfSubdirectoriesFilter(), true); moddep.addImportFilter(PathFilters.getMetaInfFilter(), true); moduleSpec.addUserDependency(moddep); } }
/** * Add dependencies for modules required for weld deployments, if managed weld configurations are attached to the deployment * */ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) { return; // Skip if there are no beans.xml files in the deployment } final ModuleLoader moduleLoader = Module.getBootModuleLoader(); addDependency(moduleSpecification, moduleLoader, JAVAX_PERSISTENCE_API_ID); addDependency(moduleSpecification, moduleLoader, JAVAEE_API_ID); addDependency(moduleSpecification, moduleLoader, JAVASSIST_ID); addDependency(moduleSpecification, moduleLoader, WELD_CORE_ID); addDependency(moduleSpecification, moduleLoader, WELD_API_ID); addDependency(moduleSpecification, moduleLoader, WELD_SPI_ID); ModuleDependency dep = new ModuleDependency(moduleLoader, JBOSS_AS_WELD_ID, false, false, false, false); dep.addImportFilter(PathFilters.getMetaInfFilter(), true); dep.addExportFilter(PathFilters.getMetaInfFilter(), true); moduleSpecification.addSystemDependency(dep); }
private void createDependencies(final ModuleSpec.Builder specBuilder, final List<ModuleDependency> apiDependencies, final boolean requireTransitive) { if (apiDependencies != null) { for (final ModuleDependency dependency : apiDependencies) { final boolean export = requireTransitive ? true : dependency.isExport(); final List<FilterSpecification> importFilters = dependency.getImportFilters(); final List<FilterSpecification> exportFilters = dependency.getExportFilters(); final PathFilter importFilter; final PathFilter exportFilter; final MultiplePathFilterBuilder importBuilder = PathFilters.multiplePathFilterBuilder(true); for (final FilterSpecification filter : importFilters) { importBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); if (dependency.isImportServices()) { importBuilder.addFilter(PathFilters.getMetaInfServicesFilter(), true); importBuilder.addFilter(PathFilters.getMetaInfSubdirectoriesFilter(), false); importBuilder.addFilter(PathFilters.getMetaInfFilter(), false); importFilter = importBuilder.create(); if (exportFilters.isEmpty()) { if (export) { exportFilter = PathFilters.acceptAll(); } else { exportFilter = PathFilters.rejectAll(); .multiplePathFilterBuilder(export); for (final FilterSpecification filter : exportFilters) { exportBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); exportFilter = exportBuilder.create();
private void addModuleDependency(DeploymentUnit deployment, ModuleIdentifier moduleIdentifier) { ModuleSpecification moduleSpec = deployment.getAttachment(Attachments.MODULE_SPECIFICATION); ModuleLoader moduleLoader = deployment.getAttachment(Attachments.SERVICE_MODULE_LOADER); ModuleDependency dependency = new ModuleDependency(moduleLoader, moduleIdentifier, false, true, true, false); dependency.addImportFilter(PathFilters.getMetaInfFilter(), true); moduleSpec.addSystemDependency(dependency); } }
private void addJSFImpl(String jsfVersion, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) { if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL)) return; ModuleIdentifier jsfModule = moduleIdFactory.getImplModId(jsfVersion); ModuleDependency jsfImpl = new ModuleDependency(moduleLoader, jsfModule, false, false, true, false); jsfImpl.addImportFilter(PathFilters.getMetaInfFilter(), true); moduleSpecification.addSystemDependency(jsfImpl); }
private void addDependency(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader, ModuleIdentifier moduleIdentifier, boolean optional, boolean deploymentBundelesClientBuilder) { ModuleDependency dependency = new ModuleDependency(moduleLoader, moduleIdentifier, optional, false, true, false); if(deploymentBundelesClientBuilder) { dependency.addImportFilter(PathFilters.is(CLIENT_BUILDER), false); } moduleSpecification.addSystemDependency(dependency); }
LOGGER.debugf("Adding integration dependencies: %d", dependencies.size()); for (ModuleDependency moduleDep : dependencies) { ModuleIdentifier moduleId = moduleDep.getIdentifier(); if (moduleDependencies.get(moduleId) != null) { LOGGER.debugf(" -dependency on %s (skipped)", moduleId); MultiplePathFilterBuilder importBuilder = PathFilters.multiplePathFilterBuilder(true); for (FilterSpecification filter : moduleDep.getImportFilters()) { importBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); PathFilter importFilter = importBuilder.create(); MultiplePathFilterBuilder exportBuilder = PathFilters.multiplePathFilterBuilder(true); for (FilterSpecification filter : moduleDep.getExportFilters()) { importBuilder.addFilter(filter.getPathFilter(), filter.isInclude()); PathFilter exportFilter = exportBuilder.create(); ModuleLoader moduleLoader = moduleDep.getModuleLoader(); boolean optional = moduleDep.isOptional(); DependencySpec depSpec = DependencySpec.createModuleDependencySpec(importFilter, exportFilter, moduleLoader, moduleId, optional); LOGGER.debugf(" +%s", depSpec); builder.addDependency(depSpec);
Objects.requireNonNull(scriptArchive, "scriptArchive"); MultiplePathFilterBuilder pathFilterBuilder = PathFilters.multiplePathFilterBuilder(true); Set<String> archiveEntryNames = scriptArchive.getArchiveEntryNames(); pathFilterBuilder.addFilter(PathFilters.in(archiveEntryNames), true); moduleSpecBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(rootResourceLoader, pathFilterBuilder.create())); moduleSpecBuilder.setModuleClassLoaderFactory(JBossModuleClassLoader.createFactory(scriptArchive));
/** * Create a dependency on the given module. * * @param identifier the module identifier * @param export {@code true} if this is a fully re-exported dependency, {@code false} if it should not be exported * @param optional {@code true} if the dependency is optional, {@code false} if it is mandatory * @return the dependency spec */ public static DependencySpec createModuleDependencySpec(final ModuleIdentifier identifier, final boolean export, final boolean optional) { return createModuleDependencySpec(PathFilters.getDefaultImportFilter(), export ? PathFilters.acceptAll() : PathFilters.rejectAll(), null, identifier, optional); }
@Override protected void configure(ModuleLoader loader, Builder builder) { builder.addDependency(DependencySpec.createSystemDependencySpec( PathFilters.acceptAll(), PathFilters.any(Arrays.asList( PathFilters.isChildOf("javax"), PathFilters.is("org/jboss/weld"), PathFilters.isChildOf("org/jboss/weld"))), systemPaths)); }
private void addAddonDependencies(AddonRepository repository, AddonId found, Builder builder) throws ContainerException { Set<AddonDependencyEntry> addons = repository.getAddonDependencies(found); for (AddonDependencyEntry dependency : addons) { ModuleIdentifier moduleId = findCompatibleInstalledModule(dependency.getId()); if (moduleId == null && !dependency.isOptional()) { throw new ContainerException("Dependency [" + dependency + "] could not be loaded for addon [" + found + "]"); } else { builder.addDependency(DependencySpec.createModuleDependencySpec( PathFilters.not(PathFilters.getMetaInfFilter()), dependency.isExported() ? PathFilters.acceptAll() : PathFilters.rejectAll(), this, moduleCache.getModuleId(dependency.getId()), dependency.isOptional())); } } }