org.jboss.modules.Module.getContextModuleLoader()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.jboss.modules.Module.getContextModuleLoader()方法的一些代码示例,展示了Module.getContextModuleLoader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Module.getContextModuleLoader()方法的具体详情如下:
包路径:org.jboss.modules.Module
类名称:Module
方法名:getContextModuleLoader

Module.getContextModuleLoader介绍

[英]Get the current thread's context module loader. This loader is the one which defined the module whose class loader is, or is a parent of, the thread's current context class loader. If there is none, then null is returned.
[中]获取当前线程的上下文模块加载器。这个加载器定义了模块,该模块的类加载器是线程当前上下文类加载器,或者是线程当前上下文类加载器的父级。如果没有,则返回null。

代码示例

代码示例来源:origin: wildfly/wildfly

static Class<? extends Protocol> findProtocolClass(OperationContext context, String protocolName, String moduleName) throws OperationFailedException {
    String className = protocolName;
    if (moduleName.equals(AbstractProtocolResourceDefinition.Attribute.MODULE.getDefinition().getDefaultValue().asString()) && !protocolName.startsWith(org.jgroups.conf.ProtocolConfiguration.protocol_prefix)) {
      className = String.join(".", org.jgroups.conf.ProtocolConfiguration.protocol_prefix, protocolName);
    }

    try {
      return Module.getContextModuleLoader().loadModule(moduleName).getClassLoader().loadClass(className).asSubclass(Protocol.class);
    } catch (ClassNotFoundException | ModuleLoadException e) {
      throw JGroupsLogger.ROOT_LOGGER.unableToLoadProtocolClass(className);
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-clustering-jgroups-extension

static Class<? extends Protocol> findProtocolClass(OperationContext context, String protocolName, String moduleName) throws OperationFailedException {
    String className = protocolName;
    if (moduleName.equals(AbstractProtocolResourceDefinition.Attribute.MODULE.getDefinition().getDefaultValue().asString()) && !protocolName.startsWith(org.jgroups.conf.ProtocolConfiguration.protocol_prefix)) {
      className = String.join(".", org.jgroups.conf.ProtocolConfiguration.protocol_prefix, protocolName);
    }

    try {
      return Module.getContextModuleLoader().loadModule(moduleName).getClassLoader().loadClass(className).asSubclass(Protocol.class);
    } catch (ClassNotFoundException | ModuleLoadException e) {
      throw JGroupsLogger.ROOT_LOGGER.unableToLoadProtocolClass(className);
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-wildfly-extensions

@Override
public ProviderLoader create(KeycloakDeploymentInfo info, ClassLoader baseClassLoader, String resource) {
  try {
    Module module = Module.getContextModuleLoader().loadModule(ModuleIdentifier.fromString(resource));
    ModuleClassLoader classLoader = module.getClassLoader();
    return new DefaultProviderLoader(info, classLoader);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: wildfly/wildfly-core

private static ProcessStateListener newInstance(String className, String moduleIdentifier) throws OperationFailedException {
    final Module module;
    try {
      module = Module.getContextModuleLoader().loadModule(moduleIdentifier);
      Class<?> clazz = module.getClassLoader().loadClass(className);
      Object instance = clazz.getConstructor(null).newInstance(null);
      return ProcessStateListener.class.cast(instance);
    } catch (ModuleLoadException e) {
      throw CoreManagementLogger.ROOT_LOGGER.errorToLoadModule(moduleIdentifier);
    } catch (ClassNotFoundException e) {
      throw CoreManagementLogger.ROOT_LOGGER.errorToLoadModuleClass(className, moduleIdentifier);
    } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | IllegalArgumentException | InvocationTargetException e) {
      throw CoreManagementLogger.ROOT_LOGGER.errorToInstantiateClassInstanceFromModule(className, moduleIdentifier);
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-wildfly-extensions

@Override
public void init(Config.Scope config) {
  String[] modules = config.getArray("modules");
  if (modules != null) {
    try {
      for (String moduleSpec : modules) {
        Module module = Module.getContextModuleLoader().loadModule(ModuleIdentifier.fromString(moduleSpec));
        ModuleClassLoader classLoader = module.getClassLoader();
        loadThemes(classLoader, classLoader.getResourceAsStream(KEYCLOAK_THEMES_JSON));
      }
    } catch (Exception e) {
      throw new RuntimeException("Failed to load themes", e);
    }
  }
}

代码示例来源:origin: org.picketlink/picketlink-as-extension

ModuleLoader moduleLoader = Module.getContextModuleLoader();
try {
  alternativeModule = moduleLoader.loadModule(ModuleIdentifier.create(alternativeModuleNode.asString()));

代码示例来源:origin: org.picketlink/picketlink-as-extension

ModuleLoader moduleLoader = Module.getContextModuleLoader();

代码示例来源:origin: org.jboss.eap/wildfly-messaging-activemq

public void startBridge() throws Exception {
  final Module module;
  if (moduleName != null) {
    ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName);
    module =  Module.getContextModuleLoader().loadModule(moduleID);
  } else {
    module = Module.forClass(JMSBridgeService.class);
  }
  ClassLoader oldTccl= WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
    setJMSBridgePasswordsFromCredentialSource();
    bridge.start();
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
  }
  MessagingLogger.ROOT_LOGGER.startedService("JMS Bridge", bridgeName);
}

代码示例来源:origin: org.wildfly/wildfly-messaging-activemq

public void startBridge() throws Exception {
  final Module module;
  if (moduleName != null) {
    ModuleIdentifier moduleID = ModuleIdentifier.fromString(moduleName);
    module =  Module.getContextModuleLoader().loadModule(moduleID);
  } else {
    module = Module.forClass(JMSBridgeService.class);
  }
  ClassLoader oldTccl= WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
  try {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader());
    setJMSBridgePasswordsFromCredentialSource();
    bridge.start();
  } finally {
    WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl);
  }
  MessagingLogger.ROOT_LOGGER.startedService("JMS Bridge", bridgeName);
}

相关文章