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

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

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

Module.getModuleFromCallerModuleLoader介绍

[英]Get a module from the current module loader. Note that this must crawl the stack to determine this, so other mechanisms are more efficient.
[中]从当前模块加载程序获取模块。请注意,这必须对堆栈进行爬网以确定这一点,因此其他机制更有效。

代码示例

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

static ClassLoader loadModule(String moduleName) throws ConfigXMLParseException {
    try {
      return Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName)).getClassLoader();
    } catch (ModuleLoadException e) {
      throw new ConfigXMLParseException(e);
    }
  }
}

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

public List<TldMetaData> getSharedTlds(DeploymentUnit deploymentUnit) {
  final List<TldMetaData> metadata = new ArrayList<TldMetaData>();
  try {
    ModuleClassLoader jstl = Module.getModuleFromCallerModuleLoader(ModuleIdentifier.create("javax.servlet.jstl.api")).getClassLoader();
    for (String tld : JSTL_TAGLIBS) {
      InputStream is = jstl.getResourceAsStream("META-INF/" + tld);
      if (is != null) {
        TldMetaData tldMetaData = parseTLD(is);
        metadata.add(tldMetaData);
      }
    }
  } catch (ModuleLoadException e) {
    // Ignore
  } catch (Exception e) {
    // Ignore
  }
  List<TldMetaData> additionalSharedTlds = deploymentUnit.getAttachment(ATTACHMENT_KEY);
  if (additionalSharedTlds != null) {
    metadata.addAll(additionalSharedTlds);
  }
  return metadata;
}

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

private Map<String, List<TldMetaData>> getMap() {
  final Map<String, List<TldMetaData>> jsfTldMap = new HashMap<>();
  JSFModuleIdFactory moduleFactory = JSFModuleIdFactory.getInstance();
  List<String> jsfSlotNames = moduleFactory.getActiveJSFVersions();
  for (String slot : jsfSlotNames) {
    final List<TldMetaData> jsfTlds = new ArrayList<TldMetaData>();
    try {
      ModuleClassLoader jsf = Module.getModuleFromCallerModuleLoader(moduleFactory.getImplModId(slot)).getClassLoader();
      for (String tld : JSF_TAGLIBS) {
        InputStream is = jsf.getResourceAsStream("META-INF/" + tld);
        if (is != null) {
          TldMetaData tldMetaData = parseTLD(is);
          jsfTlds.add(tldMetaData);
        }
      }
    } catch (ModuleLoadException e) {
      // Ignore
    } catch (Exception e) {
      // Ignore
    }
    jsfTldMap.put(slot, jsfTlds);
  }
  return jsfTldMap;
}

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

/**
   * Returns the class loader of the given module or throws a {@code ConfigXMLParseException} if the module can not be loaded.
   *
   * @param moduleName the name of the module (can not be {@code null}
   * @return the class loader of the module
   * @throws ConfigXMLParseException if the module can not be loaded
   *
   */
  static ClassLoader getClassLoaderFromModule(@Param XMLStreamReader reader, String moduleName) throws ConfigXMLParseException {
    final ModuleIdentifier identifier = ModuleIdentifier.fromString(moduleName);
    try {
      return Module.getModuleFromCallerModuleLoader(identifier).getClassLoader();
    } catch (ModuleLoadException e) {
      throw xmlLog.xmlNoModuleFound(reader, e, identifier.toString());
    }
  }
}

代码示例来源:origin: org.keycloak/keycloak-wf9-server-subsystem

private Module findSubsysModule() {
  try {
    return Module.getModuleFromCallerModuleLoader(KEYCLOAK_SUBSYSTEM);
  } catch (ModuleLoadException e) {
    throw new IllegalStateException("Can't find Keycloak subsystem.", e);
  }
}

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

private Module findSubsysModule() {
  try {
    return Module.getModuleFromCallerModuleLoader(KEYCLOAK_SUBSYSTEM);
  } catch (ModuleLoadException e) {
    throw new IllegalStateException("Can't find Keycloak subsystem.", e);
  }
}

代码示例来源:origin: org.keycloak/keycloak-eap6-server-subsystem

private Module findSubsysModule() {
  try {
    return Module.getModuleFromCallerModuleLoader(KEYCLOAK_SUBSYSTEM);
  } catch (ModuleLoadException e) {
    throw new IllegalStateException("Can't find Keycloak subsystem.", e);
  }
}

代码示例来源:origin: org.keycloak/keycloak-as7-server-subsystem

private Module findSubsysModule() {
  try {
    return Module.getModuleFromCallerModuleLoader(KEYCLOAK_SUBSYSTEM);
  } catch (ModuleLoadException e) {
    throw new IllegalStateException("Can't find Keycloak subsystem.", e);
  }
}

代码示例来源:origin: org.jboss.modules/jboss-modules

/**
 * 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 identifier the module identifier
 * @return the module
 * @throws ModuleLoadException if the module could not be loaded
 * @deprecated Use {@link #getModuleFromCallerModuleLoader(String)} instead.
 */
