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

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

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

Util.getInstanceStrict介绍

[英]Similar to #getInstance(Class) except that exceptions are propagated to the caller.
[中]与#getInstance(类)类似,只是异常会传播到调用方。

代码示例

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

/**
* Similar to {@link #getInstance(String, ClassLoader)} except that exceptions are propagated to the caller.
*
* @param classname class to instantiate
* @return an instance of classname
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
*/
public static <T> T getInstanceStrict(String classname, ClassLoader cl) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
 if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
 Class<T> clazz = loadClassStrict(classname, cl);
 return getInstanceStrict(clazz);
}

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

/**
* Instantiates a class by first attempting a static <i>factory method</i> named <tt>getInstance()</tt> on the class
* and then falling back to an empty constructor.
* <p/>
* Any exceptions encountered are wrapped in a {@link CacheConfigurationException} and rethrown.
*
* @param clazz class to instantiate
* @return an instance of the class
*/
public static <T> T getInstance(Class<T> clazz) {
 try {
   return getInstanceStrict(clazz);
 } catch (IllegalAccessException | InstantiationException iae) {
   throw new CacheConfigurationException("Unable to instantiate class " + clazz.getName(), iae);
 }
}

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

public static void amendMarshaller(GlobalConfigurationBuilder builder) {
 if (MARSHALLER != null) {
   try {
    Marshaller marshaller = Util.getInstanceStrict(MARSHALLER, Thread.currentThread().getContextClassLoader());
    builder.serialization().marshaller(marshaller);
   } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
    // No-op, stick to GlobalConfiguration default.
   }
 }
}

相关文章