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

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

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

Module.forClass介绍

[英]Get the module for a loaded class, or null if the class did not come from any module.
[中]为加载的类获取模块,如果该类不是来自任何模块,则为null。

代码示例

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

/**
 * Create a ModuleReference from a target class name and factory class.
 *
 * @param className The class name for the reference
 * @param factoryClass The factory class
 * @return A ModularReference
 */
public static ModularReference create(final String className, final Class<?> factoryClass) {
  return new ModularReference(className, factoryClass.getName(), Module.forClass(factoryClass).getIdentifier());
}

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

/**
 * Create a ModuleReference from a target class name, reference address and factory class.
 *
 * @param className The class name for the reference
 * @param addr The address of the object
 * @param factoryClass The factory class
 * @return A ModularReference
 */
public static ModularReference create(final String className, final RefAddr addr, final Class<?> factoryClass) {
  return new ModularReference(className, addr, factoryClass.getName(), Module.forClass(factoryClass).getIdentifier());
}

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

/** {@inheritDoc} */
public synchronized BeanDeploymentArchive loadBeanDeploymentArchive(final Class<?> beanClass) {
  final BeanDeploymentArchive bda = this.getBeanDeploymentArchive(beanClass);
  if (bda != null) {
    return bda;
  }
  Module module = Module.forClass(beanClass);
  if (module == null) {
    // Bean class loaded by the bootstrap class loader
    if (bootstrapClassLoaderBeanDeploymentArchive == null) {
      bootstrapClassLoaderBeanDeploymentArchive = createAndRegisterAdditionalBeanDeploymentArchive(module, beanClass);
    } else {
      bootstrapClassLoaderBeanDeploymentArchive.addBeanClass(beanClass);
    }
    return bootstrapClassLoaderBeanDeploymentArchive;
  }
  /*
   * No, there is no BDA for the class yet. Let's create one.
   */
  return createAndRegisterAdditionalBeanDeploymentArchive(module, beanClass);
}

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

/** {@inheritDoc} */
public void annotateProxyClass(final Marshaller marshaller, final Class<?> proxyClass) throws IOException {
  final Module module = Module.forClass(proxyClass);
  if (module == null) {
    marshaller.writeObject(null);
  } else {
    final ModuleIdentifier identifier = module.getIdentifier();
    marshaller.writeObject(identifier.getName());
    marshaller.writeObject(identifier.getSlot());
  }
}

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

public void writeClass(final Marshaller marshaller, final Class<?> clazz) throws IOException {
    marshaller.write(0);
    final Module module = Module.forClass(clazz);
    if (module == null) {
      marshaller.writeObject(null);
    } else {
      final ModuleIdentifier identifier = module.getIdentifier();
      marshaller.writeObject(identifier.getName());
      marshaller.writeObject(identifier.getSlot());
    }
    marshaller.writeObject(clazz.getName());
  }
}

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

public void writeClass(final Marshaller marshaller, final Class<?> clazz) throws IOException {
    marshaller.write(1);
    final Module module = Module.forClass(clazz);
    if (module == null) {
      marshaller.writeObject(null);
    } else {
      final ModuleIdentifier identifier = module.getIdentifier();
      marshaller.writeObject(identifier.getName());
      marshaller.writeObject(identifier.getSlot());
    }
    final Class<?>[] interfaces = clazz.getInterfaces();
    marshaller.writeInt(interfaces.length);
    for (Class<?> interfaze : interfaces) {
      marshaller.writeObject(interfaze.getName());
    }
  }
}

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

/** {@inheritDoc} */
public void annotateClass(final Marshaller marshaller, final Class<?> clazz) throws IOException {
  final Module module = Module.forClass(clazz);
  if (module == null) {
    marshaller.writeObject(null);
  } else {
    final ModuleIdentifier identifier = module.getIdentifier();
    marshaller.writeObject(identifier.getName());
    marshaller.writeObject(identifier.getSlot());
  }
}

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

