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


Java ModuleSpec.build方法代码示例

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


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

示例1: 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

示例2: get

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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: testExpectedPluginDependencies

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * Verify that the module creates the expected set of dependencies for a {@link ScriptCompilerPlugin}
 */
@Test
public void testExpectedPluginDependencies() throws Exception {
    ScriptCompilerPluginSpec pluginSpec = new ScriptCompilerPluginSpec.Builder("TestPlugin")
        .addMetatdata(METADATA_NAME, METADATA_VALUE)
        .build();
    ModuleIdentifier pluginId = JBossModuleUtils.getPluginModuleId(pluginSpec);
    ModuleSpec.Builder moduleSpecBuilder = ModuleSpec.build(pluginId);
    JBossModuleUtils.populateCompilerModuleSpec(moduleSpecBuilder, pluginSpec, Collections.<ModuleId, ModuleIdentifier>emptyMap());

    JBossModuleLoader moduleLoader = new JBossModuleLoader();
    moduleLoader.addModuleSpec(moduleSpecBuilder.create());
    Module module = moduleLoader.loadModule(pluginId);
    assertNotNull(module);
    ModuleClassLoader moduleClassLoader = module.getClassLoader();

    // verify the metadata was transfered
    assertEquals(module.getProperty(METADATA_NAME), METADATA_VALUE);

    // verify the module can import the core classes
    assertNotNull(moduleClassLoader.loadClass(ScriptCompilerPlugin.class.getName()));

    // verify the module can find the JDK classes
    assertNotNull(moduleClassLoader.loadClass("org.w3c.dom.Element"));

    // verify that nothing else from the classpath leaked through
    assertClassNotFound(TestNG.class.getName(), moduleClassLoader);
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:31,代码来源:JBossModuleUtilsTest.java

示例9: testJarResources

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
/**
 * Verify that the module creates the expected set of dependencies for a {@link JarScriptArchive}
 */
@Test
public void testJarResources() throws Exception {
    Path jarPath = CoreTestResourceUtil.getResourceAsPath(TEST_TEXT_JAR);
    ScriptArchive jarScriptArchive = new JarScriptArchive.Builder(jarPath)
            .setModuleSpec(new ScriptModuleSpec.Builder(ModuleId.create("testModuleId"))
            .addMetadata(METADATA_NAME, METADATA_VALUE)
            .build())
        .build();

    ModuleIdentifier revisionId = JBossModuleUtils.createRevisionId(TEST_TEXT_JAR.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_JAR.getContentPaths());
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:30,代码来源:JBossModuleUtilsTest.java

示例10: newModule

import org.jboss.modules.ModuleSpec; //导入方法依赖的package包/类
private static Map<ModuleIdentifier, ModuleSpec> newModule(final String name,
    final int level, final String prefix, final File... cp) throws Exception {
  Map<ModuleIdentifier, ModuleSpec> modules = new HashMap<>();

  String mId = name.replace(".jar", "");
  ModuleSpec.Builder builder = ModuleSpec.build(ModuleIdentifier.fromString(mId));
  if (level == 0) {
    String classurl = AppModuleLoader.class
        .getResource("/" + Main.JOOBY_REF.replace(".", "/") + ".class")
        .toString();
    String jartoken = ".jar!";
    File jar = new File(URI
        .create(classurl.substring(0, classurl.indexOf(jartoken) + jartoken.length() - 1)
            .replace("jar:", "")));
    Main.debug("loading hack: %s?%s", jar, jar.exists());
    builder.addResourceRoot(ResourceLoaderSpec
        .createResourceLoaderSpec(ResourceLoaders
            .createJarResourceLoader("jooby-run", new JarFile(jar))));
  }

  int l = (prefix.length() + mId.length() + level);
  Main.debug("%1$" + l + "s", prefix + mId);
  for (File file : cp) {
    if (file.getName().endsWith(".pom")) {
      // skip pom(s)
      continue;
    }
    if (!file.exists()) {
      // skip missing file/dir
      continue;
    }
    String fname = "└── " + file.getAbsolutePath();
    if (file.getName().startsWith("j2v8") && !name.equals(file.getName())) {
      ModuleSpec dependency = newModule(file.getName(), level + 2, "└── ", file)
          .values()
          .iterator()
          .next();
      builder.addDependency(
          DependencySpec.createModuleDependencySpec(dependency.getModuleIdentifier()));
      modules.put(dependency.getModuleIdentifier(), dependency);
    } else {
      Main.debug("%1$" + (fname.length() + level + 2) + "s", fname);
      if (file.getName().endsWith(".jar")) {
        builder.addResourceRoot(ResourceLoaderSpec
            .createResourceLoaderSpec(ResourceLoaders
                .createJarResourceLoader(file.getName(), new JarFile(file))));
      } else {
        builder.addResourceRoot(ResourceLoaderSpec
            .createResourceLoaderSpec(ResourceLoaders
                .createFileResourceLoader(file.getName(), file)));
      }
    }
  }
  Set<String> sysPaths = sysPaths();

  Main.trace("system packages:");
  sysPaths.forEach(p -> Main.trace("  %s", p));

  builder.addDependency(DependencySpec.createSystemDependencySpec(sysPaths));
  builder.addDependency(DependencySpec.createLocalDependencySpec());

  ModuleSpec module = builder.create();
  modules.put(module.getModuleIdentifier(), builder.create());
  return modules;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:66,代码来源:AppModuleLoader.java


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