Class FluxzeroSpringConfig
java.lang.Object
io.fluxzero.sdk.configuration.spring.FluxzeroSpringConfig
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor
@Configuration
public class FluxzeroSpringConfig
extends Object
implements org.springframework.beans.factory.config.BeanPostProcessor
Spring configuration class for automatically wiring and initializing common Fluxzero components in a Spring
application context.
This configuration simplifies the integration of Fluxzero by:
- Registering
@Handle...annotated beans as handlers after the context is refreshed - Auto-detecting and registering upcasters and downcasters with the
Serializer - Providing default implementations for core interfaces like
CommandGateway,Serializer, andMessageScheduler
Note that Fluxzero does not require Spring, and this class is entirely optional. It exists purely to reduce boilerplate in Spring-based applications.
The simplest way to enable this configuration in a Spring Boot application, is by annotating your main application class with:
@SpringBootApplication
@Import(FluxzeroSpringConfig.class)
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFluxzeroSpringConfig(org.springframework.context.ApplicationContext context) Stores a reference to the Spring context and prepares for handler detection. -
Method Summary
Modifier and TypeMethodDescriptionaggregateRepository(Fluxzero fluxzero) commandGateway(Fluxzero fluxzero) documentStore(Fluxzero fluxzero) errorGateway(Fluxzero fluxzero) eventGateway(Fluxzero fluxzero) fluxzero(FluxzeroBuilder builder, List<FluxzeroCustomizer> customizers) Constructs theFluxzeroinstance if no Fluxzero bean exists, preferring a user-providedClientor falling back to either aWebSocketClientorLocalClientdepending on presence of configuration properties.fluxzeroBuilder(Serializer serializer, Optional<UserProvider> userProvider, Optional<Cache> cache, Optional<WebResponseMapper> webResponseMapper, org.springframework.core.env.Environment environment) Provides a defaultFluxzeroBuilder, configured using Spring-provided components such asUserProvider,Cache, andWebResponseMapper.protected <T> Optional<T> voidhandle(org.springframework.context.event.ContextRefreshedEvent event) Registers all discovered Spring beans as Fluxzero handlers once the application context is refreshed.keyValueStore(Fluxzero fluxzero) metricsGateway(Fluxzero fluxzero) postProcessAfterInitialization(Object bean, String beanName) Captures beans post-initialization to inspect later for handler registration.queryGateway(Fluxzero fluxzero) resultGateway(Fluxzero fluxzero) Optionally provides a defaultSerializerimplementation based on Jackson, automatically detecting and registering upcasters and downcasters from Spring-managed beans.static SocketEndpointPostProcessorRegisters theSocketEndpointPostProcessor, used for handlers that manage WebSocket communication.static StatefulPostProcessorRegisters theStatefulPostProcessor, enabling lifecycle and stateful behavior for beans.static TrackSelfPostProcessorRegisters theTrackSelfPostProcessor, which supports payload classes that track and handle their own type.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor
postProcessBeforeInitialization
-
Constructor Details
-
FluxzeroSpringConfig
@Autowired protected FluxzeroSpringConfig(org.springframework.context.ApplicationContext context) Stores a reference to the Spring context and prepares for handler detection.
-
-
Method Details
-
trackSelfPostProcessor
Registers theTrackSelfPostProcessor, which supports payload classes that track and handle their own type.- See Also:
-
statefulPostProcessor
Registers theStatefulPostProcessor, enabling lifecycle and stateful behavior for beans.- See Also:
-
socketEndpointPostProcessor
Registers theSocketEndpointPostProcessor, used for handlers that manage WebSocket communication.- See Also:
-
postProcessAfterInitialization
public Object postProcessAfterInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException Captures beans post-initialization to inspect later for handler registration. Prototype beans are handled specially.- Specified by:
postProcessAfterInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-
handle
@EventListener public void handle(org.springframework.context.event.ContextRefreshedEvent event) Registers all discovered Spring beans as Fluxzero handlers once the application context is refreshed. Also installs a default uncaught exception handler and starts the application context if needed. -
serializer
Optionally provides a defaultSerializerimplementation based on Jackson, automatically detecting and registering upcasters and downcasters from Spring-managed beans.This method is only invoked if no other
Serializerbean is defined.If a custom serializer is provided by the application, upcasters and downcasters must be registered explicitly.
- Returns:
- a
Serializerconfigured with discovered casting logic
-
fluxzeroBuilder
@Bean public FluxzeroBuilder fluxzeroBuilder(Serializer serializer, Optional<UserProvider> userProvider, Optional<Cache> cache, Optional<WebResponseMapper> webResponseMapper, org.springframework.core.env.Environment environment) Provides a defaultFluxzeroBuilder, configured using Spring-provided components such asUserProvider,Cache, andWebResponseMapper. Automatically uses application properties viaSpringPropertySource. -
fluxzero
Constructs theFluxzeroinstance if no Fluxzero bean exists, preferring a user-providedClientor falling back to either aWebSocketClientorLocalClientdepending on presence of configuration properties. -
aggregateRepository
-
scheduler
-
commandGateway
-
eventGateway
-
queryGateway
-
errorGateway
-
metricsGateway
-
resultGateway
-
keyValueStore
-
documentStore
-
getBean
-