Package com.im.commons.progress
Class EnvUtils
- java.lang.Object
-
- com.im.commons.progress.EnvUtils
-
public final class EnvUtils extends java.lang.Object
This class is used as factory for creating default implementation of DIF environments (DFEnvironmentRO
andDFEnvironmentRW
) and for creating environment for subtasks.- Author:
- Petr Hamernik
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
EnvUtils.DFFeedbackWithCancel
An extension ofDFFeedback
with ability to cancel the running task.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DFEnvironmentRO
createDefaultEnvironmentRO(java.lang.String progressName, boolean cancellable)
Creates default environment for read only operations.static DFEnvironmentRW
createDefaultEnvironmentRW(DFLock lock, java.lang.String progressName, boolean cancellable)
Creates default environment for read-write operations.static EnvUtils.DFFeedbackWithCancel
createFeedbackWithCancel(DFFeedback feedback)
Creates a proxy implementation for givenDFFeedback
and returns its extension ofEnvUtils.DFFeedbackWithCancel
type.static DFEnvironmentRW
createRWFromRO(DFEnvironmentRO env, DFLock lock)
Make RW environment from given RO by adding lock and delegating the rest of methods.static DFEnvironmentRO
createSubTaskEnvironment(DFEnvironmentRO env, java.lang.String subTaskName, int masterWorkunitFrom, int masterWorkunitTo, int masterWorkunitTotal)
static DFEnvironmentRO
createSubTaskEnvironment(java.beans.PropertyChangeEvent evt, java.lang.String taskName)
Creates sub-environment.
-
-
-
Method Detail
-
createDefaultEnvironmentRO
public static DFEnvironmentRO createDefaultEnvironmentRO(java.lang.String progressName, boolean cancellable)
Creates default environment for read only operations.- Parameters:
progressName
- The progress namecancellable
- The cancellable flag- Returns:
- The default environment for read only operations
-
createDefaultEnvironmentRW
public static DFEnvironmentRW createDefaultEnvironmentRW(DFLock lock, java.lang.String progressName, boolean cancellable)
Creates default environment for read-write operations.- Parameters:
lock
- The lockprogressName
- The progress namecancellable
- The cancellable flag- Returns:
- The default environment for read-write operations
-
createSubTaskEnvironment
public static DFEnvironmentRO createSubTaskEnvironment(DFEnvironmentRO env, java.lang.String subTaskName, int masterWorkunitFrom, int masterWorkunitTo, int masterWorkunitTotal)
-
createRWFromRO
public static DFEnvironmentRW createRWFromRO(DFEnvironmentRO env, DFLock lock)
Make RW environment from given RO by adding lock and delegating the rest of methods. This method can be also used for replacing the current lock in some existingDFEnvironmentRW
.- Parameters:
env
- The read-only environmentlock
- The lock- Returns:
- The proxy for the given
DFEnvironmentRO
, all methods exceptgetLock()
delegate to the original environment.
-
createFeedbackWithCancel
public static EnvUtils.DFFeedbackWithCancel createFeedbackWithCancel(DFFeedback feedback)
Creates a proxy implementation for givenDFFeedback
and returns its extension ofEnvUtils.DFFeedbackWithCancel
type. This adds an ability to request stop action to the original feedback instance.- Parameters:
feedback
- The original feedback- Returns:
- proxy an extension (ability to stop operation)
-
createSubTaskEnvironment
public static DFEnvironmentRO createSubTaskEnvironment(java.beans.PropertyChangeEvent evt, java.lang.String taskName)
Creates sub-environment. If it is possible to extract environment from evt (it is instance ofPropertyChangeEventWithEnv
), it is used as master for the sub-environment. Otherwise, a new cancellable environment is created.- Parameters:
evt
- the event potentially containing environmenttaskName
- name of the sub-environment- Returns:
- sub-environment
-
-