org.springframework.beans.factory.config.BeanPostProcessor implementation
that invokes annotated init and destroy methods. Allows for an annotation
alternative to Spring's org.springframework.beans.factory.InitializingBean
and org.springframework.beans.factory.DisposableBean callback interfaces.
The actual annotation types that this post-processor checks for can be
configured through the "initAnnotationType"
and "destroyAnnotationType" properties.
Any custom annotation can be used, since there are no required annotation
attributes.
Init and destroy annotations may be applied to methods of any visibility: public, package-protected, protected, or private. Multiple such methods may be annotated, but it is recommended to only annotate one single init method and destroy method, respectively.
Spring's org.
supports the jakarta. and jakarta.
annotations out of the box, as init annotation and destroy annotation, respectively.
Furthermore, it also supports the jakarta. annotation
for annotation-driven injection of named beans.
setInitAnnotationType, setDestroyAnnotationType
| Modifier and Type | Class and Description |
|---|---|
| private class | InitDestroyAnnotationBeanPostProcessor.
Class representing information about annotated init and destroy methods. |
| private static class | InitDestroyAnnotationBeanPostProcessor.
Class representing an annotated init or destroy method. |
| Modifier and Type | Field and Description |
|---|---|
| private final Set | |
| private final transient InitDestroyAnnotationBeanPostProcessor. | |
| private final Set | |
| private final transient Map | |
| protected transient Log | |
| private int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addDestroyAnnotationType(Class<? extends Annotation> destroyAnnotationType)
Add a destroy annotation to check for, indicating destruction methods to call when the context is shutting down. |
| public void | addInitAnnotationType(Class<? extends Annotation> initAnnotationType)
Add an init annotation to check for, indicating initialization methods to call after configuration of a bean. |
| private InitDestroyAnnotationBeanPostProcessor. | |
| private InitDestroyAnnotationBeanPostProcessor. | |
| private InitDestroyAnnotationBeanPostProcessor. | |
| public int | |
| public Object | postProcessAfterInitialization(Object
the new bean instance bean, String the name of the bean beanName)Overrides default org. Apply this |
| public void | postProcessBeforeDestruction(Object
the bean instance to be destroyed bean, String the name of the bean beanName)Implements org. Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks. |
| public Object | postProcessBeforeInitialization(Object
the new bean instance bean, String the name of the bean beanName)Overrides default org. Apply this |
| public void | postProcessMergedBeanDefinition(RootBeanDefinition
the merged bean definition for the bean beanDefinition, Class<?> the actual type of the managed bean instance beanClass, String the name of the bean beanName)Implements org. Post-process the given merged bean definition for the specified bean. |
| public BeanRegistrationAotContribution | processAheadOfTime(RegisteredBean
the registered bean to process registeredBean)Implements org. Process the given |
| private void | |
| public boolean | requiresDestruction(Object
the bean instance to check bean)Overrides default org. Determine whether the given bean instance requires destruction by this post-processor. |
| private static String[] | safeMerge(String[] existingNames, Collection<InitDestroyAnnotationBeanPostProcessor.
|
| public void | setDestroyAnnotationType(Class<? extends Annotation> destroyAnnotationType)
Specify the destroy annotation to check for, indicating destruction methods to call when the context is shutting down. |
| public void | setInitAnnotationType(Class<? extends Annotation> initAnnotationType)
Specify the init annotation to check for, indicating initialization methods to call after configuration of a bean. |
| public void |
| destroyAnnotationTypes | back to summary |
|---|---|
| private final Set<Class<? extends Annotation>> destroyAnnotationTypes | |
| emptyLifecycleMetadata | back to summary |
|---|---|
| private final transient InitDestroyAnnotationBeanPostProcessor. | |
| initAnnotationTypes | back to summary |
|---|---|
| private final Set<Class<? extends Annotation>> initAnnotationTypes | |
| lifecycleMetadataCache | back to summary |
|---|---|
| private final transient Map<Class<?>, InitDestroyAnnotationBeanPostProcessor. | |
| logger | back to summary |
|---|---|
| protected transient Log logger | |
| order | back to summary |
|---|---|
| private int order | |
| InitDestroyAnnotationBeanPostProcessor | back to summary |
|---|---|
| public InitDestroyAnnotationBeanPostProcessor() | |
| addDestroyAnnotationType | back to summary |
|---|---|
| public void addDestroyAnnotationType(Class<? extends Annotation> destroyAnnotationType) Add a destroy annotation to check for, indicating destruction methods to call when the context is shutting down.
| |
| addInitAnnotationType | back to summary |
|---|---|
| public void addInitAnnotationType(Class<? extends Annotation> initAnnotationType) Add an init annotation to check for, indicating initialization methods to call after configuration of a bean.
| |
| buildLifecycleMetadata | back to summary |
|---|---|
| private InitDestroyAnnotationBeanPostProcessor. | |
| findLifecycleMetadata | back to summary |
|---|---|
| private InitDestroyAnnotationBeanPostProcessor. | |
| findLifecycleMetadata | back to summary |
|---|---|
| private InitDestroyAnnotationBeanPostProcessor. | |
| getOrder | back to summary |
|---|---|
| public int getOrder() Implements org. Doc from org. Get the order value of this object. Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet Same order values will result in arbitrary sort positions for the affected objects.
| |
| postProcessAfterInitialization | back to summary |
|---|---|
| public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException Overrides default org. Doc from org. Apply this In case of a FactoryBean, this callback will be invoked for both the FactoryBean
instance and the objects created by the FactoryBean (as of Spring 2.0). The
post-processor can decide whether to apply to either the FactoryBean or created
objects or both through corresponding This callback will also be invoked after a short-circuiting triggered by a
The default implementation returns the given
| |
| postProcessBeforeDestruction | back to summary |
|---|---|
| public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException Implements org. Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks. Like DisposableBean's
| |
| postProcessBeforeInitialization | back to summary |
|---|---|
| public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException Overrides default org. Doc from org. Apply this The default implementation returns the given
| |
| postProcessMergedBeanDefinition | back to summary |
|---|---|
| public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanClass, String beanName) Implements org. Post-process the given merged bean definition for the specified bean.
| |
| processAheadOfTime | back to summary |
|---|---|
| public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) Implements org. Doc from org. Process the given Processors are free to use any techniques they like to analyze the given instance. Most typically use reflection to find fields or methods to use in the contribution. Contributions typically generate source code or resource files that can be used when the AOT optimized application runs.
If the given instance isn't relevant to the processor, it should return a
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException | |
| requiresDestruction | back to summary |
|---|---|
| public boolean requiresDestruction(Object bean) Overrides default org. Doc from org. Determine whether the given bean instance requires destruction by this post-processor. The default implementation returns
| |
| safeMerge | back to summary |
|---|---|
| private static String[] safeMerge(String[] existingNames, Collection<InitDestroyAnnotationBeanPostProcessor. | |
| setDestroyAnnotationType | back to summary |
|---|---|
| public void setDestroyAnnotationType(Class<? extends Annotation> destroyAnnotationType) Specify the destroy annotation to check for, indicating destruction methods to call when the context is shutting down. Any custom annotation can be used, since there are no required
annotation attributes. There is no default, although a typical choice
is the
| |
| setInitAnnotationType | back to summary |
|---|---|
| public void setInitAnnotationType(Class<? extends Annotation> initAnnotationType) Specify the init annotation to check for, indicating initialization methods to call after configuration of a bean. Any custom annotation can be used, since there are no required
annotation attributes. There is no default, although a typical choice
is the
| |
| setOrder | back to summary |
|---|---|
| public void setOrder(int order) | |
| Modifier and Type | Field and Description |
|---|---|
| private final Class | |
| private volatile Set | |
| private volatile Set | |
| private final Collection | |
| private final Collection |
| Access | Constructor and Description |
|---|---|
| public | LifecycleMetadata(Class<?> beanClass, Collection<InitDestroyAnnotationBeanPostProcessor.
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | |
| public void | |
| public void |
| beanClass | back to summary |
|---|---|
| private final Class<?> beanClass | |
| checkedDestroyMethods | back to summary |
|---|---|
| private volatile Set<InitDestroyAnnotationBeanPostProcessor. | |
| checkedInitMethods | back to summary |
|---|---|
| private volatile Set<InitDestroyAnnotationBeanPostProcessor. | |
| destroyMethods | back to summary |
|---|---|
| private final Collection<InitDestroyAnnotationBeanPostProcessor. | |
| initMethods | back to summary |
|---|---|
| private final Collection<InitDestroyAnnotationBeanPostProcessor. | |
| LifecycleMetadata | back to summary |
|---|---|
| public LifecycleMetadata(Class<?> beanClass, Collection<InitDestroyAnnotationBeanPostProcessor. | |
| checkInitDestroyMethods | back to summary |
|---|---|
| public void checkInitDestroyMethods(RootBeanDefinition beanDefinition) | |
| hasDestroyMethods | back to summary |
|---|---|
| public boolean hasDestroyMethods() | |
| invokeDestroyMethods | back to summary |
|---|---|
| public void invokeDestroyMethods(Object target, String beanName) throws Throwable | |
| invokeInitMethods | back to summary |
|---|---|
| public void invokeInitMethods(Object target, String beanName) throws Throwable | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. Indicates whether some other object is "equal to" this one. |
| public String | |
| public Method | |
| public int | |
| public void | |
| private static boolean | isPrivateOrNotVisible(Method method, Class<?> beanClass)
Determine if the supplied lifecycle |
| identifier | back to summary |
|---|---|
| private final String identifier | |
| method | back to summary |
|---|---|
| private final Method method | |
| LifecycleMethod | back to summary |
|---|---|
| public LifecycleMethod(Method method, Class<?> beanClass) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getIdentifier | back to summary |
|---|---|
| public String getIdentifier() | |
| getMethod | back to summary |
|---|---|
| public Method getMethod() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| invoke | back to summary |
|---|---|
| public void invoke(Object target) throws Throwable | |
| isPrivateOrNotVisible | back to summary |
|---|---|
| private static boolean isPrivateOrNotVisible(Method method, Class<?> beanClass) Determine if the supplied lifecycle
| |