Class<?> clazz = Reflections.loadClass(iterator.next(), module.getClassLoader());
if (clazz != null) {
  Module classModule = Module.forClass(clazz);
  return classModule != null && classModule.equals(that.getModule());

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

/**
 * Get the caller's module. The caller's module is the module containing the method that calls this
 * method. Note that this method crawls the stack so other ways of obtaining the
 * module are more efficient.
 *
 * @return the current module
 */
public static Module getCallerModule() {
  return forClass(CallerContext.getCallingClass());
}

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

/**
 * Get the caller's module. The caller's module is the module containing the method that calls this
 * method. Note that this method crawls the stack so other ways of obtaining the
 * module are more efficient.
 *
 * @return the current module
 */
public static Module getCallerModule() {
  return forClass(JDKSpecific.getCallingUserClass());
}

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

/**
 * Create a ModuleReference from a target class name, reference address and factory class.
 *
 * @param className The class name for the reference
 * @param addr The address of the object
 * @param factoryClass The factory class
 * @return A ModularReference
 */
public static ModularReference create(final String className, final RefAddr addr, final Class<?> factoryClass) {
  return new ModularReference(className, addr, factoryClass.getName(), Module.forClass(factoryClass).getIdentifier());
}

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

/**
 * Create a ModuleReference from a target class name, reference address and factory class.
 *
 * @param className The class name for the reference
 * @param addr The address of the object
 * @param factoryClass The factory class
 * @return A ModularReference
 */
public static ModularReference create(final String className, final RefAddr addr, final Class<?> factoryClass) {
  return new ModularReference(className, addr, factoryClass.getName(), Module.forClass(factoryClass).getIdentifier());
}

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

/**
 * Create a ModuleReference from a target class name and factory class.
 *
 * @param className The class name for the reference
 * @param factoryClass The factory class
 * @return A ModularReference
 */
public static ModularReference create(final String className, final Class<?> factoryClass) {
  return new ModularReference(className, factoryClass.getName(), Module.forClass(factoryClass).getIdentifier());
}

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

/**
 * Create a ModuleReference from a target class name, reference address and factory class.
 *
 * @param className The class name for the reference
 * @param addr The address of the object
 * @param factoryClass The factory class
 * @return A ModularReference
 */
public static ModularReference create(final String className, final RefAddr addr, final Class<?> factoryClass) {
  return new ModularReference(className, addr, factoryClass.getName(), Module.forClass(factoryClass).getIdentifier());
}

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

@Override
public SSOManager<A, D, S, L, Batch> get() {
  SSOManagerFactory<A, D, S, Batch> factory = this.factory.get();
  Module module = Module.forClass(this.getClass());
  this.context = new SimpleMarshallingContextFactory().createMarshallingContext(new SimpleMarshallingConfigurationRepository(MarshallingVersion.class, MarshallingVersion.CURRENT, module), null);
  SSOManager<A, D, S, L, Batch> manager = factory.createSSOManager(this);
  manager.start();
  return manager;
}

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

public void writeClass(final Marshaller marshaller, final Class<?> clazz) throws IOException {
    marshaller.write(0);
    final Module module = Module.forClass(clazz);
    if (module == null) {
      marshaller.writeObject(null);
    } else {
      final ModuleIdentifier identifier = module.getIdentifier();
      marshaller.writeObject(identifier.getName());
      marshaller.writeObject(identifier.getSlot());
    }
    marshaller.writeObject(clazz.getName());
  }
}

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

/** {@inheritDoc} */
public void annotateProxyClass(final Marshaller marshaller, final Class<?> proxyClass) throws IOException {
  final Module module = Module.forClass(proxyClass);
  if (module == null) {
    marshaller.writeObject(null);
  } else {
    final ModuleIdentifier identifier = module.getIdentifier();
    marshaller.writeObject(identifier.getName());
    marshaller.writeObject(identifier.getSlot());
  }
}

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

/** {@inheritDoc} */
public void annotateClass(final Marshaller marshaller, final Class<?> clazz) throws IOException {
  final Module module = Module.forClass(clazz);
  if (module == null) {
    marshaller.writeObject(null);
  } else {
    final ModuleIdentifier identifier = module.getIdentifier();
    marshaller.writeObject(identifier.getName());
    marshaller.writeObject(identifier.getSlot());
  }
}

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

/** {@inheritDoc} */
public void annotateProxyClass(final Marshaller marshaller, final Class<?> proxyClass) throws IOException {
  final Module module = Module.forClass(proxyClass);
  if (module == null) {
    marshaller.writeObject(null);
  } else {
    final ModuleIdentifier identifier = module.getIdentifier();
    marshaller.writeObject(identifier.getName());
    marshaller.writeObject(identifier.getSlot());
  }
}

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

private static void calculateModule(final ExtLogRecord logRecord, final Class<?> clazz) {
    final Module module = Module.forClass(clazz);
    if (module != null) {
      logRecord.setSourceModuleName(module.getName());
      final Version version = module.getVersion();
      if (version != null) {
        logRecord.setSourceModuleVersion(version.toString());
      } else {
        logRecord.setSourceModuleVersion(null);
      }
    }
  }
}

相关文章