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, and MessageScheduler

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 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

      @Bean public static TrackSelfPostProcessor trackSelfPostProcessor()
      Registers the TrackSelfPostProcessor, which supports payload classes that track and handle their own type within the application's component-scan scope.
      See Also:
    • statefulPostProcessor

      @Bean public static StatefulPostProcessor statefulPostProcessor()
      Registers the StatefulPostProcessor, enabling discovery of stateful handler types within the application's component-scan scope.
      See Also:
    • socketEndpointPostProcessor

      @Bean public static SocketEndpointPostProcessor socketEndpointPostProcessor()
      Registers the SocketEndpointPostProcessor, used for WebSocket endpoint types within the application's component-scan scope.
      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:
      postProcessAfterInitialization in interface org.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

      @Bean public Serializer serializer()
      Optionally provides a default Serializer implementation based on Jackson, automatically detecting and registering upcasters and downcasters from Spring-managed beans.

      This method is only invoked if no other Serializer bean is defined.

      If a custom serializer is provided by the application, upcasters and downcasters must be registered explicitly.

      Returns:
      a Serializer configured 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 default FluxzeroBuilder, configured using Spring-provided components such as UserProvider, Cache, and WebResponseMapper. Automatically uses application properties via SpringPropertySource.
    • fluxzero

      @Bean public Fluxzero fluxzero(FluxzeroBuilder builder, List<FluxzeroCustomizer> customizers)
      Constructs the Fluxzero instance if no Fluxzero bean exists, preferring a user-provided Client or falling back to either a WebSocketClient or LocalClient depending on presence of configuration properties.
    • aggregateRepository

      @Bean public AggregateRepository aggregateRepository(Fluxzero fluxzero)
    • scheduler

      @Bean public MessageScheduler scheduler(Fluxzero fluxzero)
    • commandGateway

      @Bean public CommandGateway commandGateway(Fluxzero fluxzero)
    • eventGateway

      @Bean public EventGateway eventGateway(Fluxzero fluxzero)
    • queryGateway

      @Bean public QueryGateway queryGateway(Fluxzero fluxzero)
    • errorGateway

      @Bean public ErrorGateway errorGateway(Fluxzero fluxzero)
    • metricsGateway

      @Bean public MetricsGateway metricsGateway(Fluxzero fluxzero)
    • resultGateway

      @Bean public ResultGateway resultGateway(Fluxzero fluxzero)
    • keyValueStore

      @Bean public KeyValueStore keyValueStore(Fluxzero fluxzero)
    • documentStore

      @Bean public DocumentStore documentStore(Fluxzero fluxzero)
    • getBean

      protected <T> Optional<T> getBean(Class<T> type)