Class SingletonDataSource

java.lang.Object
com.creativityfactory.swiftserver.persistence.SingletonDataSource

public class SingletonDataSource extends Object
This class is responsible for creating instance of datasource following the pattern Singleton.
  • Constructor Details

    • SingletonDataSource

      public SingletonDataSource()
  • Method Details

    • init

      public static void init(Map<String,Class<? extends Persistence<?>>> dtSrcMap) throws InstantiationException, IllegalAccessException
      This class initialize the creation of single instance for each identify, which it will be used later to get instance by the given class, where it will identify by the value present in @FromDataSource. This helps in the automation of creation of REST-APIs, exactly for user-defined data sources
      Parameters:
      dtSrcMap - Map of identify-class where will create a single instance for each identify
      Throws:
      InstantiationException
      IllegalAccessException
    • getInstance

      public static Persistence<Object> getInstance(Class<?> model) throws InstantiationException, IllegalAccessException
      Returns instance of persistence object for the given class. This class must be annotated with @FromDataSource
      Parameters:
      model - the given class which you want to get a persistence object of it.
      Returns:
      instance of persistence object for the given class
      Throws:
      InstantiationException - when attempt to get an instance of persistence for a class does not annotated with @FromDataSource
      IllegalAccessException