public class ConfigurableTAPFactory extends AbstractTAPFactory
Concrete implementation of a TAPFactory
which is parameterized by a TAP configuration file.
All abstract or NULL-implemented methods/functions left by AbstractTAPFactory
are implemented using values
of a TAP configuration file. The concerned methods are: getConnection(String)
, freeConnection(DBConnection)
,
destroy()
, createADQLTranslator()
and createUWSBackupManager(UWSService)
.
Modifier and Type | Field and Description |
---|---|
protected boolean |
backupByUser
Indicate whether the jobs must be backuped gathered by user or just all mixed together.
|
protected long |
backupFrequency
Frequency at which the jobs must be backuped.
|
protected javax.sql.DataSource |
datasource
The
DataSource to use in order to access the database. |
protected java.lang.String |
dbPassword
Password of the database user to use in order to access the database.
|
protected java.lang.String |
dbUrl
JDBC URL of the database to access.
|
protected java.lang.String |
dbUser
Name of the database user to use in order to access the database.
|
protected java.lang.String |
driverPath
Classpath of the JDBC driver to use in order to access the database.
|
protected java.lang.Class<? extends JDBCTranslator> |
translator
The
JDBCTranslator to use when a ADQL query must be executed in the database. |
errorWriter
service
Constructor and Description |
---|
ConfigurableTAPFactory(ServiceConnection service,
java.util.Properties tapConfig)
Build a
TAPFactory using the given TAP service description and TAP configuration file. |
Modifier and Type | Method and Description |
---|---|
protected JDBCTranslator |
createADQLTranslator()
Build a
JDBCTranslator instance with the given class (translator ;
specified by the property sql_translator). |
UWSBackupManager |
createUWSBackupManager(UWSService uws)
Build an
DefaultTAPBackupManager thanks to the backup manager parameters specified
in the TAP configuration file (the properties: backup_frequency, backup_by_user). |
void |
destroy()
Destroy all resources (and particularly DB connections and JDBC driver) allocated in this factory.
|
void |
freeConnection(DBConnection conn)
Free the given connection.
|
DBConnection |
getConnection(java.lang.String jobID)
Build a
JDBCConnection thanks to the database parameters specified
in the TAP configuration file (the properties: jdbc_driver_path, db_url, db_user, db_password). |
createADQLExecutor, createADQLParser, createQueryChecker, createQueryChecker, createQueryFactory, createTAPJob, createTAPJob, createTAPParameters, createTAPParameters, createUploader, createUWS, getErrorWriter
createJob, createJob, createJobThread, createRequestParser, createUWSParameters, createUWSParameters
protected java.lang.Class<? extends JDBCTranslator> translator
JDBCTranslator
to use when a ADQL query must be executed in the database.
This translator is also used to convert ADQL types into database types.protected final javax.sql.DataSource datasource
DataSource
to use in order to access the database.
This attribute is actually used only if the chosen database access method is JNDI.protected final java.lang.String driverPath
protected final java.lang.String dbUrl
protected final java.lang.String dbUser
protected final java.lang.String dbPassword
protected boolean backupByUser
protected long backupFrequency
public ConfigurableTAPFactory(ServiceConnection service, java.util.Properties tapConfig) throws java.lang.NullPointerException, TAPException
TAPFactory
using the given TAP service description and TAP configuration file.service
- The TAP service description.tapConfig
- The TAP configuration file containing particularly information about the database access.java.lang.NullPointerException
- If one of the parameter is NULL.TAPException
- If some properties of the TAP configuration file are wrong.protected JDBCTranslator createADQLTranslator() throws TAPException
JDBCTranslator
instance with the given class (translator
;
specified by the property sql_translator). If the instance can not be build,
whatever is the reason, a TAPException MUST be thrown.
Note: This function is called at the initialization of ConfigurableTAPFactory
in order to check that a translator can be created.TAPException
public DBConnection getConnection(java.lang.String jobID) throws TAPException
JDBCConnection
thanks to the database parameters specified
in the TAP configuration file (the properties: jdbc_driver_path, db_url, db_user, db_password).getConnection
in class TAPFactory
jobID
- ID of the job/thread/process which has asked for this connection. note: The returned connection must then be identified thanks to this ID.TAPException
- If there is any error while getting a free connection.JDBCConnection.JDBCConnection(java.sql.Connection, JDBCTranslator, String, tap.log.TAPLog)
,
JDBCConnection.JDBCConnection(String, String, String, String, JDBCTranslator, String, tap.log.TAPLog)
public void freeConnection(DBConnection conn)
TAPFactory
Free the given connection.
This function is called by the TAP library when a job/thread does not need this connection any more. It aims to free resources associated to the given database connection.
Note: This function can just close definitely the connection OR give it back to a connection pool. The implementation is here totally free!
freeConnection
in class TAPFactory
conn
- The connection to close.public void destroy()
TAPFactory
Destroy all resources (and particularly DB connections and JDBC driver) allocated in this factory.
Note: This function is called when the TAP service is shutting down. After this call, the factory may not be able to provide any closed resources ; its behavior may be unpredictable.
destroy
in class TAPFactory
public UWSBackupManager createUWSBackupManager(UWSService uws) throws TAPException
DefaultTAPBackupManager
thanks to the backup manager parameters specified
in the TAP configuration file (the properties: backup_frequency, backup_by_user).
Note: If the specified backup_frequency is negative, no backup manager is returned.createUWSBackupManager
in class AbstractTAPFactory
uws
- The UWS service which has to be backuped and restored.DefaultTAPBackupManager
otherwise.TAPException
- If any error occurs while creating this backup manager.AbstractTAPFactory.createUWSBackupManager(uws.service.UWSService)
,
DefaultTAPBackupManager