Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD
 

com.newstep.solid.management.runtime
Class ManagedThread
com.newstep.solid.management.runtime.AsyncManagedExecutable
  |
  +--com.newstep.solid.management.runtime.ManagedThread
All Implemented Interfaces:
       ManagedExecutable
Direct Known Subclasses:
       SampleManagedThread

public abstract class ManagedThread      
A thread of program execution that conforms to the generic
ManagedExecutable contract for starting, stoping, suspending, resuming and
shutting down.


In order to extend the ManagedThread implementers must provide the
doRun() and doShutdown() implementations.


In a regular java.lang.Thread implementers must provide an
implementation of the run() method in which they may provide
an execution loop. This is NOT the case for ManagedThread implementations.
ManagedThread provides the basic loop for the implementer. The harness for
managing state changes and for suspending and resuming the execution is
provided by ManagedThread.

The abstractrun() method must be overriden to provide a
single interation of the loop.


e.g.




Regular java.lang.Thread implemenation
Thread {
void run() {
int state;

while(state!=idle) {
switch(state) {
case(running):
// print "I'm running"
break;
case(graceful_shutdown):
// print "I'm shuting down"
break;
case ...

}
}
}
}



ManagedThread implementation
ManagedThread {
void run() {
// print "I'm running"
}

boolean gracefulShutdown() {
// print "I'm shuting down"
// indicates that the thread has completed graceful shutdown
return true;
}
}

Abstract.
 
Links:
Kernel Association Association Link
to Class ManagedInnerThread
Associates type:
association
Client cardinality:
1
Client navigability:
NOT NAVIGABLE
Client visibility:
private
Supplier cardinality:
1
Supplier navigability:
NAVIGABLE
Supplier visibility:
protected
 
Generalization Generalization Link
to Class AsyncManagedExecutable
A thread of program execution that conforms to the generic
ManagedExecutable contract for starting, stoping, suspending, resuming and
shutting down.


In order to extend the ManagedThread implementers must provide the
doRun() and doShutdown() implementations.


In a regular java.lang.Thread implementers must provide an
implementation of the run() method in which they may provide
an execution loop. This is NOT the case for ManagedThread implementations.
ManagedThread provides the basic loop for the implementer. The harness for
managing state changes and for suspending and resuming the execution is
provided by ManagedThread.

The abstractrun() method must be overriden to provide a
single interation of the loop.


e.g.




Regular java.lang.Thread implemenation
Thread {
void run() {
int state;

while(state!=idle) {
switch(state) {
case(running):
// print "I'm running"
break;
case(graceful_shutdown):
// print "I'm shuting down"
break;
case ...

}
}
}
}



ManagedThread implementation
ManagedThread {
void run() {
// print "I'm running"
}

boolean gracefulShutdown() {
// print "I'm shuting down"
// indicates that the thread has completed graceful shutdown
return true;
}
}

 
 

Nested Class Summary
public class
Field Summary
protected final static String
private Semaphore
protected static Logger
protected ManagedThread
Constructor Summary
public void
public void
Method Summary
protected void
protected void
protected void
protected void
protected void
protected void
protected abstract boolean
public void
run()
protected abstract void
run()
Field Detail
className
protected final static String className
Final.
Multiplicity:
1
Static.
 

innerThread
protected ManagedThread.ManagedInnerThread innerThread
Multiplicity:
1
 

lock
private Semaphore lock
Multiplicity:
1
 

logger
protected static Logger logger
Multiplicity:
1
Static.
 
Constructor Detail
ManagedThread
public void ManagedThread ()
 
Initializes the logger and construct an associated inner thread
Stereotype:
create
 
Method Detail
doResume
protected void doResume ()
 
wakes up the ManagedThread allowing it to transition back to the RUNNING
state
 

doShutdown
protected void doShutdown ()
 
starts the process of graceful shutdown.
 

doStart
protected void doStart ()
 
starts the thread execution
Throws:
ExecutableException
 

doStop
protected void doStop ()
 
terminates the thread execution. Once a ManagedThread has been
stopped it may not be restarted.
 

doSuspend
protected void doSuspend ()
 
no extra action is taken by doSuspend during the suspension process
 

execute
protected void execute ()
 
provides the basic execution harness based on the current Thread state.
This function provides the basic mechanism for suspending the thread and
invoking the appropriate execution fuction run() or
gracefulShutdown().
Throws:
ExecutableException
 

gracefulShutdown
protected abstract boolean gracefulShutdown ()
 
Overriden to provide a single iteration of the graceful shutdown process.
The function should return whether or not the graceful shutdown process
has completed.
Return:
true if the thread has completed its graceful shutdown,
false if more iterations are required to complete graceful shutdown
Abstract.
 

run
protected abstract void run ()
 
Overriden to provide a single iteration of the running process
loop. Since the ManagedThread provides the execution harness,
implementations of run() don't need to implement the
execution loop, just a single interation.
Abstract.
 

Class
Tree
          
SUMMARY: INNER | FIELD | CONSTR | METHODDETAIL: FIELD | CONSTR | METHOD