当前位置: 首页>>代码示例>>Java>>正文


Java ModuleSpec.Builder方法代码示例

本文整理汇总了Java中org.jboss.modules.ModuleSpec.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleSpec.Builder方法的具体用法?Java ModuleSpec.Builder怎么用?Java ModuleSpec.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.modules.ModuleSpec的用法示例。


在下文中一共展示了ModuleSpec.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
void apply(ModuleSpec.Builder builder, MavenArtifactDescriptor entry) throws IOException {
    File artifact = MavenResolvers.get().resolveJarArtifact(entry.mscCoordinates());
    if (artifact == null) {
        throw new IOException("Unable to locate artifact: " + entry.mscGav());
    }

    if (LOG.isTraceEnabled()) {
        LOG.trace("adding bootstrap artifact: " + artifact.getAbsolutePath());
    }

    builder.addResourceRoot(
            ResourceLoaderSpec.createResourceLoaderSpec(
                    ResourceLoaders.createJarResourceLoader(artifact.getName(), new JarFile(artifact))
            )
    );
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:17,代码来源:WildFlySwarmBootstrapConf.java

示例2: addResourceRoot

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
private void addResourceRoot(final ModuleSpec.Builder specBuilder, final ResourceRoot resource, final List<PermissionFactory> permFactories)
        throws DeploymentUnitProcessingException {
    try {
        final VirtualFile root = resource.getRoot();
        if (resource.getExportFilters().isEmpty()) {
            specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource
                    .getRootName(), root, resource.isUsePhysicalCodeSource())));
        } else {
            final MultiplePathFilterBuilder filterBuilder = PathFilters.multiplePathFilterBuilder(true);
            for (final FilterSpecification filter : resource.getExportFilters()) {
                filterBuilder.addFilter(filter.getPathFilter(), filter.isInclude());
            }
            specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new VFSResourceLoader(resource
                    .getRootName(), root, resource.isUsePhysicalCodeSource()), filterBuilder.create()));
        }
        // 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)));
    } catch (IOException e) {
        throw ServerLogger.ROOT_LOGGER.failedToCreateVFSResourceLoader(resource.getRootName(), e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:ModuleSpecProcessor.java

示例3: start

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
@Override
public synchronized void start(StartContext context) throws StartException {
    try {
        this.jarFile = new JarFile(file);
    } catch (IOException e) {
        throw new StartException(e);
    }
    final ModuleSpec.Builder specBuilder = ModuleSpec.build(moduleIdentifier);
    addResourceRoot(specBuilder, jarFile);
    //TODO: We need some way of configuring module dependencies for external archives
    ModuleIdentifier javaee = ModuleIdentifier.create("javaee.api");
    specBuilder.addDependency(DependencySpec.createModuleDependencySpec(javaee));
    specBuilder.addDependency(DependencySpec.createLocalDependencySpec());
    // TODO: external resource need some kind of dependency mechanism
    ModuleSpec moduleSpec = specBuilder.create();
    this.moduleDefinition = new ModuleDefinition(moduleIdentifier, Collections.<ModuleDependency>emptySet(), moduleSpec);


    ServiceModuleLoader.installModuleResolvedService(context.getChildTarget(), moduleIdentifier);

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:ExternalModuleSpecService.java

示例4: testPathResources

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * Verify that the module creates the expected set of dependencies for a {@link PathScriptArchive}
 */
@Test
public void testPathResources() throws Exception {
    Path jarPath = CoreTestResourceUtil.getResourceAsPath(TEST_TEXT_PATH);
    ScriptArchive jarScriptArchive = new PathScriptArchive.Builder(jarPath)
        .setModuleSpec(new ScriptModuleSpec.Builder(ModuleId.create("testModuleId"))
            .addMetadata(METADATA_NAME, METADATA_VALUE)
            .build())
        .build();
    ModuleIdentifier revisionId = JBossModuleUtils.createRevisionId(TEST_TEXT_PATH.getModuleId(), 1);
    ModuleSpec.Builder moduleSpecBuilder = ModuleSpec.build(revisionId);
    JBossModuleLoader moduleLoader = new JBossModuleLoader();
    JBossModuleUtils.populateModuleSpecWithCoreDependencies(moduleSpecBuilder, jarScriptArchive);
    JBossModuleUtils.populateModuleSpecWithResources(moduleSpecBuilder, jarScriptArchive);
    moduleLoader.addModuleSpec(moduleSpecBuilder.create());

    Module module = moduleLoader.loadModule(revisionId);
    ModuleClassLoader moduleClassLoader = module.getClassLoader();

    // verify the metadata was transfered
    assertEquals(module.getProperty(METADATA_NAME), METADATA_VALUE);
    // verify that the archive resource match exactly the module resources
    Set<String> actualPaths = getResourcePaths(moduleClassLoader);

    assertEquals(actualPaths, TEST_TEXT_PATH.getContentPaths());
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:29,代码来源:JBossModuleUtilsTest.java

示例5: findModule

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
@Override
public ModuleSpec findModule(String identifier, ModuleLoader delegateLoader) throws ModuleLoadException {
    if (!this.moduleName.equals(identifier)) {
        return null;
    }

    ModuleSpec.Builder builder = ModuleSpec.build(identifier);
    buildModule(builder, delegateLoader);
    return builder.create();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:11,代码来源:AbstractSingleModuleFinder.java

示例6: testDependency

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
@Test
public void testDependency() {
    // Mocks
    ApplicationEnvironment env = mock(ApplicationEnvironment.class);
    when(env.getDependencies()).thenReturn(Collections.singleton("org.jboss.forge.addon:ui-spi:jar:3.4.0.Final"));

    ModuleSpec.Builder builder = mock(ModuleSpec.Builder.class);

    ApplicationModuleFinder sut = new ApplicationModuleFinder();
    sut.addDependencies(builder, env);

    verify(builder, times(1)).addResourceRoot(any());
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:14,代码来源:ApplicationModuleFinderTest.java

示例7: testDependencyHasClassifier

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
@Test
public void testDependencyHasClassifier() {
    // Mocks
    ApplicationEnvironment env = mock(ApplicationEnvironment.class);
    when(env.getDependencies()).thenReturn(Collections.singleton("org.jboss.forge.addon:ui-spi:jar:forge-addon:3.4.0.Final"));

    ModuleSpec.Builder builder = mock(ModuleSpec.Builder.class);

    ApplicationModuleFinder sut = new ApplicationModuleFinder();
    sut.addDependencies(builder, env);

    verify(builder, times(1)).addResourceRoot(any());
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:14,代码来源:ApplicationModuleFinderTest.java

示例8: handleWildFlySwarmApplicationConf

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
protected void handleWildFlySwarmApplicationConf(ModuleSpec.Builder builder) throws Exception {
    InputStream appConf = getClass().getClassLoader().getResourceAsStream(WildFlySwarmApplicationConf.CLASSPATH_LOCATION);
    if (appConf != null) {
        WildFlySwarmApplicationConf conf = new WildFlySwarmApplicationConf(appConf);
        conf.apply(builder);
    }
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:8,代码来源:ApplicationModuleFinder.java

示例9: findModule

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
@Override
public ModuleSpec findModule(ModuleIdentifier identifier, ModuleLoader delegateLoader) throws ModuleLoadException {
    if (!identifier.getName().equals(this.moduleName) || !identifier.getSlot().equals(this.moduleSlot)) {
        return null;
    }

    ModuleSpec.Builder builder = ModuleSpec.build(identifier);
    buildModule(builder, delegateLoader);
    return builder.create();
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:11,代码来源:AbstractSingleModuleFinder.java

示例10: handleWildFlySwarmBootstrapConf

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
protected void handleWildFlySwarmBootstrapConf(ModuleSpec.Builder builder) throws IOException {
    if (LOG.isTraceEnabled()) {
        LOG.trace("Loading conf from " + WildFlySwarmBootstrapConf.CLASSPATH_LOCATION);
    }
    InputStream bootstrapTxt = getClass().getClassLoader().getResourceAsStream(WildFlySwarmBootstrapConf.CLASSPATH_LOCATION);

    if (bootstrapTxt != null) {
        WildFlySwarmBootstrapConf conf = new WildFlySwarmBootstrapConf(bootstrapTxt);
        conf.apply(builder);
    }
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:12,代码来源:BootstrapModuleFinder.java

示例11: apply

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
@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));
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:14,代码来源:WildFlySwarmApplicationConf.java

示例12: createModuleSpec

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * Create a JBoss module spec for an about to be created script module.
 * @param archive the script archive being converted to a module.
 * @param moduleId the JBoss module identifier.
 * @param moduleIdMap a map of loaded script module IDs to jboss module identifiers
 * @param moduleCompilationRoot a path to a directory that will hold compiled classes for this module.
 * @throws ModuleLoadException
 */
protected ModuleSpec createModuleSpec(ScriptArchive archive,
        ModuleIdentifier moduleId,
        Map<ModuleId, ModuleIdentifier> moduleIdMap,
        Path moduleCompilationRoot) throws ModuleLoadException {
    ScriptModuleSpec archiveSpec = archive.getModuleSpec();
    // create the jboss module pre-cursor artifact
    ModuleSpec.Builder moduleSpecBuilder = ModuleSpec.build(moduleId);

    JBossModuleUtils.populateModuleSpecWithResources(moduleSpecBuilder, archive);
    JBossModuleUtils.populateModuleSpecWithCoreDependencies(moduleSpecBuilder, archive);
    JBossModuleUtils.populateModuleSpecWithAppImports(moduleSpecBuilder,
            appClassLoader, archiveSpec.getAppImportFilterPaths() == null ? appPackagePaths : archiveSpec.getAppImportFilterPaths());
    // Allow compiled class files to fetched as resources later on.
    JBossModuleUtils.populateModuleSpecWithCompilationRoot(moduleSpecBuilder, moduleCompilationRoot);

    // Populate the modulespec with the scriptArchive dependencies
    for (ModuleId dependencyModuleId : archiveSpec.getModuleDependencies()) {
        ScriptModule dependencyModule = getScriptModule(dependencyModuleId);
        Set<String> exportPaths = dependencyModule.getSourceArchive().getModuleSpec().getModuleExportFilterPaths();

        JBossModuleUtils.populateModuleSpecWithModuleDependency(moduleSpecBuilder,
            archiveSpec.getModuleImportFilterPaths(), exportPaths, moduleIdMap.get(dependencyModuleId));
    }

    return moduleSpecBuilder.create();
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:35,代码来源:ScriptModuleLoader.java

示例13: addCompilerPlugin

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * Add a language plugin to this module
 * @param pluginSpec
 * @throws ModuleLoadException
 */
public synchronized void addCompilerPlugin(ScriptCompilerPluginSpec pluginSpec) throws ModuleLoadException  {
    Objects.requireNonNull(pluginSpec, "pluginSpec");
    ModuleIdentifier pluginModuleId = JBossModuleUtils.getPluginModuleId(pluginSpec);
    ModuleSpec.Builder moduleSpecBuilder = ModuleSpec.build(pluginModuleId);
    Map<ModuleId, ModuleIdentifier> latestRevisionIds = jbossModuleLoader.getLatestRevisionIds();
    JBossModuleUtils.populateCompilerModuleSpec(moduleSpecBuilder, pluginSpec, latestRevisionIds);
    // Add app package dependencies, while blocking them from leaking (being exported) to downstream modules
    // TODO: We expose the full set of app packages to the compiler too.
    // Maybe more control over what is exposed is needed here.
    JBossModuleUtils.populateModuleSpecWithAppImports(moduleSpecBuilder, appClassLoader, appPackagePaths);
    ModuleSpec moduleSpec = moduleSpecBuilder.create();

    // spin up the module, and get the compiled classes from it's classloader
    String providerClassName = pluginSpec.getPluginClassName();
    if (providerClassName != null) {
        jbossModuleLoader.addModuleSpec(moduleSpec);
        Module pluginModule = jbossModuleLoader.loadModule(pluginModuleId);
        ModuleClassLoader pluginClassLoader = pluginModule.getClassLoader();
        Class<?> compilerProviderClass;
        try {
            compilerProviderClass = pluginClassLoader.loadClass(providerClassName);
            ScriptCompilerPlugin pluginBootstrap = (ScriptCompilerPlugin) compilerProviderClass.newInstance();
            Set<? extends ScriptArchiveCompiler> pluginCompilers = pluginBootstrap.getCompilers(pluginSpec.getCompilerParams());
            compilers.addAll(pluginCompilers);
        } catch (Exception e) {
            throw new ModuleLoadException(e);
        }

        // Save classloader away, in case clients would like access to compiler plugin's classes.
        compilerClassLoaders.put(pluginSpec.getPluginId(), pluginModule.getClassLoader());
    }
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:38,代码来源:ScriptModuleLoader.java

示例14: populateModuleSpecWithCoreDependencies

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * 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());
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:20,代码来源:JBossModuleUtils.java

示例15: populateModuleSpecWithModuleDependency

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * 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));
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:19,代码来源:JBossModuleUtils.java


注:本文中的org.jboss.modules.ModuleSpec.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。