org.infinispan.commons.util.Util.loadClass()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(123)

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

Util.loadClass介绍

[英]Loads the specified class using the passed classloader, or, if it is null the Infinispan classes' classloader.

If loadtime instrumentation via GenerateInstrumentedClassLoader is used, this class may be loaded by the bootstrap classloader.

If the class is not found, the ClassNotFoundException or NoClassDefFoundError is wrapped as a CacheConfigurationException and is re-thrown.
[中]使用传递的类加载器加载指定的类,如果是null,则使用Infinispan类的类加载器加载。
如果使用通过GenerateInstrumentedClassLoader的loadtime指令,则引导类加载器可能会加载此类。
如果找不到该类,ClassNotFoundException或NoClassDefFoundError将包装为CacheConfigurationException并重新抛出。

代码示例

代码示例来源:origin: org.infinispan/infinispan-tools

private Class<List> getPrivateArrayListClass() {
   return Util.<List>loadClass("java.util.Arrays$ArrayList", List.class.getClassLoader());
  }
}

代码示例来源:origin: org.infinispan/infinispan-tools

switch (attribute) {
 case AFTER:
   interceptorBuilder.after(Util.<CommandInterceptor>loadClass(value, holder.getClassLoader()));
   break;
 case BEFORE:
   interceptorBuilder.before(Util.<CommandInterceptor>loadClass(value, holder.getClassLoader()));
   break;
 case CLASS:

代码示例来源:origin: org.infinispan/infinispan-tools

@Override
  public Set<Class<? extends List<?>>> getTypeClasses() {
   // This is loadable from any classloader
   return Util.<Class<? extends List<?>>>asSet(Util.<List<?>>loadClass("java.util.Collections$SingletonList", null));
  }
}

代码示例来源:origin: org.infinispan/infinispan-commons

@Override
public MBeanServer getMBeanServer(Properties properties) {
 Class<?> mbsLocator = Util.loadClass("org.jboss.mx.util.MBeanServerLocator", null);
 try {
   return (MBeanServer) mbsLocator.getMethod("locateJBoss").invoke(null);
 } catch (Exception e) {
   throw new CacheException("Unable to locate JBoss MBean server", e);
 }
}

代码示例来源:origin: org.infinispan/infinispan-commons

/**
* Instantiates a class based on the class name provided.  Instantiation is attempted via an appropriate, static
* factory method named <tt>getInstance()</tt> first, and failing the existence of an appropriate factory, falls
* back to an empty constructor.
* <p />
* Any exceptions encountered loading and instantiating the class is wrapped in a {@link CacheConfigurationException}.
*
* @param classname class to instantiate
* @return an instance of classname
*/
public static <T> T getInstance(String classname, ClassLoader cl) {
 if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
 Class<T> clazz = loadClass(classname, cl);
 return getInstance(clazz);
}

代码示例来源:origin: org.infinispan/infinispan-tools

private TwoWayKey2StringMapper getTwoWayMapper() {
   String mapperClass = config.key2StringMapper();
   if (mapperClass != null) {
     ClassLoader classLoader = JdbcConfigurationUtil.class.getClassLoader();
     try {
      return (TwoWayKey2StringMapper) Util.loadClass(mapperClass, classLoader).newInstance();
     } catch (IllegalAccessException | InstantiationException e) {
      throw new CacheConfigurationException(String.format("Unabled to load TwoWayKey2StringMapper '%s' for %s store",
         mapperClass, SOURCE), e);
     }
   }
   return new DefaultTwoWayKey2StringMapper();
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

@Override
 public Set<Class<? extends Object>> getTypeClasses() {
   return Util.<Class<? extends Object>>asSet(
      Util.loadClass("org.infinispan.marshall.AdvancedExternalizerTest$IdViaConfigObj", Thread.currentThread().getContextClassLoader()),
      Util.loadClass("org.infinispan.marshall.AdvancedExternalizerTest$IdViaAnnotationObj", Thread.currentThread().getContextClassLoader()),
      Util.loadClass("org.infinispan.marshall.AdvancedExternalizerTest$IdViaBothObj", Thread.currentThread().getContextClassLoader()));
 }
}

代码示例来源:origin: org.infinispan/infinispan-tools

public static StreamingMarshaller getMarshaller(StoreProperties props) {
 switch (getMarshallerType(props)) {
   case CURRENT:
    if (props.isTargetStore())
      return null;
    GlobalConfigurationBuilder globalConfig = new GlobalConfigurationBuilder()
       .defaultCacheName(props.cacheName());
    configureExternalizers(props, globalConfig.serialization());
    EmbeddedCacheManager manager = new DefaultCacheManager(globalConfig.build(), new ConfigurationBuilder().build());
    return manager.getCache().getAdvancedCache().getComponentRegistry().getComponent(StreamingMarshaller.class);
   case CUSTOM:
    String marshallerClass = props.get(MARSHALLER, CLASS);
    if (marshallerClass == null)
      throw new CacheConfigurationException(
         String.format("The property %s.%s must be set if a custom marshaller type is specified", MARSHALLER, CLASS));
    try {
      return (StreamingMarshaller) Util.loadClass(marshallerClass, SerializationConfigUtil.class.getClassLoader()).newInstance();
    } catch (IllegalAccessException | InstantiationException e) {
      throw new CacheConfigurationException(String.format("Unable to load StreamingMarshaller '%s' for %s store",
         marshallerClass, SOURCE), e);
    }
   case LEGACY:
    if (props.isTargetStore())
      throw new CacheConfigurationException("The legacy marshaller can only be specified for source stores.");
    return new LegacyVersionAwareMarshaller(getExternalizersFromProps(props));
   default:
    throw new IllegalStateException("Unexpected marshaller type");
 }
}

代码示例来源:origin: org.infinispan/infinispan-cachestore-jpa

Class<?> clazz = Util.loadClass(value, classLoader);
builder.entityClass(clazz);
break;

代码示例来源:origin: org.infinispan/infinispan-tools

Class<?> clazz = Util.loadClass(value, classLoader);
builder.entityClass(clazz);
break;

相关文章