类 AnnotatedInjectionBeanPostProcessor
- java.lang.Object
-
- org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
-
- io.microsphere.spring.beans.factory.annotation.AnnotatedInjectionBeanPostProcessor
-
- 所有已实现的接口:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.config.BeanPostProcessor
,org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
,org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor
,org.springframework.context.EnvironmentAware
,org.springframework.core.Ordered
,org.springframework.core.PriorityOrdered
public class AnnotatedInjectionBeanPostProcessor extends org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter implements org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor, org.springframework.core.PriorityOrdered, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.context.EnvironmentAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
The genericBeanPostProcessor
implementation to support the dependency injection for the customized annotations.As a substitution, besides the core features of
AutowiredAnnotationBeanPostProcessor
,AnnotatedInjectionBeanPostProcessor
also supports:The dependency injection with multiple types of annotations
-
Annotation Features Enhancement:
setClassValuesAsString(boolean)
: whether to turn Class references into Strings (for compatibility with or to preserve them as Class referencessetNestedAnnotationsAsMap(boolean)
: whether to turn nested Annotation instances into AnnotationAttributes maps (for compatibility withAnnotationMetadata
or to preserve them as Annotation instancessetIgnoreDefaultValue(boolean)
: whether ignore default value or not: whether try merged annotation or not
- {@link #setCacheSize(int) The size of the metadata cache}
- 从以下版本开始:
- 1.0.0
- 作者:
- Mercy
- 另请参阅:
AutowiredAnnotationBeanPostProcessor
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static class
AnnotatedInjectionBeanPostProcessor.AnnotationInjectedElement<M extends java.lang.reflect.Member>
AnnotationInjectionMetadata.InjectedElement
-
构造器概要
构造器 构造器 说明 AnnotatedInjectionBeanPostProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.Class<? extends java.lang.annotation.Annotation>... otherAnnotationTypes)
AnnotatedInjectionBeanPostProcessor(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> annotationTypes)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
void
destroy()
java.lang.reflect.Constructor<?>[]
determineCandidateConstructors(java.lang.Class<?> beanClass, java.lang.String beanName)
protected boolean
determineRequiredStatus(org.springframework.core.annotation.AnnotationAttributes attributes)
Determine if the annotated field or method requires its dependency.protected org.springframework.core.annotation.AnnotationAttributes
doGetAnnotationAttributes(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
GetAnnotationAttributes
protected org.springframework.core.annotation.AnnotationAttributes
findInjectionAnnotationAttributes(java.lang.reflect.AnnotatedElement annotatedElement)
java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>>
getAnnotationTypes()
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
getBeanFactory()
java.lang.ClassLoader
getClassLoader()
org.springframework.core.env.Environment
getEnvironment()
int
getOrder()
void
postProcessMergedBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition, java.lang.Class<?> beanType, java.lang.String beanName)
org.springframework.beans.PropertyValues
postProcessProperties(org.springframework.beans.PropertyValues pvs, java.lang.Object bean, java.lang.String beanName)
org.springframework.beans.PropertyValues
postProcessPropertyValues(org.springframework.beans.PropertyValues pvs, java.beans.PropertyDescriptor[] pds, java.lang.Object bean, java.lang.String beanName)
protected java.lang.Object
resolveDependency(org.springframework.beans.factory.config.DependencyDescriptor desc, java.lang.String beanName, java.util.Set<java.lang.String> injectedBeanNames)
protected java.lang.Object
resolveInjectedFieldValue(java.lang.Object bean, java.lang.String beanName, org.springframework.beans.PropertyValues pvs, AnnotatedInjectionBeanPostProcessor.AnnotationInjectedElement<java.lang.reflect.Field> fieldElement)
Resolve the injected-object as the value of the annotatedField
protected java.lang.Object[]
resolveInjectedMethodArguments(java.lang.Object bean, java.lang.String beanName, org.springframework.beans.PropertyValues pvs, AnnotatedInjectionBeanPostProcessor.AnnotationInjectedElement<java.lang.reflect.Method> methodElement)
Resolve the injected-objects as the arguments of the annotatedmethod
void
setBeanClassLoader(java.lang.ClassLoader classLoader)
void
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
void
setCacheSize(int cacheSize)
Set the size of cachevoid
setClassValuesAsString(boolean classValuesAsString)
void
setEnvironment(org.springframework.core.env.Environment environment)
void
setIgnoreDefaultValue(boolean ignoreDefaultValue)
void
setNestedAnnotationsAsMap(boolean nestedAnnotationsAsMap)
void
setOrder(int order)
void
setTryMergedAnnotation(boolean tryMergedAnnotation)
-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 org.springframework.beans.factory.config.BeanPostProcessor
postProcessAfterInitialization, postProcessBeforeInitialization
-
从接口继承的方法 org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
postProcessAfterInstantiation, postProcessBeforeInstantiation
-
-
-
-
构造器详细资料
-
AnnotatedInjectionBeanPostProcessor
public AnnotatedInjectionBeanPostProcessor(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.Class<? extends java.lang.annotation.Annotation>... otherAnnotationTypes)
- 参数:
annotationType
- the single type ofannotation
-
AnnotatedInjectionBeanPostProcessor
public AnnotatedInjectionBeanPostProcessor(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> annotationTypes)
- 参数:
annotationTypes
- the multiple types ofannotations
-
-
方法详细资料
-
getAnnotationTypes
public final java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> getAnnotationTypes()
-
setBeanFactory
public final void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
- 指定者:
setBeanFactory
在接口中org.springframework.beans.factory.BeanFactoryAware
- 抛出:
org.springframework.beans.BeansException
-
determineCandidateConstructors
public final java.lang.reflect.Constructor<?>[] determineCandidateConstructors(java.lang.Class<?> beanClass, java.lang.String beanName) throws org.springframework.beans.BeansException
- 指定者:
determineCandidateConstructors
在接口中org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
- 抛出:
org.springframework.beans.BeansException
-
postProcessPropertyValues
public final org.springframework.beans.PropertyValues postProcessPropertyValues(org.springframework.beans.PropertyValues pvs, java.beans.PropertyDescriptor[] pds, java.lang.Object bean, java.lang.String beanName) throws org.springframework.beans.factory.BeanCreationException
- 指定者:
postProcessPropertyValues
在接口中org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
- 抛出:
org.springframework.beans.factory.BeanCreationException
-
postProcessProperties
public final org.springframework.beans.PropertyValues postProcessProperties(org.springframework.beans.PropertyValues pvs, java.lang.Object bean, java.lang.String beanName) throws org.springframework.beans.BeansException
- 指定者:
postProcessProperties
在接口中org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
- 抛出:
org.springframework.beans.BeansException
-
determineRequiredStatus
protected boolean determineRequiredStatus(org.springframework.core.annotation.AnnotationAttributes attributes)
Determine if the annotated field or method requires its dependency.- 参数:
attributes
- the injected annotation attributes- 返回:
- whether the annotation indicates that a dependency is required
-
findInjectionAnnotationAttributes
protected final org.springframework.core.annotation.AnnotationAttributes findInjectionAnnotationAttributes(java.lang.reflect.AnnotatedElement annotatedElement)
-
doGetAnnotationAttributes
protected final org.springframework.core.annotation.AnnotationAttributes doGetAnnotationAttributes(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
GetAnnotationAttributes
- 参数:
annotatedElement
-the annotated element
annotationType
- thetyoe
pfannotation
- 返回:
- if
annotatedElement
can't be found inannotatedElement
, returnnull
-
postProcessMergedBeanDefinition
public final void postProcessMergedBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition, java.lang.Class<?> beanType, java.lang.String beanName)
- 指定者:
postProcessMergedBeanDefinition
在接口中org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor
-
setClassValuesAsString
public final void setClassValuesAsString(boolean classValuesAsString)
- 参数:
classValuesAsString
- whether to turn Class references into Strings (for compatibility withAnnotationMetadata
or to preserve them as Class references
-
setNestedAnnotationsAsMap
public final void setNestedAnnotationsAsMap(boolean nestedAnnotationsAsMap)
- 参数:
nestedAnnotationsAsMap
- whether to turn nested Annotation instances intoAnnotationAttributes
maps (for compatibility withAnnotationMetadata
or to preserve them as Annotation instances
-
setIgnoreDefaultValue
public final void setIgnoreDefaultValue(boolean ignoreDefaultValue)
- 参数:
ignoreDefaultValue
- whether ignore default value or not
-
setTryMergedAnnotation
public final void setTryMergedAnnotation(boolean tryMergedAnnotation)
- 参数:
tryMergedAnnotation
- whether try merged annotation or not
-
setCacheSize
public final void setCacheSize(int cacheSize)
Set the size of cache- 参数:
cacheSize
- the size of cache
-
setOrder
public final void setOrder(int order)
-
setBeanClassLoader
public final void setBeanClassLoader(java.lang.ClassLoader classLoader)
- 指定者:
setBeanClassLoader
在接口中org.springframework.beans.factory.BeanClassLoaderAware
-
setEnvironment
public final void setEnvironment(org.springframework.core.env.Environment environment)
- 指定者:
setEnvironment
在接口中org.springframework.context.EnvironmentAware
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 抛出:
java.lang.Exception
-
destroy
public void destroy() throws java.lang.Exception
- 指定者:
destroy
在接口中org.springframework.beans.factory.DisposableBean
- 抛出:
java.lang.Exception
-
resolveInjectedFieldValue
protected java.lang.Object resolveInjectedFieldValue(java.lang.Object bean, java.lang.String beanName, org.springframework.beans.PropertyValues pvs, AnnotatedInjectionBeanPostProcessor.AnnotationInjectedElement<java.lang.reflect.Field> fieldElement) throws java.lang.Throwable
Resolve the injected-object as the value of the annotatedField
- 参数:
bean
- The bean that will be injectedbeanName
- The name of requesting bean that will be injectedpvs
-PropertyValues
fieldElement
-the field element
was annotated- 返回:
- An injected object
- 抛出:
java.lang.Throwable
- If resolving is failed
-
resolveInjectedMethodArguments
protected java.lang.Object[] resolveInjectedMethodArguments(java.lang.Object bean, java.lang.String beanName, org.springframework.beans.PropertyValues pvs, AnnotatedInjectionBeanPostProcessor.AnnotationInjectedElement<java.lang.reflect.Method> methodElement) throws java.lang.Throwable
Resolve the injected-objects as the arguments of the annotatedmethod
- 参数:
bean
- The bean that will be injectedbeanName
- The name of the bean that will be injectedpvs
-PropertyValues
methodElement
-the method element
was annotated- 返回:
- The array of the injected objects as the arguments of the annotated
method
- 抛出:
java.lang.Throwable
- If resolving is failed
-
resolveDependency
protected final java.lang.Object resolveDependency(org.springframework.beans.factory.config.DependencyDescriptor desc, java.lang.String beanName, java.util.Set<java.lang.String> injectedBeanNames)
-
getOrder
public final int getOrder()
- 指定者:
getOrder
在接口中org.springframework.core.Ordered
-
getEnvironment
public final org.springframework.core.env.Environment getEnvironment()
-
getClassLoader
public final java.lang.ClassLoader getClassLoader()
-
getBeanFactory
public final org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory()
-
-