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 ConnectedServiceImplementation ofServiceCollectionthat creates aConnectioninstance at the start of the execution of the service list and stores it in object metadata.Other than the creation of the
Connectionat the start of execution, all other behaviour is the same asServiceListwhich this class extends.The rationale behind this service collection implementation is to allow
JdbcServiceimplementations to share the same underlyingConnection. EmbeddedJdbcServiceimplementations do not need to have aDatabaseConnectionconfigured 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
JdbcDataCaptureServiceorJdbcRawDataCaptureServiceservices 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
AbstractJdbcSequenceNumberServiceinstances,JdbcDataCaptureService,JdbcRawDataCaptureServiceandJdbcDataQueryService.- 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 voidapplyServices(AdaptrisMessage msg)Apply the required services to the message.protected voiddoClose()Close any additional components.protected voiddoInit()Start any additional components.protected voiddoStart()Start any additional components.protected voiddoStop()Stop any additional components.AdaptrisConnectiongetConnection()Returns theAdaptrisConnectionto use.voidprepare()Prepare for initialisation.voidsetConnection(AdaptrisConnection c)Set the connection that will be used by allJdbcServiceinstances 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:ServiceCollectionImpApply the required services to the message.- Overrides:
applyServicesin classServiceList- Parameters:
msg- the message- Throws:
ServiceException- wrapping any underlying exception.
-
doInit
protected void doInit() throws CoreExceptionDescription copied from class:ServiceCollectionImpStart any additional components.- Overrides:
doInitin classServiceList- Throws:
CoreException- wrapping any underlying exception
-
doStart
protected void doStart() throws CoreExceptionDescription copied from class:ServiceCollectionImpStart any additional components.- Overrides:
doStartin classServiceListBase- Throws:
CoreException- wrapping any underlying exception
-
doStop
protected void doStop()
Description copied from class:ServiceCollectionImpStop any additional components.- Overrides:
doStopin classServiceListBase
-
doClose
protected void doClose()
Description copied from class:ServiceCollectionImpClose any additional components.- Overrides:
doClosein classServiceListBase
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Overrides:
preparein classServiceCollectionImp- Throws:
CoreException
-
getConnection
public AdaptrisConnection getConnection()
Description copied from interface:ConnectedServiceReturns theAdaptrisConnectionto use.- Specified by:
getConnectionin interfaceConnectedService- Returns:
- the
AdaptrisConnection
-
setConnection
public void setConnection(AdaptrisConnection c)
Set the connection that will be used by allJdbcServiceinstances in this service list.- Specified by:
setConnectionin interfaceConnectedService- Parameters:
c- theAdaptrisConnectionto use
-
-