Class SpringContextFailoverScanner
- All Implemented Interfaces:
FailoverScanner,org.springframework.beans.factory.Aware,org.springframework.beans.factory.SmartInitializingSingleton,org.springframework.context.ApplicationContextAware
FailoverScanner backed by the Spring ApplicationContext.
Implements SmartInitializingSingleton so it runs after all
singleton beans have been instantiated — the correct lifecycle point to see every
registered bean. It enumerates bean definitions, unwraps CGLIB proxies via
ClassUtils.getUserClass(java.lang.Object), then walks each class's method hierarchy with
ReflectionUtils.doWithMethods(java.lang.Class<?>, org.springframework.util.ReflectionUtils.MethodCallback) using Spring's
AnnotationUtils.findAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<A>) so that @Failover placed on an
interface method is found even when the concrete class does not repeat it.
Works with Spring-managed beans only — methods on plain Java objects not registered in the Spring context are not visible to this scanner.
- Author:
- Anand Manissery
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidScans all registered singleton beans for methods annotated withFailover.Returns allFailoverannotations discovered during scanning.Returns the payload types discovered on@Failovermethods: each method's return type, or — for a method returning aCollectionor array — its element/component type.@Nullable FailoverfindFailoverByName(String name) Returns theFailoverannotation with the given name, ornullif not found.voidsetApplicationContext(@Nullable org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
SpringContextFailoverScanner
public SpringContextFailoverScanner()
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(@Nullable org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()Scans all registered singleton beans for methods annotated withFailover. Called by Spring after every singleton bean has been instantiated.- Specified by:
afterSingletonsInstantiatedin interfaceorg.springframework.beans.factory.SmartInitializingSingleton
-
findFailoverByName
Description copied from interface:FailoverScannerReturns theFailoverannotation with the given name, ornullif not found.- Specified by:
findFailoverByNamein interfaceFailoverScanner- Parameters:
name- the value ofFailover.name()- Returns:
- the matching annotation, or
null
-
findAllFailover
Description copied from interface:FailoverScannerReturns allFailoverannotations discovered during scanning.- Specified by:
findAllFailoverin interfaceFailoverScanner- Returns:
- list of all failover annotations; never
null
-
findAllPayloadTypes
Description copied from interface:FailoverScannerReturns the payload types discovered on@Failovermethods: each method's return type, or — for a method returning aCollectionor array — its element/component type.Used to build a secure-by-default deserialization allowlist for serializing stores (the packages of these types are trusted). Returns an empty set by default for implementations that do not track types.
- Specified by:
findAllPayloadTypesin interfaceFailoverScanner- Returns:
- discovered payload types; never
null
-