public abstract class ProgressStatusBase extends Object implements ProgressStatus, Serializable
ProgressStatus
.Modifier and Type | Class and Description |
---|---|
static class |
ProgressStatusBase.ChildProgressStatus |
Modifier and Type | Field and Description |
---|---|
protected Set<ProgressStatusBase.ChildProgressStatus> |
children |
protected boolean |
completed |
protected int |
currentStepCount |
protected String |
id |
protected String |
name |
protected ProgressStatusBase |
parent |
protected int |
totalStepCount |
Modifier | Constructor and Description |
---|---|
protected |
ProgressStatusBase(ProgressStatusBase parent,
String id)
Construct unnamed
ProgressStatus |
protected |
ProgressStatusBase(String name,
int totalStepCount,
ProgressStatusBase parent,
String id)
Construct named
ProgressStatus with defined expected count
of steps. |
protected |
ProgressStatusBase(String name,
ProgressStatusBase parent,
String id)
Construct named
ProgressStatus . |
Modifier and Type | Method and Description |
---|---|
protected void |
allocateStapsForChildProcess(int allocatedSteps) |
void |
complete()
Indicates the command is complete and no further progress status will
be delivered.
|
void |
complete(String message)
Indicates the command is complete and no further progress status will
be delivered.
|
protected boolean |
completeSilently()
Complete this
ProgressStatus and all sub-ProgressStatuses
but does not fire event to parent statuses. |
float |
computeCompletePortion() |
protected float |
computeCompleteSteps() |
int |
computeSumSteps() |
ProgressStatus |
createChild(int allocatedSteps)
Create a child ProgressStatus object which can be used independently by
a command's subroutine or sub-commands.
|
ProgressStatus |
createChild(String name,
int allocatedSteps)
Create a child ProgressStatus object which can be used independently by
a command's subroutine or sub-commands.
|
ProgressStatus |
createChild(String name,
int allocatedSteps,
int totalStepCount) |
protected abstract ProgressStatusBase |
doCreateChild(String name,
int totalStepCount) |
protected ProgressStatusBase |
findById(String id)
Recursive search for child by id.
|
protected void |
fireEvent(ProgressStatusEvent event)
Fires
ProgressStatusEvent to parent. |
Set<ProgressStatusBase.ChildProgressStatus> |
getChildProgressStatuses() |
Collection<ProgressStatusBase> |
getChildren() |
int |
getCurrentStepCount() |
String |
getId()
Id is unique for any ProgressStatuses.
|
String |
getName() |
ProgressStatusBase |
getParrent() |
int |
getRemainingStepCount()
Remaining count of steps to complete this progress.
totalStepCount - currentStepCount - allocated step count |
int |
getTotalStepCount()
Total step count.
|
boolean |
isComplete()
Returns true if the
ProgressStatus has been marked as complete
via the complete() method. |
void |
progress(int steps)
Indicate progress occurred.
|
void |
progress(int steps,
String message)
Indicates progress occurred.
|
void |
progress(int steps,
String message,
boolean spinner)
Indicates progress occurred.
|
void |
progress(String message)
Indicate progress occurred.
|
void |
setCurrentStepCount(int stepCount)
This allows the current step count to be changed to a specific value,
for example when an error occurs and the command must repeat a set
of operations.
This will likely result in the overall completion percentage jumping when the next progress() message is generated. |
void |
setTotalStepCount(int totalStepCount)
Number of steps necessary to complete the operation.
|
String |
toString() |
protected String name
protected String id
protected int totalStepCount
protected int currentStepCount
protected ProgressStatusBase parent
protected boolean completed
protected Set<ProgressStatusBase.ChildProgressStatus> children
protected ProgressStatusBase(ProgressStatusBase parent, String id)
ProgressStatus
parent
- Parent ProgressStatus
id
- Is useful for event transferprotected ProgressStatusBase(String name, ProgressStatusBase parent, String id)
ProgressStatus
.name
- of the ProgressStatus
implementation is used
to identify source of progress messages.parent
- Parent ProgressStatus
id
- Is useful for event transferprotected ProgressStatusBase(String name, int totalStepCount, ProgressStatusBase parent, String id)
ProgressStatus
with defined expected count
of steps.name
- of the ProgressStatus
implementation is used
to identify source of progress messages.totalStepCount
- How many steps are expected in this
ProgressStatus
parent
- Parent ProgressStatus
id
- Is useful for event transferprotected void fireEvent(ProgressStatusEvent event)
ProgressStatusEvent
to parent.public void setTotalStepCount(int totalStepCount)
ProgressStatus
org.glassfish.api.Progress
annotation.
The total step count is used as the denominator for computing the
completion percentage as reported in the command's progress output:
percent complete = current step count / total step count * 100
Note the above formula is a bit more complex when child ProgressStatus
objects are in use.
The total step count can be changed after being set but may result in the completion percentage jumping (forward or backwards).
If the total step count is not set then a completion percentage will not be available.
It can be also set during injection using totalStepCount
parameter in org.glassfish.api.Progress
annotation.
setTotalStepCount
in interface ProgressStatus
totalStepCount
- non-negative value defines denominator for
the percentage computationpublic int getTotalStepCount()
ProgressStatus
getTotalStepCount
in interface ProgressStatus
public int getRemainingStepCount()
ProgressStatus
totalStepCount - currentStepCount - allocated step count
getRemainingStepCount
in interface ProgressStatus
public void progress(int steps, String message, boolean spinner)
ProgressStatus
progress
in interface ProgressStatus
steps
- the number of steps taken. Negative steps will reduce
the completion percentage. Never to non-negative value.message
- to be displayed by the client.spinner
- true
starts showing the spinner. It will be
active until next progress.public void progress(int steps, String message)
ProgressStatus
progress
in interface ProgressStatus
steps
- the number of steps taken. Negative steps will reduce
the completion percentage. Never to non-negative value.message
- to be displayed by the client.public void progress(int steps)
ProgressStatus
progress
in interface ProgressStatus
steps
- the number of steps taken. Negative steps will reduce
the completion percentage. Never to non-negative value.public void progress(String message)
ProgressStatus
progress
in interface ProgressStatus
message
- to be displayed by the client.public void setCurrentStepCount(int stepCount)
ProgressStatus
setCurrentStepCount
in interface ProgressStatus
stepCount
- new stepCount
value. Negative is normalized to 0
greater than the total step count is normalized to the total step
countpublic void complete(String message)
ProgressStatus
complete()
on all child ProgressStatus objects.
If this method is not invoked prior to the command completing the CLI
framework will implicitly invoke complete()
for the ProgressStatus
associated with the command.complete
in interface ProgressStatus
message
- to be displayed to the user.protected boolean completeSilently()
ProgressStatus
and all sub-ProgressStatuses
but does not fire event to parent statuses.public void complete()
ProgressStatus
complete()
on all child ProgressStatus objects.
If this method is not invoked prior to the command completing the CLI
framework will implicitly invoke complete()
for the ProgressStatus
associated with the command.complete
in interface ProgressStatus
public boolean isComplete()
ProgressStatus
ProgressStatus
has been marked as complete
via the complete()
method.isComplete
in interface ProgressStatus
protected abstract ProgressStatusBase doCreateChild(String name, int totalStepCount)
protected void allocateStapsForChildProcess(int allocatedSteps)
public ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount)
public ProgressStatus createChild(String name, int allocatedSteps)
ProgressStatus
80%: [parent name:[child name: message]]
The allocatedSteps parameter represents the subset of steps from the parent's allocation that will be given to the child to complete. When the child has completed all its steps it will have progressed the parent's allocated steps.
Example: Suppose the parent sets its TotalStepCount to 100 and
allocates 25 steps to a child.
The child sets its TotalStepCount to 100. Then for every 4 steps
the child progresses it will move the parent's progress 1 step given
the parent only allocated a total of 25 steps to the child but the child
has a total step count of 100: 100/25 = 4
child steps are
equivalent to 1 parent step.
Note: care must be taken when allocating steps to children. The number
of steps allocated to all children of the parent must not exceed the
parent's total step count. Doing so may results in erroneous
completion percentages.
createChild
in interface ProgressStatus
name
- to be associated with the child ProgressStatus. This name
appears in the progress sent to the client. If the name is an
empty string a name for this child will not be included in the
message.allocatedSteps
- the number of progress steps the parent is
allocating to the child.public ProgressStatus createChild(int allocatedSteps)
ProgressStatus
80%: [parent name: message]
createChild
in interface ProgressStatus
allocatedSteps
- the number of progress steps the parent is
allocating to the child.public int getCurrentStepCount()
protected float computeCompleteSteps()
public float computeCompletePortion()
public int computeSumSteps()
public Collection<ProgressStatusBase> getChildren()
public Set<ProgressStatusBase.ChildProgressStatus> getChildProgressStatuses()
public String getId()
ProgressStatus
getId
in interface ProgressStatus
public String getName()
public ProgressStatusBase getParrent()
protected ProgressStatusBase findById(String id)
Copyright © 2019. All rights reserved.