Class ServiceCollectionImp
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConfigComment
,EventHandlerAware
,MessageEventGenerator
,Service
,ServiceCollection
,StateManagedComponent
,Iterable<Service>
,Collection<Service>
,List<Service>
- Direct Known Subclasses:
BranchingServiceCollection
,ServiceListBase
Behaviour common to ServiceCollection
s.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends Service> c) boolean
addAll
(Collection<? extends Service> c) void
addService
(Service service) Adds aService
to the end of the configuredList
.protected abstract void
Apply the required services to the message.void
changeState
(ComponentState newState) Updates the state for the componentComponentState
.void
clear()
final void
close()
Closes the component.boolean
If true containers should continue and apply the next configuredService
even if thisService
throws anException
.Create a name for anyMleMarker
that is generated.Create a qualifier for anyMleMarker
that is generated.protected abstract void
doClose()
Close any additional components.protected abstract void
doInit()
Start any additional components.final void
doService
(AdaptrisMessage msg) Apply the service to the message.protected abstract void
doStart()
Start any additional components.protected abstract void
doStop()
Stop any additional components.protected Service
enforceRequirements
(Service service) Enforce any requirements of the list.protected Collection<? extends Service>
enforceRequirements
(Collection<? extends Service> collection) Enforce any requirements of the list.get
(int index) Returns the configuredList
ofService
s.Get the unique-id that is associated with this component.void
handleException
(Service service, AdaptrisMessage msg, Exception e) Handles any exceptions thrown from an embedded Service.int
final void
init()
Initialises the component.boolean
Returns true if the implementation supports branching.boolean
Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.iterator()
int
listIterator
(int index) void
prepare()
Prepare for initialisation.void
Register the current event handler against this component.remove
(int index) void
Request this component is closed.void
Request this component is init'd.void
Request this component is started.void
Request this component is stopped.Returns the last recordComponentState
.void
void
void
void
setOutOfStateHandler
(OutOfStateHandler handler) Set the behaviour when internal services are not in the correct state.void
Whether to restart the service that threw theServiceException
during processing.void
setServices
(List<Service> serviceList) Override the underlying service list.void
Sets the unique identifier for thisService
.int
size()
final void
start()
Starts the component.final void
stop()
Stop the componentsubList
(int fromIndex, int toIndex) <T extends ServiceCollection>
TwithServices
(Service... services) 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 java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Field Details
-
log
protected transient org.slf4j.Logger log -
eventHandler
-
-
Constructor Details
-
ServiceCollectionImp
public ServiceCollectionImp() -
ServiceCollectionImp
-
-
Method Details
-
registerEventHandler
Description copied from interface:EventHandlerAware
Register the current event handler against this component.- Specified by:
registerEventHandler
in interfaceEventHandlerAware
- Parameters:
eh
- the event handler currently in use.
-
createName
Description copied from interface:MessageEventGenerator
Create a name for anyMleMarker
that is generated.The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarker
that is generated.- Specified by:
createName
in interfaceMessageEventGenerator
-
createQualifier
Description copied from interface:MessageEventGenerator
Create a qualifier for anyMleMarker
that is generated.The default implementation is to return the unique-id of the component in question, or the empty string if not configured
- Specified by:
createQualifier
in interfaceMessageEventGenerator
- Returns:
- the qualifier for any
MleMarker
that is generated.
-
getUniqueId
Description copied from interface:AdaptrisComponent
Get the unique-id that is associated with this component.- Specified by:
getUniqueId
in interfaceAdaptrisComponent
- Returns:
- the unique-id
-
setUniqueId
Description copied from interface:Service
Sets the unique identifier for this
Service
. These unique identifiers are optional but maybe required by some implementations ofServiceCollection
.- Specified by:
setUniqueId
in interfaceService
- Parameters:
s
- thisService
's unique identifier
-
isBranching
public boolean isBranching()Description copied from interface:Service
Returns true if the implementation supports branching.
- Specified by:
isBranching
in interfaceService
- Returns:
- true if the implementation supports branching
- See Also:
-
continueOnFailure
public boolean continueOnFailure()Description copied from interface:Service
If true containers should continue and apply the next configured
Service
even if thisService
throws anException
.- Specified by:
continueOnFailure
in interfaceService
- Returns:
- continueOnFail
-
getContinueOnFail
- Returns:
- whether or not this service is configured to continue on failure.
- See Also:
-
setContinueOnFail
-
getIsTrackingEndpoint
-
setIsTrackingEndpoint
-
isTrackingEndpoint
public boolean isTrackingEndpoint()Description copied from interface:MessageEventGenerator
Returns true if this should be considered an 'end-point' for tracking purposes, otherwise false.
- Specified by:
isTrackingEndpoint
in interfaceMessageEventGenerator
- Returns:
- true if this should be considered an 'end-point' for tracking purposes, otherwise false
- See Also:
-
setComments
- Specified by:
setComments
in interfaceConfigComment
-
getComments
- Specified by:
getComments
in interfaceConfigComment
-
addService
Adds a
Service
to the end of the configuredList
.- Specified by:
addService
in interfaceServiceCollection
- Parameters:
service
- theService
to add to the end of the configuredList
may not be null
-
getServices
Returns the configured
List
ofService
s. May be empty but not null.- Specified by:
getServices
in interfaceServiceCollection
- Returns:
- the configured
List
ofService
s
-
setServices
Override the underlying service list.- Parameters:
serviceList
- the service list.
-
doService
Description copied from interface:Service
Apply the service to the message.
- Specified by:
doService
in interfaceService
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
applyServices
Apply the required services to the message.- Parameters:
msg
- the message- Throws:
ServiceException
- wrapping any underlying exception.
-
init
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
doInit
Start any additional components.- Throws:
CoreException
- wrapping any underlying exception
-
start
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
- Throws:
CoreException
- wrapping any underlyingException
s
-
doStart
Start any additional components.- Throws:
CoreException
- wrapping any underlying exception
-
stop
public final 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
-
doStop
protected abstract void doStop()Stop any additional components. -
close
public final void close()Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- Specified by:
close
in interfaceComponentLifecycle
-
doClose
protected abstract void doClose()Close any additional components. -
changeState
Updates the state for the component
ComponentState
.- Specified by:
changeState
in interfaceStateManagedComponent
-
retrieveComponentState
Returns the last record
ComponentState
.- Specified by:
retrieveComponentState
in interfaceStateManagedComponent
- Returns:
- the current
ComponentState
-
requestInit
Request this component is init'd.
- Specified by:
requestInit
in interfaceStateManagedComponent
- Throws:
CoreException
- wrapping any underlying Exceptions
-
requestStart
Request this component is started.
- Specified by:
requestStart
in interfaceStateManagedComponent
- Throws:
CoreException
- wrapping any underlying Exceptions
-
requestStop
public void requestStop()Request this component is stopped.
- Specified by:
requestStop
in interfaceStateManagedComponent
-
requestClose
public void requestClose()Request this component is closed.
- Specified by:
requestClose
in interfaceStateManagedComponent
-
prepare
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
handleException
public void handleException(Service service, AdaptrisMessage msg, Exception e) throws ServiceException Description copied from interface:ServiceCollection
Handles any exceptions thrown from an embedded Service.
- Specified by:
handleException
in interfaceServiceCollection
- Parameters:
service
- service which threw the Exceptionmsg
- the message which caused the exceptione
- the exception which was thrown- Throws:
ServiceException
- wrapping the exception ifService.continueOnFailure()
is false
-
getRestartAffectedServiceOnException
-
setRestartAffectedServiceOnException
Whether to restart the service that threw theServiceException
during processing.- Parameters:
b
- true to restart affected services, default false
-
add
- Specified by:
add
in interfaceCollection<Service>
- Specified by:
add
in interfaceList<Service>
- Overrides:
add
in classAbstractCollection<Service>
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<Service>
- Specified by:
size
in interfaceList<Service>
- Specified by:
size
in classAbstractCollection<Service>
-
add
-
addAll
- Specified by:
addAll
in interfaceCollection<Service>
- Specified by:
addAll
in interfaceList<Service>
- Overrides:
addAll
in classAbstractCollection<Service>
-
addAll
-
get
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<Service>
-
listIterator
- Specified by:
listIterator
in interfaceList<Service>
-
listIterator
- Specified by:
listIterator
in interfaceList<Service>
-
remove
-
set
-
subList
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<Service>
- Specified by:
clear
in interfaceList<Service>
- Overrides:
clear
in classAbstractCollection<Service>
-
enforceRequirements
Enforce any requirements of the list.- Parameters:
service
- the service due to be added.- Returns:
- the service
- Throws:
IllegalArgumentException
- if the requirements are not met
-
enforceRequirements
protected Collection<? extends Service> enforceRequirements(Collection<? extends Service> collection) Enforce any requirements of the list.- Parameters:
collection
- the services due to be added.- Returns:
- the collection
- Throws:
IllegalArgumentException
- if the requirements are not met
-
getOutOfStateHandler
-
setOutOfStateHandler
Set the behaviour when internal services are not in the correct state.- Parameters:
handler
- if not specified defaults toRaiseExceptionOutOfStateHandler
.
-
withServices
-