|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.almendra.commons.threads.ActiveObject
public abstract class ActiveObject
Abstract active object that constantly calls doActivity()
as long as
it is active. An active object is an object that runs in its own thread. Defines
several auxiliary methods to be used by concrete subclasses.
Field Summary | |
---|---|
protected java.lang.Object |
activeLock
Lock object used to synchronize access the flag isActive . |
protected boolean |
isActive
Holds information whether active object is active or not (has been started or has been stopped). |
protected java.lang.String |
name
Name of the active object. |
protected int |
priority
Defines the priority the active object should have when started. |
protected java.lang.Thread |
thread
Thread the active object runs in. |
protected boolean |
verbose
Specifies whether the active object should write trace information to the console. |
protected boolean |
waiting
Flag that must be set to true when active object is blocked when it is waiting for input. |
Constructor Summary | |
---|---|
ActiveObject()
Creates a new ActiveObject object. |
|
ActiveObject(boolean verbose)
Creates a new ActiveObject object. |
|
ActiveObject(boolean verbose,
int priority)
Creates a new ActiveObject object. |
Method Summary | |
---|---|
protected abstract void |
doActivity()
Abstract method that is constantly called as long as active object is active. |
java.lang.String |
getName()
Answer the user-defined name of the active object. |
int |
getPriority()
|
boolean |
isActive()
Answer whether the active object has been started and is active or not. |
protected abstract boolean |
isDaemon()
Implement in subclass whether thread the active object will run in when started is a daemon thread or not. |
protected boolean |
isVerbose()
Answer whether active object is in verbose mode writing trace information to the console. |
protected void |
messageStarting()
|
protected void |
messageStopping()
|
void |
run()
Constantly calls doActivity as long as active object is active. |
protected void |
setActive(boolean isActive)
Mark the active object as active or not as indicated by isActive . |
void |
setName(java.lang.String name)
Set user-defined name of the active object. |
void |
setPriority(int priority)
Set priority of active object. |
void |
setVerbose(boolean verbose)
Set the active object to verbose mode which will cause trace information to be written to the console. |
void |
start()
Start the active object. |
void |
stop()
Stop the active object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected boolean verbose
protected transient java.lang.Thread thread
protected boolean isActive
protected java.lang.Object activeLock
isActive
.
protected int priority
protected boolean waiting
Constructor Detail |
---|
public ActiveObject()
ActiveObject
object.
public ActiveObject(boolean verbose)
ActiveObject
object.
verbose
- define whether trace information should be written to the consolepublic ActiveObject(boolean verbose, int priority)
ActiveObject
object.
verbose
- define whether trace information should be written to the consolepriority
- define priority of thread when active object is started.Method Detail |
---|
public void run()
doActivity
as long as active object is active.
run
in interface java.lang.Runnable
Runnable.run()
protected abstract void doActivity()
public java.lang.String getName()
getName
in interface INamedObject
org.almendra.commons.cas.INamedObject#getName()
public void setName(java.lang.String name)
name
- public int getPriority()
public void setPriority(int priority)
priority
- public boolean isActive()
isActive
in interface ISimpleActiveObject
public void start()
start
in interface ISimpleActiveObject
protected void messageStarting()
public void stop()
stop
in interface ISimpleActiveObject
protected void messageStopping()
protected void setActive(boolean isActive)
isActive
.
isActive
- protected abstract boolean isDaemon()
protected boolean isVerbose()
public void setVerbose(boolean verbose)
verbose
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |