Package com.iizix.prop.vs
Class VSWorkUnit
java.lang.Object
com.iizix.prop.vs.VSWorkUnit
Class used to handle manipulation with one or more VS components that in turn may contain others. It is used to postpone other parties that also wishes to process the components and would like to be informed when the others completes their tasks. Typically, this is used by e.g. the Database Connector before it starts to do massive changes to a VS Table. On the consumer side, the UI Grid uses this in order to avoid processing updates to the VS Table until the database has completed its work unit.
This class is by no means a locking class, but rather a helper class to avoid updating data from a structure that is not yet "stable".
This class is thread-safe.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- VSWorkUnit- (VirtualSpace virtualSpace) Creates a work unit for the entire VirtualSpace.- VSWorkUnit- (VSComponent component) The list of components used in the for the VS update work.- VSWorkUnit- (VSComponent... components) The list of components used in the for the VS update work.
- Method SummaryModifier and TypeMethodDescription- void- add- (VSComponent component) Adds another component in the work unit.- boolean- areFree- (Runnable callback, VSComponent... components) Verifies if component(s) is/are included in the work unit.- voidBegins the work unit.- void- endWork()Ends the work unit.- boolean- isFree- (Runnable callback, VSComponent component) Verifies if a component is included in the work unit.
- Constructor Details- VSWorkUnitCreates a work unit for the entire VirtualSpace. This is typically done in complex update areas where the components are not know, such as e.g. the rollback of a GyroTransaction.- Parameters:
- virtualSpace- The VirtualSpace involved in the work.
 
- VSWorkUnitThe list of components used in the for the VS update work.- Parameters:
- component- The VS component involved in the work.
- Throws:
- IllegalArgumentException- If the components doesn't have a VirtualSpace.
 
- VSWorkUnitThe list of components used in the for the VS update work.- Parameters:
- components- The VS components involved in the work.
- Throws:
- IllegalArgumentException- If the components doesn't have a VirtualSpace or if the components is of length zero or are in different VirtualSpaces.
 
 
- Method Details- addAdds another component in the work unit.- Parameters:
- component- The VS component involved in the work.
- Throws:
- IllegalArgumentException- If the component is in a different VirtualSpace.
- IllegalStateException- If the work has begun.
 
- beginWorkpublic void beginWork()Begins the work unit. It is VERY important to complete the processing of the work unit with a call to- endWork()- This method registers the work unit with the VirtualSpace in question. - Throws:
- IllegalStateException- If this method is called twice.
 
- endWorkpublic void endWork()Ends the work unit. This call will call all postponed callbacks that have been added during the work unit with the- isFree(Runnable, VSComponent)- areFree(Runnable, VSComponent...)- Throws:
- IllegalStateException- If this method is called without prior beginWork or called twice.
 
- isFreeVerifies if a component is included in the work unit.- Parameters:
- callback- The callback to call when work completes, or null for none.
- component- The component to verify.
- Returns:
- true if it's OK to process, false means the component is included in this work unit and if callbackis non-null, it will be called.
 
- areFreeVerifies if component(s) is/are included in the work unit.- Parameters:
- callback- The callback to call when work completes, or null for none.
- components- The components to verify.
- Returns:
- true if it's OK to process, false means the component is included in this work unit and if callbackis non-null, it will be called.