@ComponentProfile(recommended=DatabaseConnection.class, tag="jdbc") public abstract class JdbcService extends ServiceImp implements ConnectedService
Provides database connection for JDBC-based Service
implementations.
log
Constructor and Description |
---|
JdbcService() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyTimeout(java.sql.Statement stmt) |
protected abstract void |
closeJdbcService()
Close the service.
|
void |
closeService() |
protected java.sql.Statement |
createStatement(java.sql.Connection c) |
AdaptrisConnection |
getConnection()
Returns the
AdaptrisConnection to use. |
protected java.sql.Connection |
getConnection(AdaptrisMessage msg)
Get the
Connection either from the AdaptrisMessage object or from configuration. |
TimeInterval |
getStatementTimeout() |
protected abstract void |
initJdbcService() |
void |
initService() |
void |
prepare()
Prepare for initialisation.
|
protected abstract void |
prepareService() |
protected java.sql.PreparedStatement |
prepareStatement(java.sql.Connection c,
java.lang.String sql) |
protected java.sql.PreparedStatement |
prepareStatement(java.sql.Connection c,
java.lang.String sql,
int autoGenKeys) |
void |
setConnection(AdaptrisConnection conn)
Sets the
AdaptrisConnection to use. |
void |
setStatementTimeout(TimeInterval statementTimeout)
Set the statement timeout.
|
void |
start()
Starts the component.
|
protected abstract void |
startService()
Start the service.
|
void |
stop()
Stop the component
|
protected abstract void |
stopService()
Stop the service.
|
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
continueOnFailure, doService, isBranching, setUniqueId
createName, createQualifier, isTrackingEndpoint
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
getUniqueId
close, init
public final void initService() throws CoreException
initService
in class ServiceImp
CoreException
public final void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
protected abstract void prepareService() throws CoreException
CoreException
protected abstract void initJdbcService() throws CoreException
CoreException
public final void closeService()
closeService
in class ServiceImp
protected abstract void closeJdbcService()
This is called before the connection is closed
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface ComponentLifecycle
start
in class ServiceImp
CoreException
- wrapping any underlying Exception
sprotected abstract void startService() throws CoreException
This is called after the connection is started
CoreException
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
stop
in interface ComponentLifecycle
stop
in class ServiceImp
protected abstract void stopService()
This is called after before the connection is stopped
public void setConnection(AdaptrisConnection conn)
ConnectedService
AdaptrisConnection
to use.setConnection
in interface ConnectedService
conn
- the AdaptrisConnection
to usepublic AdaptrisConnection getConnection()
ConnectedService
AdaptrisConnection
to use.getConnection
in interface ConnectedService
AdaptrisConnection
protected java.sql.Connection getConnection(AdaptrisMessage msg) throws java.sql.SQLException
Connection
either from the AdaptrisMessage
object or from configuration.msg
- the adaptrisMessage objectjava.sql.SQLException
public TimeInterval getStatementTimeout()
public void setStatementTimeout(TimeInterval statementTimeout)
statementTimeout
- the statement timeout.protected java.sql.Statement createStatement(java.sql.Connection c) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.PreparedStatement prepareStatement(java.sql.Connection c, java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.PreparedStatement prepareStatement(java.sql.Connection c, java.lang.String sql, int autoGenKeys) throws java.sql.SQLException
java.sql.SQLException
protected void applyTimeout(java.sql.Statement stmt) throws java.sql.SQLException
java.sql.SQLException