@Deprecated
public static Module getModuleFromCallerModuleLoader(final ModuleIdentifier identifier) throws ModuleLoadException {
  return getModuleFromCallerModuleLoader(identifier.toString());
}

代码示例来源:origin: org.jboss.forge/jboss-modules

/**
 * Load a class from a module in the caller's module loader.
 *
 * @see #getCallerModuleLoader()
 *
 * @param moduleIdentifier the identifier of the module from which the class
 *        should be loaded
 * @param className the class name to load
 * @return the class
 * @throws ModuleLoadException if the module could not be loaded
 * @throws ClassNotFoundException if the class could not be loaded
 */
public static Class<?> loadClassFromCallerModuleLoader(final ModuleIdentifier moduleIdentifier, final String className)
    throws ModuleLoadException, ClassNotFoundException {
  return Class.forName(className, true, getModuleFromCallerModuleLoader(moduleIdentifier).getClassLoader());
}

代码示例来源:origin: org.jboss.modules/jboss-modules

/**
 * Load a class from a module in the caller's module loader.
 *
 * @see #getCallerModuleLoader()
 *
 * @param name the name of the module from which the class
 *        should be loaded
 * @param className the class name to load
 * @return the class
 * @throws ModuleLoadException if the module could not be loaded
 * @throws ClassNotFoundException if the class could not be loaded
 */
public static Class<?> loadClassFromCallerModuleLoader(final String name, final String className)
    throws ModuleLoadException, ClassNotFoundException {
  return Class.forName(className, true, getModuleFromCallerModuleLoader(name).getClassLoader());
}

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

Module module = Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName));
ModuleClassLoader mcl = module.getClassLoader();
Field pathsField = ModuleClassLoader.class.getDeclaredField("paths");

代码示例来源:origin: org.jboss.eap/wildfly-client-all

static ClassLoader loadModule(String moduleName) throws ConfigXMLParseException {
    try {
      return Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName)).getClassLoader();
    } catch (ModuleLoadException e) {
      throw new ConfigXMLParseException(e);
    }
  }
}

代码示例来源:origin: wildfly/jboss-ejb-client

static ClassLoader loadModule(String moduleName) throws ConfigXMLParseException {
    try {
      return Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString(moduleName)).getClassLoader();
    } catch (ModuleLoadException e) {
      throw new ConfigXMLParseException(e);
    }
  }
}

代码示例来源:origin: org.jboss.as/jboss-as-remoting

static Xnio getXnio() throws ModuleLoadException {
    return Xnio.getInstance(null, Module.getModuleFromCallerModuleLoader(ModuleIdentifier.fromString("org.jboss.xnio.nio")).getClassLoader());
  }
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron

/**
   * Returns the class loader of the given module or throws a {@code ConfigXMLParseException} if the module can not be loaded.
   *
   * @param moduleName the name of the module (can not be {@code null}
   * @return the class loader of the module
   * @throws ConfigXMLParseException if the module can not be loaded
   *
   */
  static ClassLoader getClassLoaderFromModule(@Param XMLStreamReader reader, String moduleName) throws ConfigXMLParseException {
    final ModuleIdentifier identifier = ModuleIdentifier.fromString(moduleName);
    try {
      return Module.getModuleFromCallerModuleLoader(identifier).getClassLoader();
    } catch (ModuleLoadException e) {
      throw xmlLog.xmlNoModuleFound(reader, e, identifier.toString());
    }
  }
}

代码示例来源:origin: org.wildfly.security/wildfly-elytron-client

/**
   * Returns the class loader of the given module or throws a {@code ConfigXMLParseException} if the module can not be loaded.
   *
   * @param moduleName the name of the module (can not be {@code null}
   * @return the class loader of the module
   * @throws ConfigXMLParseException if the module can not be loaded
   *
   */
  static ClassLoader getClassLoaderFromModule(@Param XMLStreamReader reader, String moduleName) throws ConfigXMLParseException {
    final ModuleIdentifier identifier = ModuleIdentifier.fromString(moduleName);
    try {
      return Module.getModuleFromCallerModuleLoader(identifier).getClassLoader();
    } catch (ModuleLoadException e) {
      throw xmlLog.xmlNoModuleFound(reader, e, identifier.toString());
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
   * Returns the class loader of the given module or throws a {@code ConfigXMLParseException} if the module can not be loaded.
   *
   * @param moduleName the name of the module (can not be {@code null}
   * @return the class loader of the module
   * @throws ConfigXMLParseException if the module can not be loaded
   *
   */
  static ClassLoader getClassLoaderFromModule(@Param XMLStreamReader reader, String moduleName) throws ConfigXMLParseException {
    final ModuleIdentifier identifier = ModuleIdentifier.fromString(moduleName);
    try {
      return Module.getModuleFromCallerModuleLoader(identifier).getClassLoader();
    } catch (ModuleLoadException e) {
      throw xmlLog.xmlNoModuleFound(reader, e, identifier.toString());
    }
  }
}

相关文章

微信公众号

最新文章

更多