本文整理汇总了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))
)
);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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());
}