/** * Return the class loader associated to the JBoss Module identified by the {@code moduleName} * * @param moduleName the name of the module (can not be {@code null} * @return the class loader associated to the JBoss Module * @throws IOException if the module can not be loaded or if JBoss Modules is not present */ static ClassLoader getClassLoaderFromModule(String moduleName) throws IOException{ try { return Module.getCallerModuleLoader().loadModule(moduleName).getClassLoader(); } catch (ModuleLoadException e) { throw new IOException("Failed to create endpoint", e); } catch (LinkageError e) { throw new IOException("Failed to create endpoint: JBoss Modules is not present", e); } } }
private static Class<?> loadDriver(String driverName, String moduleName) throws IllegalArgumentException { try { Module module = Module.getCallerModuleLoader().loadModule(moduleName); AgroalLogger.DRIVER_LOGGER.debugf("loaded module '%s' for driver: %s", moduleName, driverName); ServiceLoader<Driver> serviceLoader = module.loadService(Driver.class); if (serviceLoader.iterator().hasNext()) { // Consider just the first definition. User can use different implementation only with explicit declaration of class attribute Class<?> driverClass = serviceLoader.iterator().next().getClass(); AgroalLogger.DRIVER_LOGGER.driverLoaded(driverClass.getName(), driverName); return driverClass; } return null; } catch (ModuleLoadException e) { throw AgroalLogger.DRIVER_LOGGER.loadModuleException(e, moduleName); } }
private static Class unwrapClass(ModelNode classModel) throws OperationFailedException { String className = classModel.get(NAME).asString(); String moduleName = classModel.get(MODULE).asString(); try { ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName); Module module = Module.getCallerModuleLoader().loadModule(moduleID); Class<?> clazz = module.getClassLoader().loadClass(className); return clazz; } catch (Exception e) { throw ROOT_LOGGER.unableToLoadClassFromModule(className, moduleName); } } }
private static Class unwrapClass(ModelNode classModel) throws OperationFailedException { String className = classModel.get(NAME).asString(); String moduleName = classModel.get(MODULE).asString(); try { ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName); Module module = Module.getCallerModuleLoader().loadModule(moduleID); Class<?> clazz = module.getClassLoader().loadClass(className); return clazz; } catch (Exception e) { throw ROOT_LOGGER.unableToLoadClassFromModule(className, moduleName); } } }
static ModuleClassLoader getModuleClassLoader(final String moduleSpec) throws ModuleLoadException { ModuleLoader loader = Module.getCallerModuleLoader(); final Module module = loader.loadModule(ModuleIdentifier.fromString(moduleSpec)); GetModuleClassLoaderAction action = new GetModuleClassLoaderAction(module); return WildFlySecurityManager.isChecking() ? doPrivileged(action) : action.run(); }
private ObjectFactory factoryFromModularReference(ModularReference modularReference, final Hashtable<?, ?> environment) throws Exception { final Module module = Module.getCallerModuleLoader().loadModule(modularReference.getModuleIdentifier()); final ClassLoader classLoader = module.getClassLoader(); return factoryFromReference(modularReference, classLoader, environment); }
private static Class<?> loadClass(String driverName, String moduleName, String className) throws IllegalArgumentException { try { Module module = Module.getCallerModuleLoader().loadModule(moduleName); AgroalLogger.DRIVER_LOGGER.debugf("loaded module '%s' for driver: %s", moduleName, driverName); Class<?> providerClass = module.getClassLoader().loadClass(className); AgroalLogger.DRIVER_LOGGER.driverLoaded(className, driverName); return providerClass; } catch (ModuleLoadException e) { throw AgroalLogger.DRIVER_LOGGER.loadModuleException(e, moduleName); } catch (ClassNotFoundException e) { throw AgroalLogger.DRIVER_LOGGER.loadClassException(e, className); } }
try { ModuleIdentifier moduleId = ModuleIdentifier.create(moduleName, slot); module = Module.getCallerModuleLoader().loadModule(moduleId); } catch (ModuleNotFoundException e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.raModuleNotFound(moduleName, e.getMessage()), e);
try { moduleId = ModuleIdentifier.fromString(moduleName); module = Module.getCallerModuleLoader().loadModule(moduleId); } catch (ModuleNotFoundException e) { context.getFailureDescription().set(ConnectorLogger.ROOT_LOGGER.missingDependencyInModuleDriver(moduleName, e.getMessage()));
module = Module.getCallerModuleLoader().loadModule(moduleId); } catch (ModuleNotFoundException e) { throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.missingDependencyInModuleDriver(moduleName, e.getMessage()), e);
/** * Get a module from the current module loader. Note that this must crawl the * stack to determine this, so other mechanisms are more efficient. * @see #getCallerModuleLoader() * * @param name the module name * @return the module * @throws ModuleLoadException if the module could not be loaded */ public static Module getModuleFromCallerModuleLoader(final String name) throws ModuleLoadException { return getCallerModuleLoader().loadModule(name); }
private static Class unwrapClass(ModelNode classModel) throws OperationFailedException { String className = classModel.get(NAME).asString(); String moduleName = classModel.get(MODULE).asString(); try { ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName); Module module = Module.getCallerModuleLoader().loadModule(moduleID); Class<?> clazz = module.getClassLoader().loadClass(className); return clazz; } catch (Exception e) { throw MessagingLogger.ROOT_LOGGER.unableToLoadClassFromModule(className, moduleName); } }
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()); }
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()); }
private static Class unwrapClass(ModelNode classModel) throws OperationFailedException { String className = classModel.get(NAME).asString(); String moduleName = classModel.get(MODULE).asString(); try { ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName); Module module = Module.getCallerModuleLoader().loadModule(moduleID); Class<?> clazz = module.getClassLoader().loadClass(className); return clazz; } catch (Exception e) { throw MessagingLogger.ROOT_LOGGER.unableToLoadClassFromModule(className, moduleName); } }
public ModuleClassLoader run() throws ModuleLoadException { ModuleLoader loader = Module.getCallerModuleLoader(); ModuleIdentifier identifier = ModuleIdentifier.fromString(moduleSpec); return loader.loadModule(identifier).getClassLoader(); } });
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(); } }
static ModuleClassLoader getModuleClassLoader(final String moduleSpec) throws ModuleLoadException { ModuleLoader loader = Module.getCallerModuleLoader(); final Module module = loader.loadModule(ModuleIdentifier.fromString(moduleSpec)); GetModuleClassLoaderAction action = new GetModuleClassLoaderAction(module); return WildFlySecurityManager.isChecking() ? doPrivileged(action) : action.run(); }
private ObjectFactory factoryFromModularReference(ModularReference modularReference, final Hashtable<?, ?> environment) throws Exception { final Module module = Module.getCallerModuleLoader().loadModule(modularReference.getModuleIdentifier()); final ClassLoader classLoader = module.getClassLoader(); return factoryFromReference(modularReference, classLoader, environment); }
public static HttpHandler createErrorContext(final String slot) throws ModuleLoadException { final ClassPathResourceManager cpresource = new ClassPathResourceManager(getClassLoader(Module.getCallerModuleLoader(), ERROR_MODULE, slot), ""); final io.undertow.server.handlers.resource.ResourceHandler handler = new io.undertow.server.handlers.resource.ResourceHandler(cpresource) .setAllowed(not(path("META-INF"))) .setDirectoryListingEnabled(false) .setCachable(Predicates.<HttpServerExchange>falsePredicate()); //we also need to setup the default resource redirect return new PredicateHandler(path("/"), new RedirectHandler(ExchangeAttributes.constant(ERROR_CONTEXT + DEFAULT_RESOURCE)), handler); }