Class SpringGeneratorFactory

All Implemented Interfaces:
CommonFactory, ExtendedFactory, PrimitiveFactory, RegexFactory

@Component public class SpringGeneratorFactory extends GeneratorFactory
SpringGeneratorFactory integrates the core GeneratorFactory with Spring, providing automatic discovery and registration of entity generators using ORM resolvers.

This factory scans entities from the configured ORMCreator, registers them, and allows retrieval of EntityGenerator instances for specific entity classes.

Lifecycle: The initialization process is performed after Spring dependency injection via the @PostConstruct annotated init() method.

  • Constructor Details

    • SpringGeneratorFactory

      public SpringGeneratorFactory(EntityInstanceCreator entityInstanceCreator, ORMCreator ormCreator)
      Constructs a new SpringGeneratorFactory with the required dependencies.
      Parameters:
      entityInstanceCreator - the factory responsible for creating entity instances
      ormCreator - the ORM creator used to provide entity resolvers
  • Method Details

    • getGenerator

      public <T> EntityGenerator<T> getGenerator(Class<T> clazz)
      Retrieves the EntityGenerator associated with the given entity class.
      When the application starts, SpringGeneratorFactory automatically scans and registers all entity generators.

      Therefore, you do not need to manually register the entity class you want to generate.

      Type Parameters:
      T - the entity type
      Parameters:
      clazz - the entity class
      Returns:
      the EntityGenerator for the given class
      Throws:
      GeneratorException - if no generator is found for the class
    • getEntityGeneratorNames

      public List<Class<?>> getEntityGeneratorNames()
      Returns:
      list of entity classes with registered generators
    • getOrmCreator

      public ORMCreator getOrmCreator()
      Returns:
      the ORM creator instance used by this factory.