public class WrappedDatabaseService extends java.lang.Object implements DatabaseService
DatabaseService wrapper that can beused to generate a tabe
showing the current active connectionsLOG_INSERT_FEATURE, LOG_QUERY_FEATURE, LOG_UPDATE, USE_SQL_DISTICT_FEATURE| Constructor and Description |
|---|
WrappedDatabaseService(AppContext conn) |
WrappedDatabaseService(DatabaseService inner,
java.lang.String id) |
| Modifier and Type | Method and Description |
|---|---|
static void |
add(WrappedDatabaseService serv) |
void |
addClosable(java.lang.AutoCloseable c) |
void |
cleanup()
AppContext is being closed. |
void |
closeRetainedClosables() |
void |
commitTransaction()
flush changes since start of last commit.
|
java.util.Map<java.lang.String,java.lang.Object> |
getConnectionAttributes()
get a map of information about the connection
|
AppContext |
getContext() |
SQLContext |
getSQLContext()
get
SQLContext using the default ConfigService |
SQLContext |
getSQLContext(java.lang.String tag)
get alternative database
SQLContext
If the tag is null it returns the same SQLContext as
DatabaseService.getSQLContext(). |
SQLContext |
getSQLContext(java.lang.String tag,
java.util.Properties config_props)
get a {SQLContext} based on properties
|
static Table |
getStatusTable() |
java.lang.Class<? super DatabaseService> |
getType()
Returns the type of service the class should be registered under.
|
void |
handleError(java.lang.String message,
java.sql.SQLException e)
Handle an unexpected database exception.
|
boolean |
inTransaction()
Are we already in a transaction
|
void |
logError(java.lang.String message,
java.sql.SQLException e)
handle an
SQLException directly. |
static void |
remove(WrappedDatabaseService serv) |
void |
removeClosable(java.lang.AutoCloseable c) |
void |
rollbackTransaction()
Abort changes since start or last commit
|
void |
startTransaction()
Start a database transaction
Transactions cannot be nested so use
DatabaseService.inTransaction() if possible doubt. |
void |
stopTransaction()
finish transaction (includes commit).
|
int |
transactionStage()
returns the number of times
DatabaseService.commitTransaction() has been called
since the last transaction start. |
public WrappedDatabaseService(AppContext conn)
conn - public WrappedDatabaseService(DatabaseService inner, java.lang.String id)
public static void add(WrappedDatabaseService serv)
public static void remove(WrappedDatabaseService serv)
public static Table getStatusTable()
public AppContext getContext()
getContext in interface Contexedpublic java.lang.Class<? super DatabaseService> getType()
AppContextServicegetType in interface AppContextService<DatabaseService>public void cleanup()
AppContextCleanupAppContext is being closed.
Only use this for cleanup that can't be handled by
normal garbage collection or for state which is never returned by reference.cleanup in interface AppContextCleanuppublic void addClosable(java.lang.AutoCloseable c)
addClosable in interface CloseRegistrypublic void removeClosable(java.lang.AutoCloseable c)
removeClosable in interface CloseRegistrypublic SQLContext getSQLContext(java.lang.String tag, java.util.Properties config_props) throws java.sql.SQLException
DatabaseServicegetSQLContext in interface DatabaseServiceSQLContextjava.sql.SQLExceptionpublic SQLContext getSQLContext() throws java.sql.SQLException
DatabaseServiceSQLContext using the default ConfigServicegetSQLContext in interface DatabaseServiceSQLContext to databasejava.sql.SQLExceptionpublic SQLContext getSQLContext(java.lang.String tag) throws java.sql.SQLException
DatabaseServiceSQLContext
If the tag is null it returns the same SQLContext as
DatabaseService.getSQLContext().getSQLContext in interface DatabaseServicejava.sql.SQLExceptionpublic boolean inTransaction()
DatabaseServiceinTransaction in interface DatabaseServicepublic int transactionStage()
DatabaseServiceDatabaseService.commitTransaction() has been called
since the last transaction start.
If this returns 0 then a roll-back will return to the state at DatabaseService.startTransaction() if greater than zero
there have been intermediate commits.
To aid in testing the value is not reset to zero until the next call to DatabaseService.startTransaction()transactionStage in interface DatabaseServicepublic void startTransaction()
DatabaseServiceDatabaseService.inTransaction() if possible doubt.startTransaction in interface DatabaseServicepublic void rollbackTransaction()
DatabaseServicerollbackTransaction in interface DatabaseServicepublic void commitTransaction()
DatabaseServiceCleanupService unless the transaction phases all
make sense in their own right.commitTransaction in interface DatabaseServicepublic void stopTransaction()
DatabaseServicestopTransaction in interface DatabaseServicepublic void handleError(java.lang.String message,
java.sql.SQLException e)
throws DataFault
DatabaseServiceDataFault however
this also allow special handing of certain classes of error such as SQLTransientExceptionshandleError in interface DatabaseServiceDataFaultpublic void logError(java.lang.String message,
java.sql.SQLException e)
DatabaseServiceSQLException directly. Normally this will just log the error however
this also allow special handing of certain classes of error such as SQLTransientExceptionslogError in interface DatabaseServicepublic void closeRetainedClosables()
closeRetainedClosables in interface CloseRegistrypublic java.util.Map<java.lang.String,java.lang.Object> getConnectionAttributes()
throws java.lang.Exception
DatabaseServicegetConnectionAttributes in interface DatabaseServicejava.lang.Exception