Class TrackSelfPostProcessor

java.lang.Object
io.fluxzero.sdk.configuration.spring.TrackSelfPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.context.EnvironmentAware

public class TrackSelfPostProcessor extends Object
Spring BeanDefinitionRegistryPostProcessor that detects classes annotated with TrackSelf and registers them as FluxzeroPrototype beans for use by Fluxzero.

The scan follows Spring's

invalid reference
ComponentScan
boundaries so that applications control which self-tracked payload types become active without exposing those payload types as regular Spring beans.

All detected @TrackSelf types are wrapped as FluxzeroPrototype and registered as Spring bean definitions, allowing Fluxzero to discover and register them as self-tracking projections at runtime.

Usage

To enable self-tracking on a class use e.g.:
@TrackSelf
public interface UserUpdate {
    UserId getUserId();

    @HandleCommand
    default void handle() {
        Fluxzero.loadAggregate(getUserId()).assertAndApply(this);
    }
}

Make sure Spring picks up this processor, for example by including FluxzeroSpringConfig in your configuration:

@SpringBootApplication
@Import(FluxzeroSpringConfig.class)
public class MyApp { ... }
See Also:
  • Constructor Details

    • TrackSelfPostProcessor

      public TrackSelfPostProcessor()
  • Method Details

    • getTargetAnnotation

      protected Class<TrackSelf> getTargetAnnotation()
    • getBeanNameSuffix

      protected String getBeanNameSuffix()
    • postProcessBeanFactory

      public void postProcessBeanFactory(@NonNull @NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • postProcessBeanDefinitionRegistry

      public void postProcessBeanDefinitionRegistry(@NonNull @NonNull org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • setEnvironment

      public void setEnvironment(org.springframework.core.env.Environment environment)
      Specified by:
      setEnvironment in interface org.springframework.context.EnvironmentAware