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


Java ModuleSpec类代码示例

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


ModuleSpec类属于org.jboss.modules包,在下文中一共展示了ModuleSpec类的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: installAliases

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
private void installAliases(final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier, final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext) {

        for (final ModuleIdentifier alias : moduleSpecification.getAliases()) {
            final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias);
            final ModuleSpec spec = ModuleSpec.buildAlias(alias, moduleIdentifier).create();

            ModuleDefinition moduleDefinition = new ModuleDefinition(alias, new HashSet<>(moduleSpecification.getAllDependencies()), spec);

            final ValueService<ModuleDefinition> moduleSpecService = new ValueService<>(new ImmediateValue<>(moduleDefinition));
            phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService).addDependencies(
                    deploymentUnit.getServiceName()).addDependencies(phaseContext.getPhaseServiceName()).setInitialMode(
                    Mode.ON_DEMAND).install();
            ModuleLoadService.installService(phaseContext.getServiceTarget(), alias, Collections.singletonList(moduleIdentifier));

            ModuleResolvePhaseService.installService(phaseContext.getServiceTarget(), moduleDefinition);
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:ModuleSpecProcessor.java

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

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

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

示例6: getDependencyScriptModuleIds

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

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

示例8: detect

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
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 = new JarFile(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(DependencySpec.createModuleDependencySpec(eachModuleIdentifier));
                }
                builder.addDependency(DependencySpec.createLocalDependencySpec());

                return builder.create();
            });
            this.installed = true;
        }
        return this.installed;
    }
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:38,代码来源:DriverModuleBuilder.java

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

示例10: findModule

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
@Override
public ModuleSpec findModule(String moduleIdentifier, ModuleLoader moduleLoader) throws ModuleLoadException {
    FunctionalModuleFinder delegate = FINDERS.get(moduleIdentifier);
    if (delegate == null) {
        return null;
    }

    return delegate.findModule(moduleIdentifier, moduleLoader);
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:10,代码来源:DynamicModuleFinder.java

示例11: testMain

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
@Test
public void testMain() {
    ClasspathModuleFinder finder = new ClasspathModuleFinder();

    try {
        ModuleSpec spec = finder.findModule("classpath.module.load.test", null);

        assertNotNull(spec);
    } catch (ModuleLoadException e) {
        fail();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:13,代码来源:ClasspathModuleFinderTest.java

示例12: testMissingMain

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
@Test
public void testMissingMain() {
    ClasspathModuleFinder finder = new ClasspathModuleFinder();

    try {
        ModuleSpec spec = finder.findModule("classpath.module.load.test.missing", null);

        assertNull(spec);
    } catch (ModuleLoadException e) {
        fail();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:13,代码来源:ClasspathModuleFinderTest.java

示例13: testSlot

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
@Test
public void testSlot() {
    ClasspathModuleFinder finder = new ClasspathModuleFinder();

    try {
        ModuleSpec spec = finder.findModule("classpath.module.load.test:1.0.0.Final", null);

        assertNotNull(spec);
    } catch (ModuleLoadException e) {
        fail();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:13,代码来源:ClasspathModuleFinderTest.java

示例14: testMissingSlot

import org.jboss.modules.ModuleSpec; //导入依赖的package包/类
@Test
public void testMissingSlot() {
    ClasspathModuleFinder finder = new ClasspathModuleFinder();

    try {
        ModuleSpec spec = finder.findModule("classpath.module.load.test:missing", null);

        assertNull(spec);
    } catch (ModuleLoadException e) {
        fail();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:13,代码来源:ClasspathModuleFinderTest.java

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


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