Package com.jk.data.dataaccess
Class JKDataAccessFactory
java.lang.Object
com.jk.data.dataaccess.JKDataAccessFactory
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
close()
This method closes the resources associated with the default data source and default NoSQL data source, if they are initialized.static JKDataAccessService
This method gets the data access service.static JKDataAccessService
getDataAccessService
(JKDataSource dataSource) This method gets the data access service using the provided data source.static JKDataAccessService
getDataAccessService
(String databasePrefix) This method gets the data access service using the provided database prefix.static JKDataSource
This method retrieves the default data source.static JKNoSqlDataAccess
This method creates and returns a NoSQL data access service.static JKNoSqlDataSource
This method retrieves or initializes the default NoSQL data source, ensuring thread safety.static JKObjectDataAccess
This method gets the object data access service using the default data source.static JKObjectDataAccess
getObjectDataAccessService
(JKDataSource dataSource) This method gets the object data access service using the provided data source.static JKObjectDataAccess
getObjectDataAccessService
(String databasePrefix) This method gets the object object data access service using the provided database prefix.static void
init()
This method initializes theJKDataAccessFactory
by setting the default data source based on configuration.static boolean
isEntityAvailable
(Class<?> clas) This method checks if an entity represented by the specified class is available within the default data source.static void
This method sets the default data source to the provided one.
-
Constructor Details
-
JKDataAccessFactory
public JKDataAccessFactory()
-
-
Method Details
-
getDefaultDataSource
This method retrieves the default data source.If not initialized, it initializes it.
- Returns:
- the default data source instance.
-
setDefaultDataSource
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 theJKDataAccessFactory
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
This method gets the data access service.- Returns:
- the data access service.
-
getObjectDataAccessService
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
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
This method gets the object data access service using the default data source.- Returns:
- the object data access service.
-
getDataAccessService
This method gets the data access service using the provided database prefix.- Parameters:
databasePrefix
- Specifies the database prefix.- Returns:
- the data access service.
-
getDataAccessService
This method gets the data access service using the provided data source.- Parameters:
dataSource
- Specifies the data source.- Returns:
- the data access service.
-
isEntityAvailable
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
This method retrieves or initializes the default NoSQL data source, ensuring thread safety.- Returns:
- the default
JKNoSqlDataSource
instance.
-
getNoSqlDataAccess
This method creates and returns a NoSQL data access service.- Returns:
- a
JKNoSqlDataAccess
instance.
-