@ComponentProfile(summary="A collection of services which has an additional database connection", tag="service,jdbc", recommended=DatabaseConnection.class) public class JdbcServiceList extends ServiceList implements ConnectedService
ServiceCollection
that creates a Connection
instance at the start of
the execution of
the service list and stores it in object metadata.
Other than the creation of the Connection
at the start of execution, all other behaviour is the same as
ServiceList
which this class extends.
The rationale behind this service collection implementation is to allow JdbcService
implementations to share the same
underlying Connection
. Embedded JdbcService
implementations do not need to have a
DatabaseConnection
configured as they can derive the correct DatabaseConnection from object metadata. This also allows
the services to participate in a simple transaction if the connection is not set to auto-commit. The event of an exception, the
connection is rolledback and then committed. If all services are considered successful then the transaction is committed (note
that continue-on-fail=true equates to success).
The standard use case for this will be multiple JdbcDataCaptureService
or JdbcRawDataCaptureService
services that
need to be executed but the captured data should only committed to the database at the end. In the event of an exception, all the
changes should be discarded ensuring that the database is consistent.
Note that only some JdbcService implementations support this behaviour namely concrete AbstractJdbcSequenceNumberService
instances, JdbcDataCaptureService
, JdbcRawDataCaptureService
and JdbcDataQueryService
.
JdbcConstants.OBJ_METADATA_DATABASE_CONNECTION_KEY
In the adapter configuration file this class is aliased as jdbc-service-list which is the preferred alternative to the fully qualified classname when building your configuration.
eventHandler, log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
JdbcServiceList() |
JdbcServiceList(java.util.Collection<Service> serviceList) |
JdbcServiceList(Service... services) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyServices(AdaptrisMessage msg)
Apply the required services to the message.
|
protected void |
doClose()
Close any additional components.
|
protected void |
doInit()
Start any additional components.
|
protected void |
doStart()
Start any additional components.
|
protected void |
doStop()
Stop any additional components.
|
AdaptrisConnection |
getConnection()
Returns the
AdaptrisConnection to use. |
void |
prepare()
Prepare for initialisation.
|
void |
setConnection(AdaptrisConnection c)
Set the connection that will be used by all
JdbcService instances in this service list. |
getAllowForwardSearch, setAllowForwardSearch
haltProcessing
add, add, addAll, addAll, addService, changeState, clear, close, continueOnFailure, createName, createQualifier, doService, enforceRequirements, enforceRequirements, get, getComments, getContinueOnFail, getIsTrackingEndpoint, getLookupName, getOutOfStateHandler, getRestartAffectedServiceOnException, getServices, getUniqueId, handleException, indexOf, init, isBranching, isTrackingEndpoint, iterator, lastIndexOf, listIterator, listIterator, registerEventHandler, remove, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, set, setComments, setContinueOnFail, setIsTrackingEndpoint, setLookupName, setOutOfStateHandler, setRestartAffectedServiceOnException, setServices, setUniqueId, size, start, stop, subList, withServices
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
continueOnFailure, doService, isBranching, setUniqueId
createName, createQualifier, isTrackingEndpoint
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
getUniqueId
close, init, start, stop
getLookupName
public JdbcServiceList()
public JdbcServiceList(java.util.Collection<Service> serviceList)
public JdbcServiceList(Service... services)
protected void applyServices(AdaptrisMessage msg) throws ServiceException
ServiceCollectionImp
applyServices
in class ServiceList
msg
- the messageServiceException
- wrapping any underlying exception.protected void doInit() throws CoreException
ServiceCollectionImp
doInit
in class ServiceList
CoreException
- wrapping any underlying exceptionprotected void doStart() throws CoreException
ServiceCollectionImp
doStart
in class ServiceListBase
CoreException
- wrapping any underlying exceptionprotected void doStop()
ServiceCollectionImp
doStop
in class ServiceListBase
protected void doClose()
ServiceCollectionImp
doClose
in class ServiceListBase
public void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
prepare
in class ServiceCollectionImp
CoreException
public AdaptrisConnection getConnection()
ConnectedService
AdaptrisConnection
to use.getConnection
in interface ConnectedService
AdaptrisConnection
public void setConnection(AdaptrisConnection c)
JdbcService
instances in this service list.setConnection
in interface ConnectedService
c
- the AdaptrisConnection
to use