Package org.apache.log.output.db
Class AbstractJDBCTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.db.AbstractJDBCTarget
- All Implemented Interfaces:
ErrorAware
,LogTarget
,Closeable
- Direct Known Subclasses:
DefaultJDBCTarget
Abstract JDBC target.
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractJDBCTarget
(DataSource dataSource) Creation of a new instance of the AbstractJDBCTarget. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Utility method to check connection and bring it back up if necessary.void
close()
Shutdown target.protected void
Close connection to underlying database.protected void
doProcessEvent
(LogEvent event) Process a log event, via formatting and outputting it.protected final Connection
Utility method for subclasses to access connection.protected boolean
isStale()
Detect if connection is stale and should be reopened.protected void
open()
Startup log session.protected void
Open connection to underlying database.protected abstract void
Output a log event to DB.Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
Field Details
-
m_dataSource
-
m_connection
-
-
Constructor Details
-
AbstractJDBCTarget
Creation of a new instance of the AbstractJDBCTarget.- Parameters:
dataSource
- the JDBC datasource
-
-
Method Details
-
doProcessEvent
Process a log event, via formatting and outputting it.- Specified by:
doProcessEvent
in classAbstractTarget
- Parameters:
event
- the log event- Throws:
Exception
- if an event processing error occurs
-
output
Output a log event to DB. This must be implemented by subclasses.- Parameters:
event
- the log event.
-
open
protected void open()Startup log session.- Overrides:
open
in classAbstractTarget
-
openConnection
protected void openConnection()Open connection to underlying database. -
getConnection
Utility method for subclasses to access connection.- Returns:
- the Connection
-
checkConnection
protected final void checkConnection()Utility method to check connection and bring it back up if necessary. -
isStale
protected boolean isStale()Detect if connection is stale and should be reopened.- Returns:
- true if connection is stale, false otherwise
-
close
public void close()Shutdown target. Attempting to write to target after close() will cause errors to be logged.- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classAbstractTarget
-
closeConnection
protected void closeConnection()Close connection to underlying database.
-