类 SpringObjenesis
- java.lang.Object
- org.springframework.objenesis.SpringObjenesis
- 所有已实现的接口:
org.springframework.objenesis.Objenesis
public class SpringObjenesis extends Object implements org.springframework.objenesis.Objenesis
Spring-specific variant ofObjenesisStd
/ObjenesisBase
, providing a cache based onClass
keys instead of class names, and allowing for selective use of the cache.- 从以下版本开始:
- 4.2
- 作者:
- Juergen Hoeller
- 另请参阅:
isWorthTrying()
,newInstance(Class, boolean)
字段概要
字段 修饰符和类型 字段 说明 static String
IGNORE_OBJENESIS_PROPERTY_NAME
System property that instructs Spring to ignore Objenesis, not even attempting to use it.
构造器概要
构造器 构造器 说明 SpringObjenesis()
Create a newSpringObjenesis
instance with the standard instantiator strategy.SpringObjenesis(org.springframework.objenesis.strategy.InstantiatorStrategy strategy)
Create a newSpringObjenesis
instance with the given standard instantiator strategy.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T>
getInstantiatorOf(Class<T> clazz)
boolean
isWorthTrying()
Return whether this Objenesis instance is worth trying for instance creation, i.e. whether it hasn't been used yet or is known to work.<T> T
newInstance(Class<T> clazz)
<T> T
newInstance(Class<T> clazz, boolean useCache)
Create a new instance of the given class via Objenesis.protected <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T>
newInstantiatorOf(Class<T> clazz)
字段详细资料
IGNORE_OBJENESIS_PROPERTY_NAME
public static final String IGNORE_OBJENESIS_PROPERTY_NAME
System property that instructs Spring to ignore Objenesis, not even attempting to use it. Setting this flag to "true" is equivalent to letting Spring find out that Objenesis isn't working at runtime, triggering the fallback code path immediately: Most importantly, this means that all CGLIB AOP proxies will be created through regular instantiation via a default constructor.- 另请参阅:
- 常量字段值
构造器详细资料
SpringObjenesis
public SpringObjenesis()
Create a newSpringObjenesis
instance with the standard instantiator strategy.
SpringObjenesis
public SpringObjenesis(org.springframework.objenesis.strategy.InstantiatorStrategy strategy)
Create a newSpringObjenesis
instance with the given standard instantiator strategy.- 参数:
strategy
- the instantiator strategy to use
方法详细资料
isWorthTrying
public boolean isWorthTrying()
Return whether this Objenesis instance is worth trying for instance creation, i.e. whether it hasn't been used yet or is known to work.If the configured Objenesis instantiator strategy has been identified to not work on the current JVM at all or if the "spring.objenesis.ignore" property has been set to "true", this method returns
false
.
newInstance
public <T> T newInstance(Class<T> clazz, boolean useCache)
Create a new instance of the given class via Objenesis.- 参数:
clazz
- the class to create an instance ofuseCache
- whether to use the instantiator cache (typicallytrue
but can be set tofalse
e.g. for reloadable classes)- 返回:
- the new instance (never
null
) - 抛出:
org.springframework.objenesis.ObjenesisException
- if instance creation failed
newInstance
public <T> T newInstance(Class<T> clazz)
- 指定者:
newInstance
在接口中org.springframework.objenesis.Objenesis
getInstantiatorOf
public <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz)
- 指定者:
getInstantiatorOf
在接口中org.springframework.objenesis.Objenesis
newInstantiatorOf
protected <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T> newInstantiatorOf(Class<T> clazz)