public class SpringObjenesis extends Object implements org.springframework.objenesis.Objenesis
ObjenesisStd / ObjenesisBase,
providing a cache based on Class keys instead of class names,
and allowing for selective use of the cache.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 new
SpringObjenesis instance with the
standard instantiator strategy. |
SpringObjenesis(org.springframework.objenesis.strategy.InstantiatorStrategy strategy)
Create a new
SpringObjenesis 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) |
public static final String IGNORE_OBJENESIS_PROPERTY_NAME
public SpringObjenesis()
SpringObjenesis instance with the
standard instantiator strategy.public SpringObjenesis(org.springframework.objenesis.strategy.InstantiatorStrategy strategy)
SpringObjenesis instance with the
given standard instantiator strategy.strategy - the instantiator strategy to usepublic boolean isWorthTrying()
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.
public <T> T newInstance(Class<T> clazz, boolean useCache)
clazz - the class to create an instance ofuseCache - whether to use the instantiator cache
(typically true but can be set to false
e.g. for reloadable classes)null)ObjenesisException - if instance creation failedpublic <T> T newInstance(Class<T> clazz)
newInstance 在接口中 org.springframework.objenesis.Objenesispublic <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz)
getInstantiatorOf 在接口中 org.springframework.objenesis.Objenesisprotected <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T> newInstantiatorOf(Class<T> clazz)