Package com.adaptris.core.jdbc
Class JdbcService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.jdbc.JdbcService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConnectedService
,MessageEventGenerator
,Service
,StateManagedComponent
- Direct Known Subclasses:
AbstractJdbcSequenceNumberService
,JdbcMapInsert
,JdbcServiceWithParameters
@ComponentProfile(recommended=DatabaseConnection.class, tag="jdbc") public abstract class JdbcService extends ServiceImp implements ConnectedService
Provides database connection for JDBC-based
Service
implementations.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description JdbcService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 theAdaptrisConnection
to use.protected java.sql.Connection
getConnection(AdaptrisMessage msg)
Get theConnection
either from theAdaptrisMessage
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 theAdaptrisConnection
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 componentprotected abstract void
stopService()
Stop the service.-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, doService, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Method Detail
-
initService
public final void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
prepare
public final void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
prepareService
protected abstract void prepareService() throws CoreException
- Throws:
CoreException
-
initJdbcService
protected abstract void initJdbcService() throws CoreException
- Throws:
CoreException
-
closeService
public final void closeService()
- Specified by:
closeService
in classServiceImp
-
closeJdbcService
protected abstract void closeJdbcService()
Close the service.This is called before the connection is closed
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s
-
startService
protected abstract void startService() throws CoreException
Start the service.This is called after the connection is started
- Throws:
CoreException
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classServiceImp
-
stopService
protected abstract void stopService()
Stop the service.This is called after before the connection is stopped
-
setConnection
public void setConnection(AdaptrisConnection conn)
Description copied from interface:ConnectedService
Sets theAdaptrisConnection
to use.- Specified by:
setConnection
in interfaceConnectedService
- Parameters:
conn
- theAdaptrisConnection
to use
-
getConnection
public AdaptrisConnection getConnection()
Description copied from interface:ConnectedService
Returns theAdaptrisConnection
to use.- Specified by:
getConnection
in interfaceConnectedService
- Returns:
- the
AdaptrisConnection
-
getConnection
protected java.sql.Connection getConnection(AdaptrisMessage msg) throws java.sql.SQLException
Get theConnection
either from theAdaptrisMessage
object or from configuration.- Parameters:
msg
- the adaptrisMessage object- Returns:
- the connection either from the adaptris message or from configuration.
- Throws:
java.sql.SQLException
-
getStatementTimeout
public TimeInterval getStatementTimeout()
-
setStatementTimeout
public void setStatementTimeout(TimeInterval statementTimeout)
Set the statement timeout.- Parameters:
statementTimeout
- the statement timeout.- Since:
- 3.0.1
-
createStatement
protected java.sql.Statement createStatement(java.sql.Connection c) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
prepareStatement
protected java.sql.PreparedStatement prepareStatement(java.sql.Connection c, java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
prepareStatement
protected java.sql.PreparedStatement prepareStatement(java.sql.Connection c, java.lang.String sql, int autoGenKeys) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
applyTimeout
protected void applyTimeout(java.sql.Statement stmt) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-