Java Code Examples for org.jboss.modules.Module#getCallerModuleLoader()
The following examples show how to use
org.jboss.modules.Module#getCallerModuleLoader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextCreateHandlerRegistryIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testHandlerRegistry() throws Exception { ContextCreateHandlerRegistry handlerRegistry = ServiceLocator.getRequiredService(CamelConstants.CONTEXT_CREATE_HANDLER_REGISTRY_SERVICE_NAME, 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)); }
Example 2
Source File: ModuleLoadingResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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; }
Example 3
Source File: SecurityActions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
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()); }
Example 4
Source File: SpringExcludedPathsTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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); }
Example 5
Source File: SpringJeeNamespaceTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: SpringJeeNamespaceTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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); }
Example 7
Source File: CXFResourcesTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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); }
Example 8
Source File: CXFResourcesTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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); }
Example 9
Source File: CXFResourcesTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: ConfigSupport.java From wildfly-camel with Apache License 2.0 | 5 votes |
public static void applyConfigChange(Path jbossHome, List<String> configs, boolean enable) throws Exception { IllegalStateAssertion.assertFalse(configs.isEmpty(), "No configurations specified"); Iterator<ConfigPlugin> itsrv; ClassLoader classLoader = ConfigSupport.class.getClassLoader(); // In wildfly every plugin lives in its own module. // The module identity corresponds to the config name if (classLoader instanceof ModuleClassLoader) { List<ConfigPlugin> plugins = new ArrayList<>(); for (String config : configs) { ModuleLoader moduleLoader = Module.getCallerModuleLoader(); ModuleIdentifier modid = ModuleIdentifier.create("org.wildfly.extras.config.plugin." + config); ModuleClassLoader modcl = moduleLoader.loadModule(modid).getClassLoader(); Iterator<ConfigPlugin> auxit = ServiceLoader.load(ConfigPlugin.class, modcl).iterator(); while (auxit.hasNext()) { plugins.add(auxit.next()); } } itsrv = plugins.iterator(); } else { itsrv = ServiceLoader.load(ConfigPlugin.class, classLoader).iterator(); } while (itsrv.hasNext()) { ConfigPlugin plugin = itsrv.next(); if (configs.contains(plugin.getConfigName())) { ConfigLogger.info("Processing config for: " + plugin.getConfigName()); applyLayerChanges(jbossHome, plugin, enable); applyConfigurationChanges(jbossHome, plugin, enable); } } }
Example 11
Source File: RuntimeVaultReader.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
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(); }