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 a
All methods of this class (except
All handler incremental worklist updates will be
UUID instead of a
incremental worklist update instance and thus simplifying interfaces not supporting Java objects,
for instance web services. All methods of this class (except
init(IncrementalWorklistUpdate, Integer) require a
UUID identifying the corresponding incremental worklist update. If the ID does not refer to an
incremental worklist update, an IllegalArgumentException will be thrown. All handler incremental worklist updates will be
CachingIncWorklistUpdate. 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.
null will be returned instead of IncWorklistUpdateData if there
are no updates (for the current iteration). If the incremental worklist update is closed
on-the-fly, an IncWorklistUpdateData will be returned even if there is no content.
This class is thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final longThe time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.protected final longThe 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
ConstructorsConstructorDescriptionIncWorklistUpdateHandler(long initialAliveTime, long aliveTimeExtension, LogService logService) Creates a new handler for incremental worklist updates. -
Method Summary
Modifier and TypeMethodDescriptionvoidCallsServerSideProxy.close()on the designated iterator and removes it from this handler.@NotNull @Valid IncWorklistUpdateDataCallsIncrementalWorklistUpdate.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 Details
-
initialAliveTime
protected final long initialAliveTimeThe time in milliseconds a wrapping caching incremental worklist update is alive. -
aliveTimeExtension
protected final long aliveTimeExtensionThe time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.
-
-
Constructor Details
-
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 Details
-
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
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.
-