Package com.jk.data.datasource.impl
Class JKAbstractDataSource
java.lang.Object
com.jk.data.datasource.impl.JKAbstractDataSource
- All Implemented Interfaces:
Synchronizable
,JKDataSource
- Direct Known Subclasses:
JKHibernateDataSource
The Class JKAbstractDataSource.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new JK abstract data source.JKAbstractDataSource
(String name, Properties properties) Instantiates a new JK abstract data source. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Clean specific database resources.void
close()
Close.void
close
(Connection con) Close.void
close
(Connection connection, boolean commit) Close.protected void
Override config from properties.Gets the client info properties.Gets the config.Gets the connection.Gets the database type.jakarta.persistence.EntityManagerFactory
getEmf()
Gets the emf.Gets the entities.getEntities
(boolean initIfNull) Gets the entities.int
Gets the max allowed connections.getName()
Gets the name.Gets the properties.Gets the query connection.abstract void
init()
Inits the.protected void
initProperties
(Properties properties) Inits the properties.boolean
isEntityAvailable
(Class<?> clas) Checks if is entity available.protected void
processProperty
(Properties properties, String key, String value) Process property.protected void
Adds the J pa entities.protected void
setEmf
(jakarta.persistence.EntityManagerFactory emf) Sets the emf.void
Sets the name.void
setProperty
(String key, String value) Sets the property.protected void
setPropertyIfNull
(String property, String value) Sets the property if null.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jk.data.datasource.JKDataSource
close, createConnection, createEntityManager, getBaseScriptPath, getDatabaseName, getDatabasepassword, getDatabaseUrl, getDatabaseUsername, getRowsLimit
-
Field Details
-
logger
The logger.
-
-
Constructor Details
-
JKAbstractDataSource
public JKAbstractDataSource()Instantiates a new JK abstract data source. -
JKAbstractDataSource
Instantiates a new JK abstract data source.- Parameters:
name
- the nameproperties
- the properties
-
-
Method Details
-
initProperties
Inits the properties.- Parameters:
properties
- the properties
-
fixProperties
protected void fixProperties()Override config from properties. -
processProperty
Process property.- Parameters:
properties
- the propertieskey
- the keyvalue
- the value
-
init
public abstract void init()Inits the.- Specified by:
init
in interfaceJKDataSource
-
getName
Gets the name.- Returns:
- the name
-
setName
Sets the name.- Parameters:
name
- the new name
-
getEntities
Gets the entities.- Returns:
- the entities
-
getEntities
Gets the entities.- Parameters:
initIfNull
- the init if null- Returns:
- the entities
-
getProperties
Gets the properties.- Specified by:
getProperties
in interfaceJKDataSource
- Returns:
- the properties
-
cleanSpecificDatabaseResources
protected void cleanSpecificDatabaseResources()Clean specific database resources. -
close
Close.- Specified by:
close
in interfaceJKDataSource
- Parameters:
con
- the con
-
close
Close.- Specified by:
close
in interfaceJKDataSource
- Parameters:
connection
- the connectioncommit
- the commit
-
getConnection
Gets the connection.- Specified by:
getConnection
in interfaceJKDataSource
- Returns:
- the connection
- Throws:
JKDataAccessException
- the JK data access exception
-
getClientInfoProperties
Gets the client info properties.- Returns:
- the client info properties
-
getEmf
public jakarta.persistence.EntityManagerFactory getEmf()Gets the emf.- Returns:
- the emf
-
setEmf
protected void setEmf(jakarta.persistence.EntityManagerFactory emf) Sets the emf.- Parameters:
emf
- the new emf
-
scanJpaEntities
protected void scanJpaEntities()Adds the J pa entities. -
getMaxAllowedConnections
public int getMaxAllowedConnections()Gets the max allowed connections.- Specified by:
getMaxAllowedConnections
in interfaceJKDataSource
- Returns:
- the max allowed connections
-
setProperty
Sets the property.- Specified by:
setProperty
in interfaceJKDataSource
- Parameters:
key
- the keyvalue
- the value
-
isEntityAvailable
Checks if is entity available.- Specified by:
isEntityAvailable
in interfaceJKDataSource
- Parameters:
clas
- the clas- Returns:
- true, if is entity available
-
getDatabaseType
Gets the database type.- Specified by:
getDatabaseType
in interfaceJKDataSource
- Returns:
- the database type
-
getConfig
Gets the config.- Returns:
- the config
-
setPropertyIfNull
Sets the property if null.- Parameters:
property
- the propertyvalue
- the value
-
close
public void close()Close.- Specified by:
close
in interfaceJKDataSource
-
getQueryConnection
Gets the query connection.- Specified by:
getQueryConnection
in interfaceJKDataSource
- Returns:
- the query connection
- Throws:
JKDataAccessException
- the JK data access exception
-