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
Serviceimplementations.
-
-
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 voidapplyTimeout(java.sql.Statement stmt)protected abstract voidcloseJdbcService()Close the service.voidcloseService()protected java.sql.StatementcreateStatement(java.sql.Connection c)AdaptrisConnectiongetConnection()Returns theAdaptrisConnectionto use.protected java.sql.ConnectiongetConnection(AdaptrisMessage msg)Get theConnectioneither from theAdaptrisMessageobject or from configuration.TimeIntervalgetStatementTimeout()protected abstract voidinitJdbcService()voidinitService()voidprepare()Prepare for initialisation.protected abstract voidprepareService()protected java.sql.PreparedStatementprepareStatement(java.sql.Connection c, java.lang.String sql)protected java.sql.PreparedStatementprepareStatement(java.sql.Connection c, java.lang.String sql, int autoGenKeys)voidsetConnection(AdaptrisConnection conn)Sets theAdaptrisConnectionto use.voidsetStatementTimeout(TimeInterval statementTimeout)Set the statement timeout.voidstart()Starts the component.protected abstract voidstartService()Start the service.voidstop()Stop the componentprotected abstract voidstopService()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:
initServicein classServiceImp- Throws:
CoreException
-
prepare
public final void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein 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:
closeServicein classServiceImp
-
closeJdbcService
protected abstract void closeJdbcService()
Close the service.This is called before the connection is closed
-
start
public void start() throws CoreExceptionDescription copied from interface:ComponentLifecycleStarts 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:
startin interfaceComponentLifecycle- Overrides:
startin classServiceImp- Throws:
CoreException- wrapping any underlyingExceptions
-
startService
protected abstract void startService() throws CoreExceptionStart the service.This is called after the connection is started
- Throws:
CoreException
-
stop
public void stop()
Description copied from interface:ComponentLifecycleStop 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 aRuntimeExceptionmay cause unintended consequences- Specified by:
stopin interfaceComponentLifecycle- Overrides:
stopin 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:ConnectedServiceSets theAdaptrisConnectionto use.- Specified by:
setConnectionin interfaceConnectedService- Parameters:
conn- theAdaptrisConnectionto use
-
getConnection
public AdaptrisConnection getConnection()
Description copied from interface:ConnectedServiceReturns theAdaptrisConnectionto use.- Specified by:
getConnectionin interfaceConnectedService- Returns:
- the
AdaptrisConnection
-
getConnection
protected java.sql.Connection getConnection(AdaptrisMessage msg) throws java.sql.SQLException
Get theConnectioneither from theAdaptrisMessageobject 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
-
-