Top Description Fields Constructors Methods
org.glassfish.hk2.runlevel.internal

public Class CurrentTaskFutureWrapper

extends Object
implements RunLevelFuture
Class Inheritance
All Implemented Interfaces
org.glassfish.hk2.runlevel.RunLevelFuture, java.util.concurrent.Future
Imports
java.util.concurrent.ExecutionException, .TimeUnit, .TimeoutException, org.glassfish.hk2.runlevel.RunLevelFuture

This object is used to wrap the internal CurrentTaskFuture which is a ChangeableRunLevelFuture. This way the users of the RunLevelController API will not get something that can be cast to a ChangeableRunLevelFuture
Author
jwells

Field Summary

Modifier and TypeField and Description
private final CurrentTaskFuture

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
cancel(boolean mayInterruptIfRunning)

Implements org.glassfish.hk2.runlevel.RunLevelFuture.cancel.

The cancel method attempts to cancel the current running job (if the job is not already completed or already cancelled).

public Object
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public Object
get(long timeout, TimeUnit unit)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

pack-priv CurrentTaskFuture
public int
getProposedLevel()

Implements org.glassfish.hk2.runlevel.RunLevelFuture.getProposedLevel.

This gets the level that this future job is attempting to get to

public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

public boolean
isDown()

Implements org.glassfish.hk2.runlevel.RunLevelFuture.isDown.

Returns true if this job represents the system going from a higher level to a lower level.

public boolean
isUp()

Implements org.glassfish.hk2.runlevel.RunLevelFuture.isUp.

Returns true if this job represents the system going from a lower level to a higher level.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

delegateback to summary
private final CurrentTaskFuture delegate

Constructor Detail

CurrentTaskFutureWrapperback to summary
pack-priv CurrentTaskFutureWrapper(CurrentTaskFuture delegate)

Method Detail

cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements org.glassfish.hk2.runlevel.RunLevelFuture.cancel.

Doc from org.glassfish.hk2.runlevel.RunLevelFuture.cancel.

The cancel method attempts to cancel the current running job (if the job is not already completed or already cancelled). The meaning of cancel is different depending on whether or not the system was going up to a level or coming down to a level.

If the system was going up to a level then calling cancel will cause the system to stop going up, and instead proceed back down to the last completed level. For example, suppose there were three services at level ten and the system was going up to level ten. As the system was proceeding up to level ten the first of the three services had already been started and the second service was in progress and the third service had not been started. The system will wait for the second service to complete coming up and then will shut it down along with the first service. Since the last completed level was nine, the system will remain at level nine and this job will be complete.

If the system was going down to a level then calling cancel will cause the system to continue going down, but it will stop going down at the next level. For example, suppose there were three services at level ten and the current proposed level is five. Suppose one of those three services had already been shutdown and one was in the process of being shutdown and the other had not yet been shutdown when the cancel arrives. The system will continue to shutdown the one in progress and then will shutdown the remaining service at level ten to reach level nine. However, the job will no longer attempt to go down to level five, but will instead be finished at level nine.

There is a cancel timeout value that is set. This is the amount of time the system will wait for services to complete after cancel has been called. Any services still running after this timeout will be orphaned (they will not be shutdown if they do eventually complete). Further, if an attempt is made to start the same service that is still running on another thread that request will fail.

Annotations
@Override
getback to summary
public Object get() throws InterruptedException, ExecutionException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
getback to summary
public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Annotations
@Override
Exceptions
InterruptedException:
if the current thread was interrupted while waiting
ExecutionException:
if the computation threw an exception
TimeoutException:
if the wait timed out
getDelegateback to summary
pack-priv CurrentTaskFuture getDelegate()
getProposedLevelback to summary
public int getProposedLevel()

Implements org.glassfish.hk2.runlevel.RunLevelFuture.getProposedLevel.

Doc from org.glassfish.hk2.runlevel.RunLevelFuture.getProposedLevel.

This gets the level that this future job is attempting to get to

Annotations
@Override
isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Annotations
@Override
isDownback to summary
public boolean isDown()

Implements org.glassfish.hk2.runlevel.RunLevelFuture.isDown.

Doc from org.glassfish.hk2.runlevel.RunLevelFuture.isDown.

Returns true if this job represents the system going from a higher level to a lower level. This method and isUp can both be false (for the case that proceedTo asked to go to the level it is already at) but they cannot both be true

Annotations
@Override
isUpback to summary
public boolean isUp()

Implements org.glassfish.hk2.runlevel.RunLevelFuture.isUp.

Doc from org.glassfish.hk2.runlevel.RunLevelFuture.isUp.

Returns true if this job represents the system going from a lower level to a higher level. This method and isDown can both be false (for the case that proceedTo asked to go to the level it is already at) but they cannot both be true

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override