Class CosIdGeneratorRegistrar

java.lang.Object
me.ahoo.cosid.spring.autoconfigure.CosIdGeneratorRegistrar
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.context.EnvironmentAware

public class CosIdGeneratorRegistrar extends Object implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.context.EnvironmentAware, org.springframework.beans.factory.BeanFactoryAware
Registers one bean per generator, named after it, whose instance CosIdRuntime provides (07 ยง4.1): the runtime stays the one source of truth. Only names and types are registered here, while the bean definitions are processed; the spec is built then from cosid.* and the RuntimeSpecCustomizer beans, and is the cosIdRuntimeSpec bean the runtime starts from.

Bean types: IdGenerator for snowflake, segment and custom (the default one is primary), PartsIdGenerator for cosid80, GroupedIdGenerator for periodic-segment, and the concrete UuidV7Generator for uuidv7, which has no interface of its own; the other concrete generators are CosIdRuntime.get(name, type). The bean of a disabled generator throws GeneratorDisabledException on each call (D24). Every generator bean depends on the runtime, so it is destroyed before the runtime closes.

  • Field Details

  • Constructor Details

    • CosIdGeneratorRegistrar

      public CosIdGeneratorRegistrar()
  • Method Details

    • setEnvironment

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

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
    • spec

      public me.ahoo.cosid.runtime.RuntimeSpec spec()
      The spec: cosid.* mapped by CosIdSpecs, then customized. Built once.
      Returns:
      the spec
    • postProcessBeanDefinitionRegistry

      public void postProcessBeanDefinitionRegistry(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
    • postProcessBeanFactory

      public void postProcessBeanFactory(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