Class IncWorklistUpdateHandler
- java.lang.Object
-
- de.aristaflow.ilm.model.common.AbstractIteratorHandler<CachingIncWorklistUpdate,InitialIncWorklistUpdateData,IncWorklistUpdateData>
-
- de.aristaflow.ilm.model.worklistmodel.IncWorklistUpdateHandler
-
public class IncWorklistUpdateHandler extends AbstractIteratorHandler<CachingIncWorklistUpdate,InitialIncWorklistUpdateData,IncWorklistUpdateData>
This class handles incremental worklist updates by assigning IDs to them and mapping these IDs to the respective incremental worklist update. This allows to use aUUIDinstead of a incremental worklist update instance and thus simplifying interfaces not supporting Java objects, for instance web services.
All methods of this class (exceptinit(IncrementalWorklistUpdate, Integer)require a UUID identifying the corresponding incremental worklist update. If the ID does not refer to an incremental worklist update, anIllegalArgumentExceptionwill be thrown.
All handler incremental worklist updates will beCachingIncWorklistUpdate. This allows for iterating back and specifying the first item update which to retrieve.This handler tries to minimise closing effort for incremental worklist updates. It will close them implicitly if
- all updates are transferred initially,
- all updates are retrieved at once (
countisnull), - the incremental worklist update contains no data at all.
nullwill be returned instead ofIncWorklistUpdateDataif there are no updates (for the current iteration). If the incremental worklist update is closed on-the-fly, anIncWorklistUpdateDatawill be returned even if there is no content.This class is thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected longaliveTimeExtensionThe time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.protected longinitialAliveTimeThe time in milliseconds a wrapping caching incremental worklist update is alive.-
Fields inherited from class de.aristaflow.ilm.model.common.AbstractIteratorHandler
dataCreator, initDataCreator, iterators, iteratorTypeName, logger, removerService
-
-
Constructor Summary
Constructors Constructor Description IncWorklistUpdateHandler(long initialAliveTime, long aliveTimeExtension, LogService logService)Creates a new handler for incremental worklist updates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose(@NotNull UUID iteratorId)CallsServerSideProxy.close()on the designated iterator and removes it from this handler.@NotNull @Valid IncWorklistUpdateDatagetNext(@NotNull UUID incUpdateId, @Positive Integer count, @PositiveOrZero Integer start)CallsIncrementalWorklistUpdate.getNext(int)on the designated incremental worklist update.protected IncWorklistUpdateDatagetNext(UUID incUpdateId, CachingIncWorklistUpdate incWorklistUpdate, Integer count, Integer start)CallsIncrementalWorklistUpdate.getNext(int)orIncrementalWorklistUpdate.getAll()on the designated incremental worklist update.@NotNull @Valid IncWorklistUpdateDatagetPrevious(@NotNull UUID incUpdateId, @NotNull @Positive Integer count)CallsCachingIncWorklistUpdate.getPrevious(int)on the designated incremental worklist update.@NotNull @Valid InitialIncWorklistUpdateDatainit(@NotNull @Valid IncrementalWorklistUpdate incWorklistUpdate, @Positive Integer count)Adds the designated incremental worklist update to this handler, creates an ID for it and callsgetNext(UUID, Integer, Integer)with the designated parameters andstart=null.-
Methods inherited from class de.aristaflow.ilm.model.common.AbstractIteratorHandler
closeOrDefer, closeOrDefer, getIterator, shutdown
-
-
-
-
Field Detail
-
initialAliveTime
protected final long initialAliveTime
The time in milliseconds a wrapping caching incremental worklist update is alive.
-
aliveTimeExtension
protected final long aliveTimeExtension
The time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.
-
-
Constructor Detail
-
IncWorklistUpdateHandler
public IncWorklistUpdateHandler(long initialAliveTime, long aliveTimeExtension, LogService logService)Creates a new handler for incremental worklist updates.- Parameters:
initialAliveTime- The time in milliseconds a wrapping caching incremental worklist update is alive.aliveTimeExtension- The time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.logService- The log service to retrieve the logger for log messages from.
-
-
Method Detail
-
init
@NotNull @Valid public @NotNull @Valid InitialIncWorklistUpdateData init(@NotNull @Valid @NotNull @Valid IncrementalWorklistUpdate incWorklistUpdate, @Positive @Positive Integer count)
Adds the designated incremental worklist update to this handler, creates an ID for it and callsgetNext(UUID, Integer, Integer)with the designated parameters andstart=null. The added incremental worklist update will be removed from this handler when it is closed. If all data of the incremental worklist update is transferred now, the incremental worklist update will be closed immediately.- Parameters:
incWorklistUpdate- The incremental worklist update to add to this handler.count- The amount of item updates to retrieve in forward direction. This has to be> 0ornull. If this isnull, all item updates of the designated incremental worklist update will be returned and the incremental worklist update will be closed.- Returns:
- The initial meta data of the incremental worklist update and the next n item updates of
the designated incremental worklist update, where n is the specified count. In case of
an insufficient amount of next item updates remaining only the available item updates
will be returned. If there are no item updates,
nullwill be returned. If nocountorInteger.MAX_VALUEis specified, all item updates of the designated incremental worklist update will be returned at once and the incremental worklist update will be closed. - Throws:
IllegalArgumentException- Ifcountis non-positive (<= 0), anIllegalArgumentExceptionwill be thrown.IllegalStateException- If the designated incremental worklist update has been closed implicitly, anIllegalStateExceptionwill be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException- If the designated incremental worklist update has been closed implicitly, aServiceConnectionExceptionwill be thrown on client side.
-
getNext
@NotNull @Valid public @NotNull @Valid IncWorklistUpdateData getNext(@NotNull @NotNull UUID incUpdateId, @Positive @Positive Integer count, @PositiveOrZero @PositiveOrZero Integer start)
CallsIncrementalWorklistUpdate.getNext(int)on the designated incremental worklist update. The alive time of the incremental worklist update will be extended in case of implicit extension.- Parameters:
incUpdateId- The ID of the incremental worklist update to forward the call to.count- The amount of item updates to retrieve in forward direction. This has to be> 0ornull. If this isnull, all item updates of the designated incremental worklist update will be returned and the incremental worklist update will be closed.start- The index of the item update from which to retrieve the next count item updates when requesting a limited amount of item updates (count > 0). 0 is the index of the first item update. This has to be>= 0and it must not be bigger than the amounts of item updates in the designated incremental worklist update. If this isnull, the nextcountitem updates will be returned.- Returns:
- Some meta data of the incremental worklist update and the next n item updates of the
designated incremental worklist update, where n is the specified count. In case of an
insufficient amount of next item updates remaining only the available item updates (or
no item updates) will be returned. If no
countorInteger.MAX_VALUEis specified, all remaining item updates of the designated incremental worklist update will be returned at once. - Throws:
IllegalArgumentException- If the designated ID does not refer to anIncrementalWorklistUpdateknown by this handler, anIllegalArgumentExceptionwill be thrown.IllegalArgumentException- Ifcountis non-positive (<= 0) orstartis negative (< 0) orstartrefers to an index that is bigger than the amount of item updates of the designated incremental worklist update, anIllegalArgumentExceptionwill be thrown.IllegalStateException- If the designated incremental worklist update has been closed implicitly, anIllegalStateExceptionwill be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException- If the designated incremental worklist update has been closed implicitly, aServiceConnectionExceptionwill be thrown on client side.
-
getNext
protected IncWorklistUpdateData getNext(UUID incUpdateId, CachingIncWorklistUpdate incWorklistUpdate, Integer count, Integer start)
CallsIncrementalWorklistUpdate.getNext(int)orIncrementalWorklistUpdate.getAll()on the designated incremental worklist update. The alive time of the incremental worklist update will be extended in case of implicit extension. If all item udpates are requested now or the incremental worklist update has no updates at all, it will be set to closed at once. The caller of this method has to close the incremental worklist update otherwise!- Parameters:
incUpdateId- The ID of the incremental worklist update to forward the call to.incWorklistUpdate- The incremental worklist update to forward the call to.count- The amount of item updates to retrieve in forward direction. This has to be> 0ornull. If this isnull, all item updates of the designated incremental worklist update will be returned.start- The index of the item update from which to retrieve the next count item updates when requesting a limited amount of item updates (count > 0). 0 is the index of the first item update. This has to be>= 0and it must not be bigger than the amounts of item updates in the designated incremental worklist update. If this isnull, the nextcountitem updates will be returned.- Returns:
- Some meta data of the incremental worklist update and the next n item updates of the designated incremental worklist update, where n is the specified count. In case of an insufficient amount of next item updates remaining only the available item updates (or no item updates) will be returned.
- Throws:
IllegalArgumentException- If the designated ID does not refer to anIncrementalWorklistUpdateknown by this handler, anIllegalArgumentExceptionwill be thrown.IllegalArgumentException- Ifcountis non-positive (<= 0) orstartis negative (< 0) orstartrefers to an index that is bigger than the amount of item updates of the designated incremental worklist update, anIllegalArgumentExceptionwill be thrown.IllegalStateException- If the designated incremental worklist update has been closed implicitly, anIllegalStateExceptionwill be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException- If the designated incremental worklist update has been closed implicitly, aServiceConnectionExceptionwill be thrown on client side.
-
getPrevious
@NotNull @Valid public @NotNull @Valid IncWorklistUpdateData getPrevious(@NotNull @NotNull UUID incUpdateId, @NotNull @Positive @NotNull @Positive Integer count)
CallsCachingIncWorklistUpdate.getPrevious(int)on the designated incremental worklist update.- Parameters:
incUpdateId- The ID of the incremental worklist update to forward the call to.count- The amount of item updates to retrieve in backward direction. This has to be > 0.- Returns:
- The ID of the incremental worklist update and the previous n item updates, where n is
the specified count. The order corresponds to the one in the underlying data structure,
that is previous item updates in the returned list are also previous item updates in
the data structure. In case of an insufficient amount of previous item updates
remaining only the available item updates will be returned. If there are no more
previous item updates,
nullwill be returned as item updates. - Throws:
IllegalArgumentException- If the designated ID does not refer to anIncrementalWorklistUpdateknown by this handler, anIllegalArgumentExceptionwill be thrown.IllegalArgumentException- If the designated incremental worklist update does not have any previous item updates or count is non-positive (<= 0), anIllegalArgumentExceptionwill be thrown.IllegalStateException- If the designated incremental worklist update has been closed implicitly, anIllegalStateExceptionwill be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException- If the designated incremental worklist update has been closed implicitly, aServiceConnectionExceptionwill be thrown on client side.
-
close
public void close(@NotNull @NotNull UUID iteratorId)CallsServerSideProxy.close()on the designated iterator and removes it from this handler. This implementation callsIncrementalWorklistUpdate.close()which does not throw anIOExceptionand handles legacy callingIncrementalWorklistUpdate.drop()on proxies from old servers.- Overrides:
closein classAbstractIteratorHandler<CachingIncWorklistUpdate,InitialIncWorklistUpdateData,IncWorklistUpdateData>- Parameters:
iteratorId- The ID of the iterator to close.
-
-