Class JdbcServiceList
- java.lang.Object
-
- java.util.AbstractCollection<Service>
-
- com.adaptris.core.ServiceCollectionImp
-
- com.adaptris.core.ServiceListBase
-
- com.adaptris.core.ServiceList
-
- com.adaptris.core.services.jdbc.JdbcServiceList
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,ConnectedService
,EventHandlerAware
,MessageEventGenerator
,Service
,ServiceCollection
,StateManagedComponent
,java.lang.Iterable<Service>
,java.util.Collection<Service>
,java.util.List<Service>
@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
Implementation ofServiceCollection
that creates aConnection
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 asServiceList
which this class extends.The rationale behind this service collection implementation is to allow
JdbcService
implementations to share the same underlyingConnection
. EmbeddedJdbcService
implementations do not need to have aDatabaseConnection
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
orJdbcRawDataCaptureService
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
andJdbcDataQueryService
.- See Also:
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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceCollectionImp
eventHandler, log
-
-
Constructor Summary
Constructors Constructor Description JdbcServiceList()
JdbcServiceList(Service... services)
JdbcServiceList(java.util.Collection<Service> serviceList)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 theAdaptrisConnection
to use.void
prepare()
Prepare for initialisation.void
setConnection(AdaptrisConnection c)
Set the connection that will be used by allJdbcService
instances in this service list.-
Methods inherited from class com.adaptris.core.ServiceList
getAllowForwardSearch, setAllowForwardSearch
-
Methods inherited from class com.adaptris.core.ServiceListBase
haltProcessing
-
Methods inherited from class com.adaptris.core.ServiceCollectionImp
add, add, addAll, addAll, addService, changeState, clear, close, continueOnFailure, createName, createQualifier, doService, enforceRequirements, enforceRequirements, get, getComments, getContinueOnFail, getIsTrackingEndpoint, getOutOfStateHandler, getRestartAffectedServiceOnException, getServices, getUniqueId, handleException, indexOf, init, isBranching, isTrackingEndpoint, iterator, lastIndexOf, listIterator, listIterator, registerEventHandler, remove, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, set, setComments, setContinueOnFail, setIsTrackingEndpoint, setOutOfStateHandler, setRestartAffectedServiceOnException, setServices, setUniqueId, size, start, stop, subList, withServices
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface java.util.List
contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
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
-
applyServices
protected void applyServices(AdaptrisMessage msg) throws ServiceException
Description copied from class:ServiceCollectionImp
Apply the required services to the message.- Overrides:
applyServices
in classServiceList
- Parameters:
msg
- the message- Throws:
ServiceException
- wrapping any underlying exception.
-
doInit
protected void doInit() throws CoreException
Description copied from class:ServiceCollectionImp
Start any additional components.- Overrides:
doInit
in classServiceList
- Throws:
CoreException
- wrapping any underlying exception
-
doStart
protected void doStart() throws CoreException
Description copied from class:ServiceCollectionImp
Start any additional components.- Overrides:
doStart
in classServiceListBase
- Throws:
CoreException
- wrapping any underlying exception
-
doStop
protected void doStop()
Description copied from class:ServiceCollectionImp
Stop any additional components.- Overrides:
doStop
in classServiceListBase
-
doClose
protected void doClose()
Description copied from class:ServiceCollectionImp
Close any additional components.- Overrides:
doClose
in classServiceListBase
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Overrides:
prepare
in classServiceCollectionImp
- Throws:
CoreException
-
getConnection
public AdaptrisConnection getConnection()
Description copied from interface:ConnectedService
Returns theAdaptrisConnection
to use.- Specified by:
getConnection
in interfaceConnectedService
- Returns:
- the
AdaptrisConnection
-
setConnection
public void setConnection(AdaptrisConnection c)
Set the connection that will be used by allJdbcService
instances in this service list.- Specified by:
setConnection
in interfaceConnectedService
- Parameters:
c
- theAdaptrisConnection
to use
-
-