Class AnnotationBasedModelFactory

java.lang.Object
org.adempiere.base.AnnotationBasedFactory
org.adempiere.base.AnnotationBasedModelFactory
All Implemented Interfaces:
IModelFactory
Direct Known Subclasses:
WS_ModelFactory

public class AnnotationBasedModelFactory extends AnnotationBasedFactory implements IModelFactory
Translates table names into model classes having the Model annotation. Relies on DefaultModelFactory for everything else.
This factory is designed to have a service rank higher than DefaultModelFactory, as class discovery using SPI is preferred over reflection-based methods.
Author:
Saulo Gil, Heng Sin
  • Constructor Details

    • AnnotationBasedModelFactory

      public AnnotationBasedModelFactory()
  • Method Details

    • getPackages

      protected String[] getPackages()
      Extension point. Subclasses might override this method in order to have faster model class scanning.
      Returns:
      array of packages to be accepted during class scanning
      See Also:
      • ClassGraph.acceptPackagesNonRecursive(String...)
    • getAcceptClassesPatterns

      protected String[] getAcceptClassesPatterns()
      Extension point. Provide a list of patterns to match against class names.
      Returns:
      array of strings containing patterns
      See Also:
      • ClassGraph.acceptClasses(String...)
    • activate

      public void activate(org.osgi.service.component.ComponentContext context) throws ClassNotFoundException
      Scan annotation upon activation of component
      Parameters:
      context -
      Throws:
      ClassNotFoundException
    • getClass

      public Class<?> getClass(String tableName)
      Get Persistence Class for Table
      Specified by:
      getClass in interface IModelFactory
      Parameters:
      tableName - table name
      Returns:
      class or null
    • getPO

      public PO getPO(String tableName, int Record_ID, String trxName)
      Get PO Class Instance
      Specified by:
      getPO in interface IModelFactory
      Record_ID - record
      Returns:
      PO for Record or null
    • getPO

      public PO getPO(String tableName, String Record_UU, String trxName)
      Get PO Class Instance
      Specified by:
      getPO in interface IModelFactory
      Record_UU - record UUID
      Returns:
      PO for Record or null
    • getPO

      public PO getPO(String tableName, ResultSet rs, String trxName)
      Get PO Class Instance
      Specified by:
      getPO in interface IModelFactory
      rs - result set
      trxName - transaction
      Returns:
      PO for Record or null