org.apache.log.output.db

Class AbstractJDBCTarget

public abstract class AbstractJDBCTarget extends AbstractTarget

Abstract JDBC target.

Author: Avalon Development Team Peter Donald

Field Summary
Connectionm_connection
DataSourcem_dataSource
Constructor Summary
protected AbstractJDBCTarget(DataSource dataSource)
Creation of a new instance of the AbstractJDBCTarget.
Method Summary
protected voidcheckConnection()
Utility method to check connection and bring it back up if necessary.
voidclose()
Shutdown target.
protected voidcloseConnection()
Close connection to underlying database.
protected voiddoProcessEvent(LogEvent event)
Process a log event, via formatting and outputting it.
protected ConnectiongetConnection()
Utility method for subclasses to access connection.
protected booleanisStale()
Detect if connection is stale and should be reopened.
protected voidopen()
Startup log session.
protected voidopenConnection()
Open connection to underlying database.
protected abstract voidoutput(LogEvent event)
Output a log event to DB.

Field Detail

m_connection

private Connection m_connection

m_dataSource

private DataSource m_dataSource

Constructor Detail

AbstractJDBCTarget

protected AbstractJDBCTarget(DataSource dataSource)
Creation of a new instance of the AbstractJDBCTarget.

Parameters: dataSource the JDBC datasource

Method Detail

checkConnection

protected final void checkConnection()
Utility method to check connection and bring it back up if necessary.

close

public void close()
Shutdown target. Attempting to write to target after close() will cause errors to be logged.

closeConnection

protected void closeConnection()
Close connection to underlying database.

doProcessEvent

protected void doProcessEvent(LogEvent event)
Process a log event, via formatting and outputting it.

Parameters: event the log event

Throws: Exception if an event processing error occurs

getConnection

protected final Connection getConnection()
Utility method for subclasses to access connection.

Returns: the Connection

isStale

protected boolean isStale()
Detect if connection is stale and should be reopened.

Returns: true if connection is stale, false otherwise

open

protected void open()
Startup log session.

openConnection

protected void openConnection()
Open connection to underlying database.

output

protected abstract void output(LogEvent event)
Output a log event to DB. This must be implemented by subclasses.

Parameters: event the log event.