本文整理汇总了Java中org.jboss.modules.Module.getClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java Module.getClassLoader方法的具体用法?Java Module.getClassLoader怎么用?Java Module.getClassLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.modules.Module
的用法示例。
在下文中一共展示了Module.getClassLoader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadTranslators
import org.jboss.modules.Module; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private void loadTranslators(String moduleName) {
ClassLoader translatorLoader = this.getClass().getClassLoader();
try {
final Module module = Module.getBootModuleLoader().loadModule(moduleName);
if (module != null) {
translatorLoader = module.getClassLoader();
final ServiceLoader<ExecutionFactory> serviceLoader = ServiceLoader.load(ExecutionFactory.class,
translatorLoader);
if (serviceLoader != null) {
for (ExecutionFactory ef : serviceLoader) {
Translator t = ef.getClass().getAnnotation(Translator.class);
fraction.translator(t.name(), x -> x.module(moduleName));
}
}
}
} catch (ModuleLoadException e) {
//no-op
}
}
示例2: getRawUsageText
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
public String getRawUsageText() throws Exception {
Module module = Module.getBootModuleLoader().loadModule("swarm.application");
ClassLoader cl = module.getClassLoader();
InputStream in = cl.getResourceAsStream(META_INF_USAGE_TXT);
if (in == null) {
in = cl.getResourceAsStream(WEB_INF_USAGE_TXT);
}
if (in == null) {
in = cl.getResourceAsStream(USAGE_TXT);
}
if (in != null) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
return reader
.lines()
.collect(Collectors.joining("\n"));
}
}
return null;
}
示例3: fromSwarmApplicationModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Produces
@XMLConfig
public URL fromSwarmApplicationModule() {
try {
Module app = Module.getBootModuleLoader().loadModule("swarm.application");
ClassLoader cl = app.getClassLoader();
URL result = cl.getResource(STANDALONE_XML_FILE);
if (result != null) {
SwarmConfigMessages.MESSAGES.loadingStandaloneXml("'swarm.application' module", result.toExternalForm());
}
return result;
} catch (ModuleLoadException e) {
SwarmConfigMessages.MESSAGES.errorLoadingModule(e);
}
return null;
}
示例4: toResponse
import org.jboss.modules.Module; //导入方法依赖的package包/类
public Response toResponse(NotFoundException e) {
if (e.getMessage().contains("favicon.ico")) {
try {
Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.create("org.wildfly.swarm.undertow", "runtime"));
ClassLoader cl = module.getClassLoader();
final InputStream in = cl.getResourceAsStream("favicon.ico");
if (in != null) {
Response.ResponseBuilder builder = Response.ok();
builder.entity(in);
return builder.build();
}
} catch (ModuleLoadException e1) {
throw e;
}
}
// can't handle it, rethrow.
throw e;
}
示例5: setupLoggingSystem
import org.jboss.modules.Module; //导入方法依赖的package包/类
private static void setupLoggingSystem(ModuleLoader moduleLoader) {
final ModuleIdentifier logModuleId = ModuleIdentifier.create(MODULE_ID_LOGMANAGER);
final Module logModule;
try {
logModule = moduleLoader.loadModule(logModuleId);
} catch (final ModuleLoadException mle) {
throw EmbeddedLogger.ROOT_LOGGER.moduleLoaderError(mle, MODULE_ID_LOGMANAGER, moduleLoader);
}
final ModuleClassLoader logModuleClassLoader = logModule.getClassLoader();
final ClassLoader tccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(logModuleClassLoader);
WildFlySecurityManager.setPropertyPrivileged(SYSPROP_KEY_LOGMANAGER, SYSPROP_VALUE_JBOSS_LOGMANAGER);
final Class<?> actualLogManagerClass = LogManager.getLogManager().getClass();
if (actualLogManagerClass == LogManager.class) {
System.err.println("Cannot not load JBoss LogManager. The LogManager has likely been accessed prior to this initialization.");
} else {
Module.setModuleLogger(new JDKModuleLogger());
}
} finally {
// Reset TCCL
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(tccl);
}
}
示例6: doRunTestMethod
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
protected TestResult doRunTestMethod(TestRunner runner, Class<?> testClass, String methodName, Map<String, String> protocolProps) {
ClassLoader runWithClassLoader = ClassLoader.getSystemClassLoader();
if (Boolean.parseBoolean(protocolProps.get(ExtendedJMXProtocolConfiguration.PROPERTY_ENABLE_TCCL))) {
ArquillianConfig config = getArquillianConfig(testClass.getName(), 30000L);
DeploymentUnit depUnit = config.getDeploymentUnit().getValue();
Module module = depUnit.getAttachment(Attachments.MODULE);
if (module != null) {
runWithClassLoader = module.getClassLoader();
}
}
ClassLoader tccl = WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(runWithClassLoader);
try {
return super.doRunTestMethod(runner, testClass, methodName, protocolProps);
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(tccl);
}
}
示例7: deploy
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
final Module module = depUnit.getAttachment(Attachments.MODULE);
final String runtimeName = depUnit.getName();
// Add the camel context bootstraps to the deployment
CamelDeploymentSettings depSettings = depUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY);
for (URL contextURL : depSettings.getCamelContextUrls()) {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(module.getClassLoader());
SpringCamelContextBootstrap bootstrap = new SpringCamelContextBootstrap(contextURL, module.getClassLoader());
depUnit.addToAttachmentList(CamelConstants.CAMEL_CONTEXT_BOOTSTRAP_KEY, bootstrap);
} catch (Exception ex) {
throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
}
}
示例8: testHandlerRegistry
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testHandlerRegistry() throws Exception {
ContextCreateHandlerRegistry handlerRegistry = ServiceLocator.getRequiredService(ContextCreateHandlerRegistry.class);
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
deployer.deploy(CAMEL_TEST_JAR);
Module module = moduleLoader.loadModule(ModuleIdentifier.create("deployment.camel-test.jar"));
ClassLoader classLoader = module.getClassLoader();
// Registry should have classloader key after deploy
Assert.assertTrue(handlerRegistry.containsKey(classLoader));
deployer.undeploy(CAMEL_TEST_JAR);
// Registry should have removed classloader key after undeploy
Assert.assertFalse("Expected registry to not contain key: " + classLoader, handlerRegistry.containsKey(classLoader));
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:19,代码来源:ContextCreateHandlerRegistryIntegrationTest.java
示例9: compileModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
/**
* Compiles and links the scripts within the module by locating the correct compiler
* and delegating the compilation. the classes will be loaded into the module's classloader
* upon completion.
* @param module module to be compiled
* @param moduleCompilationRoot the directory to store compiled classes in.
*/
protected void compileModule(Module module, Path moduleCompilationRoot) throws ScriptCompilationException, IOException {
// compile the script archive for the module, and inject the resultant classes into
// the ModuleClassLoader
ModuleClassLoader moduleClassLoader = module.getClassLoader();
if (moduleClassLoader instanceof JBossModuleClassLoader) {
JBossModuleClassLoader jBossModuleClassLoader = (JBossModuleClassLoader)moduleClassLoader;
ScriptArchive scriptArchive = jBossModuleClassLoader.getScriptArchive();
List<ScriptArchiveCompiler> candidateCompilers = findCompilers(scriptArchive);
if (candidateCompilers.size() == 0) {
throw new ScriptCompilationException("Could not find a suitable compiler for this archive.");
}
// Compile iteratively
for (ScriptArchiveCompiler compiler: candidateCompilers) {
compiler.compile(scriptArchive, jBossModuleClassLoader, moduleCompilationRoot);
}
}
}
示例10: testPathResources
import org.jboss.modules.Module; //导入方法依赖的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());
}
示例11: classLoader
import org.jboss.modules.Module; //导入方法依赖的package包/类
public MethodHandleBuilder classLoader(ModuleIdentifier moduleIdentifier) {
Module module;
try {
module = Module.getBootModuleLoader().loadModule(moduleIdentifier);
} catch (ModuleLoadException e) {
// TODO: use NoSQLLogger for all exceptions created here
throw new RuntimeException("Could not load module " + moduleIdentifier.getName(), e);
}
this.classLoader = module.getClassLoader();
return this;
}
示例12: handleRequest
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
boolean faviconHandled = false;
if (!exchange.isResponseComplete() && exchange.getRequestPath().contains("favicon.ico")) {
try (InputStream faviconStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("favicon.ico")) {
if (faviconStream != null) {
// Load from WAR
faviconHandled = writeFavicon(faviconStream, exchange);
}
}
if (!faviconHandled) {
Module module = Module.getBootModuleLoader().loadModule("org.wildfly.swarm.undertow:runtime");
ClassLoader cl = module.getClassLoader();
try (InputStream in = cl.getResourceAsStream("favicon.ico")) {
if (in != null) {
// Return default
faviconHandled = writeFavicon(in, exchange);
}
}
}
}
if (!faviconHandled) {
this.next.handleRequest(exchange);
}
}
示例13: getBootstrapClassLoader
import org.jboss.modules.Module; //导入方法依赖的package包/类
public ClassLoader getBootstrapClassLoader() throws ModuleLoadException {
if (this.mode == Mode.UBERJAR) {
try {
//ClassLoader cl = Module.getBootModuleLoader().loadModule("org.wildfly.swarm.bootstrap").getClassLoader();
Module module = Module.getBootModuleLoader().loadModule("org.wildfly.swarm.bootstrap");
ClassLoader cl = module.getClassLoader();
return cl;
} catch (ModuleLoadException e) {
// ignore
}
}
return ApplicationEnvironment.class.getClassLoader();
}
示例14: deploy
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ServiceTarget target = phaseContext.getServiceTarget();
if (!TeiidAttachments.isTranslator(deploymentUnit)) {
return;
}
String moduleName = deploymentUnit.getName();
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
ClassLoader translatorLoader = module.getClassLoader();
final ServiceLoader<ExecutionFactory> serviceLoader = ServiceLoader.load(ExecutionFactory.class, translatorLoader);
if (serviceLoader != null) {
for (ExecutionFactory ef:serviceLoader) {
VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(ef, moduleName);
if (metadata == null) {
throw new DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50070, moduleName));
}
deploymentUnit.putAttachment(TeiidAttachments.TRANSLATOR_METADATA, metadata);
metadata.addProperty(TranslatorUtil.DEPLOYMENT_NAME, moduleName);
metadata.addAttchment(ClassLoader.class, translatorLoader);
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50006, metadata.getName()));
buildService(target, metadata);
}
}
}
示例15: resolveClassLoader
import org.jboss.modules.Module; //导入方法依赖的package包/类
static ClassLoader resolveClassLoader(String module) throws ModuleLoadException {
Module current = Module.getCallerModule();
if (module != null && current != null) {
ModuleIdentifier mi = ModuleIdentifier.fromString(module);
current = current.getModule(mi);
}
return current != null ? current.getClassLoader() : ClassLoadingAttributeDefinitions.class.getClassLoader();
}