Class IncWorklistUpdateHandler
- java.lang.Object
-
- de.aristaflow.ilm.model.common.collection.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 aUUID
instead 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, anIllegalArgumentException
will 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 (
count
isnull
), - the incremental worklist update contains no data at all.
null
will be returned instead ofIncWorklistUpdateData
if there are no updates (for the current iteration). If the incremental worklist update is closed on-the-fly, anIncWorklistUpdateData
will be returned even if there is no content.This class is thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected long
aliveTimeExtension
The time in milliseconds to extend the alive time when accessing the wrapping caching incremental worklist update.protected long
initialAliveTime
The time in milliseconds a wrapping caching incremental worklist update is alive.-
Fields inherited from class de.aristaflow.ilm.model.common.collection.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 void
close(@NotNull UUID iteratorId)
CallsServerSideProxy.close()
on the designated iterator and removes it from this handler.@NotNull @Valid IncWorklistUpdateData
getNext(@NotNull UUID incUpdateId, @Positive Integer count, @PositiveOrZero Integer start)
CallsIncrementalWorklistUpdate.getNext(int)
on the designated incremental worklist update.protected IncWorklistUpdateData
getNext(UUID incUpdateId, CachingIncWorklistUpdate incWorklistUpdate, Integer count, Integer start)
CallsIncrementalWorklistUpdate.getNext(int)
orIncrementalWorklistUpdate.getAll()
on the designated incremental worklist update.@NotNull @Valid IncWorklistUpdateData
getPrevious(@NotNull UUID incUpdateId, @NotNull @Positive Integer count)
CallsCachingIncWorklistUpdate.getPrevious(int)
on the designated incremental worklist update.@NotNull @Valid InitialIncWorklistUpdateData
init(@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.collection.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> 0
ornull
. 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,
null
will be returned. If nocount
orInteger.MAX_VALUE
is 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
- Ifcount
is non-positive (<= 0
), anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been closed implicitly, aServiceConnectionException
will 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> 0
ornull
. 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>= 0
and it must not be bigger than the amounts of item updates in the designated incremental worklist update. If this isnull
, the nextcount
item 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
count
orInteger.MAX_VALUE
is 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 anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- Ifcount
is non-positive (<= 0
) orstart
is negative (< 0
) orstart
refers to an index that is bigger than the amount of item updates of the designated incremental worklist update, anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been closed implicitly, aServiceConnectionException
will 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!- 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> 0
ornull
. 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>= 0
and it must not be bigger than the amounts of item updates in the designated incremental worklist update. If this isnull
, the nextcount
item 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 anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- Ifcount
is non-positive (<= 0
) orstart
is negative (< 0
) orstart
refers to an index that is bigger than the amount of item updates of the designated incremental worklist update, anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been closed implicitly, aServiceConnectionException
will 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,
null
will be returned as item updates. - Throws:
IllegalArgumentException
- If the designated ID does not refer to anIncrementalWorklistUpdate
known by this handler, anIllegalArgumentException
will be thrown.IllegalArgumentException
- If the designated incremental worklist update does not have any previous item updates or count is non-positive (<= 0), anIllegalArgumentException
will be thrown.IllegalStateException
- If the designated incremental worklist update has been closed implicitly, anIllegalStateException
will be thrown on server side.de.aristaflow.adept2.model.communication.ServiceConnectionException
- If the designated incremental worklist update has been closed implicitly, aServiceConnectionException
will 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 anIOException
and handles legacy callingIncrementalWorklistUpdate.drop()
on proxies from old servers.- Overrides:
close
in classAbstractIteratorHandler<CachingIncWorklistUpdate,InitialIncWorklistUpdateData,IncWorklistUpdateData>
- Parameters:
iteratorId
- The ID of the iterator to close.
-
-