本文整理汇总了Java中org.jboss.modules.Module.getCallerModuleLoader方法的典型用法代码示例。如果您正苦于以下问题:Java Module.getCallerModuleLoader方法的具体用法?Java Module.getCallerModuleLoader怎么用?Java Module.getCallerModuleLoader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.modules.Module
的用法示例。
在下文中一共展示了Module.getCallerModuleLoader方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFromModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
static ServerConnection createFromModule(Properties info)
throws ConnectionException, TeiidException {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
ModuleLoader callerModuleLoader = Module.getCallerModuleLoader();
if (callerModuleLoader == null) {
throw new ConnectionException(JDBCPlugin.Event.TEIID20033, null, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20033));
}
final Module module = callerModuleLoader.loadModule(ModuleIdentifier.create("org.jboss.teiid")); //$NON-NLS-1$
Thread.currentThread().setContextClassLoader(module.getClassLoader());
return (ServerConnection)ReflectionHelper.create("org.teiid.transport.LocalServerConnection", Arrays.asList(info, PropertiesUtils.getBooleanProperty(info, EmbeddedProfile.USE_CALLING_THREAD, true)), Thread.currentThread().getContextClassLoader()); //$NON-NLS-1$
} catch (ModuleLoadException e) {
throw new ConnectionException(JDBCPlugin.Event.TEIID20008, e, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20008));
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
}
示例2: 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
示例3: findResourcePaths
import org.jboss.modules.Module; //导入方法依赖的package包/类
private static List<String> findResourcePaths(String moduleName) throws ModuleLoadException, ReflectiveOperationException, IOException, URISyntaxException {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleLoaderMXBean loader = ModuleInfoHandler.INSTANCE.getMxBean(moduleLoader);
moduleLoader.loadModule(ModuleIdentifier.fromString(moduleName));
List<String> result = new LinkedList<>();
for (ResourceLoaderInfo rl : loader.getResourceLoaders(moduleName)){
if (rl.getLocation() != null) {
URL url = new URL(rl.getLocation());
switch (url.getProtocol()){
case "jar": {
JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
result.add(jarConnection.getJarFile().getName());
break;
}
default: {
result.add(new File(url.getFile() ).toString());
}
}
}
}
return result;
}
示例4: internalLoadAndInstantiateFromModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
private static <T> T internalLoadAndInstantiateFromModule(String moduleId, final Class<T> iface, final String name) throws Exception {
ModuleLoader loader = Module.getCallerModuleLoader();
final Module module = loader.loadModule(ModuleIdentifier.fromString(moduleId));
ClassLoader cl = WildFlySecurityManager.isChecking() ? doPrivileged(new GetModuleClassLoaderAction(module)) : module.getClassLoader();
Class<?> clazz = cl.loadClass(name);
return iface.cast(clazz.newInstance());
}
示例5: testAccessFromCamelSpringModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testAccessFromCamelSpringModule() throws Exception {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleIdentifier modid = ModuleIdentifier.create("org.apache.camel.spring");
ModuleClassLoader classLoader = moduleLoader.loadModule(modid).getClassLoader();
Class<?> loadedClass = classLoader.loadClass("org.apache.camel.spring.SpringCamelContext");
Assert.assertNotNull("Class not null", loadedClass);
loadedClass = classLoader.loadClass("org.apache.camel.spring.remoting.CamelServiceExporter");
Assert.assertNotNull("Class not null", loadedClass);
}
示例6: testLoadHandlersFromSpringContext
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testLoadHandlersFromSpringContext() throws Exception {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleClassLoader classLoader = moduleLoader.loadModule("org.springframework.context").getClassLoader();
URL resurl = classLoader.getResource("META-INF/spring.handlers");
Assert.assertNotNull("URL not null", resurl);
}
示例7: testLoadHandlersFromCamel
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testLoadHandlersFromCamel() throws Exception {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleClassLoader classLoader = moduleLoader.loadModule("org.apache.camel").getClassLoader();
URL resurl = classLoader.getResource("META-INF/spring.handlers");
Assert.assertNotNull("URL not null", resurl);
}
示例8: testAccessFromCXFModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testAccessFromCXFModule() throws Exception {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleIdentifier modid = ModuleIdentifier.create("org.apache.cxf");
ModuleClassLoader classLoader = moduleLoader.loadModule(modid).getClassLoader();
URL resurl = classLoader.getResource("META-INF/cxf/cxf.xml");
Assert.assertNotNull("URL not null", resurl);
}
示例9: testAccessFromCXFComponentModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testAccessFromCXFComponentModule() throws Exception {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleIdentifier modid = ModuleIdentifier.create("org.apache.camel.component.cxf");
ModuleClassLoader classLoader = moduleLoader.loadModule(modid).getClassLoader();
URL resurl = classLoader.getResource("META-INF/cxf/cxf.xml");
Assert.assertNotNull("URL not null", resurl);
}
示例10: testAccessFromCamelComponentModule
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Test
public void testAccessFromCamelComponentModule() throws Exception {
ModuleLoader moduleLoader = Module.getCallerModuleLoader();
ModuleIdentifier modid = ModuleIdentifier.create("org.apache.camel.component");
ModuleClassLoader classLoader = moduleLoader.loadModule(modid).getClassLoader();
URL resurl = classLoader.getResource("META-INF/cxf/cxf.xml");
Assert.assertNotNull("URL not null", resurl);
}
示例11: performRuntime
import org.jboss.modules.Module; //导入方法依赖的package包/类
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model,
final ServiceVerificationHandler verificationHandler, final List<ServiceController<?>> newControllers) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
final PathAddress pathAddress = PathAddress.pathAddress(address);
final String translatorName = pathAddress.getLastElement().getValue();
String moduleName = null;
if (isDefined(TRANSLATOR_MODULE_ATTRIBUTE, operation, context)) {
moduleName = asString(TRANSLATOR_MODULE_ATTRIBUTE, operation, context);
}
final ServiceTarget target = context.getServiceTarget();
final Module module;
ClassLoader translatorLoader = this.getClass().getClassLoader();
ModuleLoader ml = Module.getCallerModuleLoader();
if (moduleName != null && ml != null) {
try {
module = ml.loadModule(ModuleIdentifier.create(moduleName));
translatorLoader = module.getClassLoader();
} catch (ModuleLoadException e) {
throw new OperationFailedException(e, new ModelNode().set(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50007, moduleName, translatorName)));
}
}
boolean added = false;
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 OperationFailedException( new ModelNode().set(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50008, translatorName)));
}
metadata.addAttchment(ClassLoader.class, translatorLoader);
if (translatorName.equalsIgnoreCase(metadata.getName())) {
LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50006, metadata.getName()));
TranslatorDeployer.buildService(target, metadata);
added = true;
break;
}
}
}
if (!added) {
throw new OperationFailedException(new ModelNode().set(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50009, translatorName, moduleName)));
}
}
示例12: getModuleClassLoader
import org.jboss.modules.Module; //导入方法依赖的package包/类
private ModuleClassLoader getModuleClassLoader(final String moduleSpec) throws ModuleLoadException {
ModuleLoader loader = Module.getCallerModuleLoader();
final Module module = loader.loadModule(ModuleIdentifier.fromString(moduleSpec));
return WildFlySecurityManager.isChecking() ? doPrivileged(new GetModuleClassLoaderAction(module)) : module.getClassLoader();
}