Class JKDataAccessFactory

java.lang.Object
com.jk.data.dataaccess.JKDataAccessFactory

public class JKDataAccessFactory extends Object
This class provides a factory for creating data access-related objects, including data sources and data access services, and manages the default data source.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Details

    • JKDataAccessFactory

      public JKDataAccessFactory()
  • Method Details

    • getDefaultDataSource

      public static JKDataSource getDefaultDataSource()
      This method retrieves the default data source.

      If not initialized, it initializes it.

      Returns:
      the default data source instance.
    • setDefaultDataSource

      public static void setDefaultDataSource(JKDataSource impl)
      This method sets the default data source to the provided one.
      Parameters:
      impl - Specifies the new default data source.
    • init

      public static void init()
      This method initializes the JKDataAccessFactory by setting the default data source based on configuration.

      If the creation of the default data source is enabled in the configuration, it creates and sets it.

      Otherwise, it logs a message indicating that default data source creation is disabled.

    • close

      protected static void close()
      This method closes the resources associated with the default data source and default NoSQL data source, if they are initialized.
    • getDataAccessService

      public static JKDataAccessService getDataAccessService()
      This method gets the data access service.
      Returns:
      the data access service.
    • getObjectDataAccessService

      public static JKObjectDataAccess getObjectDataAccessService(String databasePrefix)
      This method gets the object object data access service using the provided database prefix.
      Parameters:
      databasePrefix - Specifies the database prefix.
      Returns:
      the object data access service.
    • getObjectDataAccessService

      public static JKObjectDataAccess getObjectDataAccessService(JKDataSource dataSource)
      This method gets the object data access service using the provided data source.
      Parameters:
      dataSource - Specifies the data source.
      Returns:
      the object data access service.
    • getObjectDataAccessService

      public static JKObjectDataAccess getObjectDataAccessService()
      This method gets the object data access service using the default data source.
      Returns:
      the object data access service.
    • getDataAccessService

      public static JKDataAccessService getDataAccessService(String databasePrefix)
      This method gets the data access service using the provided database prefix.
      Parameters:
      databasePrefix - Specifies the database prefix.
      Returns:
      the data access service.
    • getDataAccessService

      public static JKDataAccessService getDataAccessService(JKDataSource dataSource)
      This method gets the data access service using the provided data source.
      Parameters:
      dataSource - Specifies the data source.
      Returns:
      the data access service.
    • isEntityAvailable

      public static boolean isEntityAvailable(Class<?> clas)
      This method checks if an entity represented by the specified class is available within the default data source.
      Parameters:
      clas - Specifies the class representing the entity to check for availability.
      Returns:
      true, if the entity is available within the default data source, false otherwise.
    • getNoSqlDataSource

      public static JKNoSqlDataSource getNoSqlDataSource()
      This method retrieves or initializes the default NoSQL data source, ensuring thread safety.
      Returns:
      the default JKNoSqlDataSource instance.
    • getNoSqlDataAccess

      public static JKNoSqlDataAccess getNoSqlDataAccess()
      This method creates and returns a NoSQL data access service.
      Returns:
      a JKNoSqlDataAccess instance.