org.jboss.modules.DependencySpec Java Examples
The following examples show how to use
org.jboss.modules.DependencySpec.
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: JBossModuleLoader.java From Nicobar with Apache License 2.0 | 6 votes |
/** * Extract the Module dependencies for the given module in the form * of ScriptModule ids. */ public static Set<ModuleId> getDependencyScriptModuleIds(ModuleSpec moduleSpec) { Objects.requireNonNull(moduleSpec, "moduleSpec"); if (!(moduleSpec instanceof ConcreteModuleSpec)) { throw new IllegalArgumentException("Unsupported ModuleSpec implementation: " + moduleSpec.getClass().getName()); } Set<ModuleId> dependencyNames = new LinkedHashSet<ModuleId>(); ConcreteModuleSpec concreteSpec = (ConcreteModuleSpec)moduleSpec; for (DependencySpec dependencSpec : concreteSpec.getDependencies()) { if (dependencSpec instanceof ModuleDependencySpec) { ModuleIdentifier revisionId = ((ModuleDependencySpec)dependencSpec).getIdentifier(); dependencyNames.add(ModuleId.fromString(revisionId.getName())); } } return dependencyNames; }
Example #2
Source File: AddonModuleLoader.java From furnace with Eclipse Public License 1.0 | 6 votes |
private void addAddonDependency(Set<AddonView> views, AddonId found, Builder builder, AddonDependencyEntry dependency) { AddonId addonId = stateManager.resolveAddonId(views, dependency.getName()); ModuleIdentifier moduleId = null; if (addonId != null) { Addon addon = lifecycleManager.getAddon(views, addonId); moduleId = findCompatibleInstalledModule(addonId); if (moduleId != null) { builder.addDependency(DependencySpec.createModuleDependencySpec( PathFilters.not(PathFilters.getMetaInfFilter()), dependency.isExported() ? PathFilters.acceptAll() : PathFilters.rejectAll(), this, moduleCache.getModuleId(addon), dependency.isOptional())); } } if (!dependency.isOptional() && (addonId == null || moduleId == null)) throw new ContainerException("Dependency [" + dependency + "] could not be loaded for addon [" + found + "]"); }
Example #3
Source File: AbstractModuleSpecProvider.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Override public ModuleSpec get(ModuleLoader loader, ModuleIdentifier id) { if (getId().equals(id)) { Builder builder = ModuleSpec.build(id); builder.addDependency(DependencySpec.createClassLoaderDependencySpec(PathFilters.acceptAll(), PathFilters.acceptAll(), AbstractModuleSpecProvider.class.getClassLoader(), getPaths())); builder.addDependency(DependencySpec.createClassLoaderDependencySpec(PathFilters.acceptAll(), PathFilters.acceptAll(), ClassLoader.getSystemClassLoader(), getPaths())); configure(loader, builder); return builder.create(); } return null; }
Example #4
Source File: DriverModuleBuilder.java From thorntail with Apache License 2.0 | 5 votes |
public boolean detect(final String moduleName) { Messages.MESSAGES.attemptToAutoDetectDriver(this.name); File primaryJar = attemptDetection(); if (primaryJar != null) { Set<File> optionalJars = findOptionalJars(); optionalJars.add(primaryJar); DynamicModuleFinder.register(moduleName, (id, loader) -> { ModuleSpec.Builder builder = ModuleSpec.build(id); for (File eachJar : optionalJars) { try { JarFile jar = JarFileManager.INSTANCE.addJarFile(eachJar); builder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec( ResourceLoaders.createIterableJarResourceLoader(jar.getName(), jar) )); } catch (IOException e) { Messages.MESSAGES.errorLoadingAutodetectedDriver(this.name, e); return null; } } for (String eachModuleIdentifier : driverModuleDependencies) { builder.addDependency(new ModuleDependencySpecBuilder() .setName(eachModuleIdentifier) .build()); } builder.addDependency(DependencySpec.createLocalDependencySpec()); return builder.create(); }); this.installed = true; } return this.installed; }
Example #5
Source File: JBossModuleUtils.java From Nicobar with Apache License 2.0 | 5 votes |
/** * Populates a {@link ModuleSpec} with runtime resources, dependencies and properties from the * {@link ScriptCompilerPluginSpec} * Helpful when creating a {@link ModuleSpec} from a ScriptLibPluginSpec * * @param moduleSpecBuilder builder to populate * @param pluginSpec {@link ScriptCompilerPluginSpec} to copy from * @param latestRevisionIds used to lookup the latest dependencies. see {@link JBossModuleLoader#getLatestRevisionIds()} */ public static void populateCompilerModuleSpec(ModuleSpec.Builder moduleSpecBuilder, ScriptCompilerPluginSpec pluginSpec, Map<ModuleId, ModuleIdentifier> latestRevisionIds) throws ModuleLoadException { Objects.requireNonNull(moduleSpecBuilder, "moduleSpecBuilder"); Objects.requireNonNull(pluginSpec, "pluginSpec"); Objects.requireNonNull(latestRevisionIds, "latestRevisionIds"); Set<Path> pluginRuntime = pluginSpec.getRuntimeResources(); for (Path resourcePath : pluginRuntime) { File file = resourcePath.toFile(); String pathString = resourcePath.toString(); ResourceLoader rootResourceLoader = null; if (file.isDirectory()) { rootResourceLoader = ResourceLoaders.createFileResourceLoader(pathString, file); } else if (pathString.endsWith(".jar")) { try { rootResourceLoader = ResourceLoaders.createJarResourceLoader(pathString, new JarFile(file)); } catch (IOException e) { throw new ModuleLoadException(e); } } if (rootResourceLoader != null) { moduleSpecBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(rootResourceLoader)); } } moduleSpecBuilder.addDependency(JRE_DEPENDENCY_SPEC); moduleSpecBuilder.addDependency(NICOBAR_CORE_DEPENDENCY_SPEC); moduleSpecBuilder.addDependency(DependencySpec.createLocalDependencySpec()); // add dependencies to the module spec Set<ModuleId> dependencies = pluginSpec.getModuleDependencies(); for (ModuleId scriptModuleId : dependencies) { ModuleIdentifier latestIdentifier = latestRevisionIds.get(scriptModuleId); if (latestIdentifier == null) { throw new ModuleLoadException("Cannot find dependent module: " + scriptModuleId); } moduleSpecBuilder.addDependency(DependencySpec.createModuleDependencySpec(latestIdentifier, true, false)); } Map<String, String> pluginMetadata = pluginSpec.getPluginMetadata(); addPropertiesToSpec(moduleSpecBuilder, pluginMetadata); }
Example #6
Source File: JBossModuleUtils.java From Nicobar with Apache License 2.0 | 5 votes |
/** * Populate a module spec builder with a dependencies on other modules. * @param moduleSpecBuilder builder to populate * @param moduleImportFilterPaths paths valid for importing into the module being built. * Can be null or empty to indicate that no filters should be applied. * @param dependencyExportFilterPaths export paths for the dependency being linked * @param dependentModuleIdentifier used to lookup the latest dependencies. see {@link JBossModuleLoader#getLatestRevisionIds()} */ public static void populateModuleSpecWithModuleDependency(ModuleSpec.Builder moduleSpecBuilder, @Nullable Set<String> moduleImportFilterPaths, @Nullable Set<String> dependencyExportFilterPaths, ModuleIdentifier dependentModuleIdentifier) { Objects.requireNonNull(moduleSpecBuilder, "moduleSpecBuilder"); PathFilter moduleImportFilters = buildFilters(moduleImportFilterPaths, false); PathFilter dependencyExportFilters = buildFilters(dependencyExportFilterPaths, false); PathFilter importFilters = PathFilters.all(dependencyExportFilters, moduleImportFilters); moduleSpecBuilder.addDependency(DependencySpec.createModuleDependencySpec(importFilters, dependencyExportFilters, null, dependentModuleIdentifier, false)); }
Example #7
Source File: JBossModuleUtils.java From Nicobar with Apache License 2.0 | 5 votes |
/** * Populates a module spec builder with core dependencies on JRE, Nicobar, itself, and compiler plugins. * * @param moduleSpecBuilder builder to populate * @param scriptArchive {@link ScriptArchive} to copy from */ public static void populateModuleSpecWithCoreDependencies(ModuleSpec.Builder moduleSpecBuilder, ScriptArchive scriptArchive) throws ModuleLoadException { Objects.requireNonNull(moduleSpecBuilder, "moduleSpecBuilder"); Objects.requireNonNull(scriptArchive, "scriptArchive"); Set<String> compilerPlugins = scriptArchive.getModuleSpec().getCompilerPluginIds(); for (String compilerPluginId : compilerPlugins) { moduleSpecBuilder.addDependency(DependencySpec.createModuleDependencySpec(getPluginModuleId(compilerPluginId), false)); } moduleSpecBuilder.addDependency(JRE_DEPENDENCY_SPEC); // TODO: Why does a module need a dependency on Nicobar itself? moduleSpecBuilder.addDependency(NICOBAR_CORE_DEPENDENCY_SPEC); moduleSpecBuilder.addDependency(DependencySpec.createLocalDependencySpec()); }
Example #8
Source File: FurnaceContainerSpec.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Override protected void configure(ModuleLoader loader, Builder builder) { builder.addDependency(DependencySpec.createSystemDependencySpec( PathFilters.acceptAll(), PathFilters.all( PathFilters.not(PathFilters.any( PathFilters.is("org/jboss/forge/furnace/impl"), PathFilters.isChildOf("org/jboss/forge/furnace/impl"))), PathFilters.any(Arrays.asList( PathFilters.is("org/jboss/forge/furnace/proxy/javassist"), PathFilters.isChildOf("org/jboss/forge/furnace/proxy/javassist"), PathFilters.is("META-INF/services"), PathFilters.is("org/jboss/forge/furnace"), PathFilters.is("org/jboss/forge/furnace/addons"), PathFilters.is("org/jboss/forge/furnace/event"), PathFilters.is("org/jboss/forge/furnace/exception"), PathFilters.is("org/jboss/forge/furnace/lifecycle"), PathFilters.is("org/jboss/forge/furnace/lock"), PathFilters.is("org/jboss/forge/furnace/repositories"), PathFilters.is("org/jboss/forge/furnace/services"), PathFilters.is("org/jboss/forge/furnace/spi"), PathFilters.is("org/jboss/forge/furnace/util"), PathFilters.is("org/jboss/forge/furnace/versions"), PathFilters.is("org/jboss/forge/furnace/proxy") ))), getPaths())); }
Example #9
Source File: ExternalModuleSpecService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static void addEEDependencies(ModuleSpec.Builder specBuilder) { DependencySpec dependencySpec = new ModuleDependencySpecBuilder() .setName(ServerRootResourceDefinition.WILDFLY_EE_API) .setOptional(true) .build(); specBuilder.addDependency(dependencySpec); }
Example #10
Source File: WildFlySwarmApplicationConf.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 5 votes |
@Override void apply(ModuleSpec.Builder builder) { builder.addDependency( DependencySpec.createModuleDependencySpec( PathFilters.acceptAll(), PathFilters.acceptAll(), PathFilters.acceptAll(), PathFilters.acceptAll(), ClassFilters.acceptAll(), ClassFilters.acceptAll(), null, ModuleIdentifier.create(this.name, this.slot), false)); }
Example #11
Source File: JBossDeploymentStructureParser12.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
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: throw unexpectedContent(reader); } } Set<String> paths = Collections.emptySet(); final MultiplePathFilterBuilder exportBuilder = PathFilters.multiplePathFilterBuilder(export); while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (export) { // If re-exported, add META-INF/** -> false at the end of the list (require explicit override) exportBuilder.addFilter(PathFilters.getMetaInfSubdirectoriesFilter(), false); exportBuilder.addFilter(PathFilters.getMetaInfFilter(), false); } final PathFilter exportFilter = exportBuilder.create(); specBuilder.addSystemDependency(DependencySpec.createSystemDependencySpec(PathFilters.getDefaultImportFilter(), exportFilter, paths)); return; } case START_ELEMENT: { switch (Element.of(reader.getName())) { case PATHS: { paths = parseSet(reader); break; } case EXPORTS: { parseFilterList(reader, exportBuilder); break; } default: { throw unexpectedContent(reader); } } } } } }
Example #12
Source File: ModuleSpecProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private ServiceName createModuleService(final DeploymentPhaseContext phaseContext, final DeploymentUnit deploymentUnit, final List<ResourceRoot> resourceRoots, final List<ResourceRoot> parentResourceRoots, final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier) throws DeploymentUnitProcessingException { logger.debugf("Creating module: %s", moduleIdentifier); final ModuleSpec.Builder specBuilder = ModuleSpec.build(moduleIdentifier); for (final DependencySpec dep : moduleSpecification.getModuleSystemDependencies()) { specBuilder.addDependency(dep); } final List<ModuleDependency> dependencies = moduleSpecification.getSystemDependencies(); final List<ModuleDependency> localDependencies = moduleSpecification.getLocalDependencies(); final List<ModuleDependency> userDependencies = moduleSpecification.getUserDependencies(); final List<PermissionFactory> permFactories = moduleSpecification.getPermissionFactories(); installAliases(moduleSpecification, moduleIdentifier, deploymentUnit, phaseContext); // add additional resource loaders first for (final ResourceLoaderSpec resourceLoaderSpec : moduleSpecification.getResourceLoaders()) { logger.debugf("Adding resource loader %s to module %s", resourceLoaderSpec, moduleIdentifier); specBuilder.addResourceRoot(resourceLoaderSpec); } for (final ResourceRoot resourceRoot : resourceRoots) { logger.debugf("Adding resource %s to module %s", resourceRoot.getRoot(), moduleIdentifier); addResourceRoot(specBuilder, resourceRoot, permFactories); } createDependencies(specBuilder, dependencies, false); createDependencies(specBuilder, userDependencies, false); if (moduleSpecification.isLocalLast()) { createDependencies(specBuilder, localDependencies, moduleSpecification.isLocalDependenciesTransitive()); specBuilder.addDependency(DependencySpec.createLocalDependencySpec()); } else { specBuilder.addDependency(DependencySpec.createLocalDependencySpec()); createDependencies(specBuilder, localDependencies, moduleSpecification.isLocalDependenciesTransitive()); } final Enumeration<Permission> e = DEFAULT_PERMISSIONS.elements(); while (e.hasMoreElements()) { permFactories.add(new ImmediatePermissionFactory(e.nextElement())); } // TODO: servlet context temp dir FilePermission // add file permissions for parent roots for (ResourceRoot additionalParentRoot : parentResourceRoots) { final VirtualFile root = additionalParentRoot.getRoot(); // start with the root permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getPathName(), VirtualFilePermission.FLAG_READ))); // also include all children, recursively permFactories.add(new ImmediatePermissionFactory( new VirtualFilePermission(root.getChild("-").getPathName(), VirtualFilePermission.FLAG_READ))); } FactoryPermissionCollection permissionCollection = new FactoryPermissionCollection(permFactories.toArray(new PermissionFactory[permFactories.size()])); specBuilder.setPermissionCollection(permissionCollection); deploymentUnit.putAttachment(Attachments.MODULE_PERMISSIONS, permissionCollection); final DelegatingClassFileTransformer delegatingClassFileTransformer = new DelegatingClassFileTransformer(); specBuilder.setClassFileTransformer(delegatingClassFileTransformer); deploymentUnit.putAttachment(DelegatingClassFileTransformer.ATTACHMENT_KEY, delegatingClassFileTransformer); final ModuleSpec moduleSpec = specBuilder.create(); final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(moduleIdentifier); ModuleDefinition moduleDefinition = new ModuleDefinition(moduleIdentifier, new HashSet<>(moduleSpecification.getAllDependencies()), moduleSpec); final ValueService<ModuleDefinition> moduleSpecService = new ValueService<>(new ImmediateValue<>(moduleDefinition)); final ServiceBuilder sb = phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService); sb.requires(deploymentUnit.getServiceName()); sb.requires(phaseContext.getPhaseServiceName()); sb.setInitialMode(Mode.ON_DEMAND); sb.install(); ModuleResolvePhaseService.installService(phaseContext.getServiceTarget(), moduleDefinition); return ModuleLoadService.install(phaseContext.getServiceTarget(), moduleIdentifier, dependencies, localDependencies, userDependencies); }
Example #13
Source File: JBossDeploymentStructureParser11.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
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: throw unexpectedContent(reader); } } Set<String> paths = Collections.emptySet(); final MultiplePathFilterBuilder exportBuilder = PathFilters.multiplePathFilterBuilder(export); while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (export) { // If re-exported, add META-INF/** -> false at the end of the list (require explicit override) exportBuilder.addFilter(PathFilters.getMetaInfSubdirectoriesFilter(), false); exportBuilder.addFilter(PathFilters.getMetaInfFilter(), false); } final PathFilter exportFilter = exportBuilder.create(); specBuilder.addSystemDependency(DependencySpec.createSystemDependencySpec(PathFilters.getDefaultImportFilter(), exportFilter, paths)); return; } case START_ELEMENT: { switch (Element.of(reader.getName())) { case PATHS: { paths = parseSet(reader); break; } case EXPORTS: { parseFilterList(reader, exportBuilder); break; } default: { throw unexpectedContent(reader); } } } } } }
Example #14
Source File: ModuleStructureSpec.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public List<DependencySpec> getSystemDependencies() { return Collections.unmodifiableList(systemDependencies); }
Example #15
Source File: ModuleStructureSpec.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public void addSystemDependency(final DependencySpec dependency) { systemDependencies.add(dependency); }
Example #16
Source File: JBossDeploymentStructureParser13.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
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: throw unexpectedContent(reader); } } Set<String> paths = Collections.emptySet(); final MultiplePathFilterBuilder exportBuilder = PathFilters.multiplePathFilterBuilder(export); while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (export) { // If re-exported, add META-INF/** -> false at the end of the list (require explicit override) exportBuilder.addFilter(PathFilters.getMetaInfSubdirectoriesFilter(), false); exportBuilder.addFilter(PathFilters.getMetaInfFilter(), false); } final PathFilter exportFilter = exportBuilder.create(); specBuilder.addSystemDependency(DependencySpec.createSystemDependencySpec(PathFilters.getDefaultImportFilter(), exportFilter, paths)); return; } case START_ELEMENT: { switch (Element.of(reader.getName())) { case PATHS: { paths = parseSet(reader); break; } case EXPORTS: { parseFilterList(reader, exportBuilder); break; } default: { throw unexpectedContent(reader); } } } } } }
Example #17
Source File: ModuleSpecification.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public List<DependencySpec> getModuleSystemDependencies() { return Collections.unmodifiableList(moduleSystemDependencies); }
Example #18
Source File: ModuleSpecification.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public void addModuleSystemDependencies(final List<DependencySpec> systemDependencies) { moduleSystemDependencies.addAll(systemDependencies); }
Example #19
Source File: DriverInfo.java From thorntail with Apache License 2.0 | 4 votes |
public boolean detect(DatasourcesFraction fraction) { if (fraction.subresources().jdbcDriver(this.name) != null) { // already installed return true; } DatasourcesMessages.MESSAGES.attemptToAutoDetectJdbcDriver(this.name); File primaryJar = attemptDetection(); if (primaryJar != null) { Set<File> optionalJars = findOptionalJars(); optionalJars.add(primaryJar); fraction.jdbcDriver(this.name, (driver) -> { @SuppressWarnings("deprecation") ModuleIdentifier identifier = ModuleIdentifier.fromString(this.moduleIdentifier); driver.driverModuleName(identifier.getName()); driver.moduleSlot(identifier.getSlot()); this.configureDriver(driver); }); DynamicModuleFinder.register(this.moduleIdentifier, (id, loader) -> { ModuleSpec.Builder builder = ModuleSpec.build(id); for (File eachJar : optionalJars) { try { JarFile jar = JarFileManager.INSTANCE.addJarFile(eachJar); builder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec( ResourceLoaders.createIterableJarResourceLoader(jar.getName(), jar) )); } catch (IOException e) { DatasourcesMessages.MESSAGES.errorLoadingAutodetectedJdbcDriver(this.name, e); return null; } } builder.addDependency(new ModuleDependencySpecBuilder() .setName("javax.api") .build()); builder.addDependency(new ModuleDependencySpecBuilder() .setName("javax.transactions.api") .setExport(false) .setOptional(true) .build()); builder.addDependency(DependencySpec.createLocalDependencySpec()); addModuleDependencies(builder); return builder.create(); }); this.installed = true; } return this.installed; }
Example #20
Source File: JBossModuleUtils.java From Nicobar with Apache License 2.0 | 3 votes |
/** * Populates a {@link ModuleSpec} with a dependency on application runtime packages * specified as a set of package paths, loaded within the given classloader. This is the * primary way that a module gains access to packages defined in the application classloader. * This dependency is NOT rexported to downstream modules. * * @param moduleSpecBuilder builder to populate * @param appClassLoader a classloader the application classloader. * @param appPackages the global set of application package paths. */ public static void populateModuleSpecWithAppImports(ModuleSpec.Builder moduleSpecBuilder, ClassLoader appClassLoader, Set<String> appPackages) { Objects.requireNonNull(moduleSpecBuilder, "moduleSpecBuilder"); Objects.requireNonNull(appClassLoader, "classLoader"); moduleSpecBuilder.addDependency(DependencySpec.createClassLoaderDependencySpec(appClassLoader, appPackages, false)); }