visad
Class ActionImpl
- java.lang.Object
-
- visad.ActionImpl
-
- All Implemented Interfaces:
- java.lang.Runnable, java.util.EventListener, Action, ThingChangedListener
- Direct Known Subclasses:
- CellImpl, DisplayImpl, FormulaVar
public abstract class ActionImpl extends java.lang.Object implements Action, java.lang.Runnable
ActionImpl is the abstract superclass for runnable threads that need to be notified when ThingReference objects change.ActionImpl is the superclass of DisplayImpl and CellImpl.
ActionImpl is not Serializable and should not be copied between JVMs.
-
-
Field Summary
Fields Modifier and Type Field and Description static booleanTRACE_STACKstatic booleanTRACE_TIMEIndicates whether we print out the trace from where an action is invoked and print its run time
-
Constructor Summary
Constructors Constructor and Description ActionImpl(java.lang.String name)construct an ActionImpl
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidaddReference(ThingReference ref)Creates a link to a ThingReference.booleancheckTicks()voiddisableAction()disable activity in this ActionImpl and if necessary wait for end of current doAction() callabstract voiddoAction()abstract method that implements activity of this ActionImplvoidenableAction()enable activity in this ActionImpl and trigger any pending activityReferenceActionLinkfindReference(ThingReference ref)Returns the link associated with a ThingReference.java.lang.ThreadgetCurrentActionThread()return Thread currently active in run() method of this ActionImpl, or null is run() is not activejava.util.VectorgetLinks()java.lang.StringgetName()static intgetTaskCount()return the number of tasks in the threadpool queuestatic voidprintPool()voidremoveAllReferences()delete all links to ThingReferencesvoidremoveReference(ThingReference ref)Removes a link to a ThingReference.voidrun()invoked by a Thread from the ThreadPool whenever there is a request for activity in this ActionImplbooleansetEnabled(boolean enable)Set the "enabled" state of this action.voidsetName(java.lang.String name)change the name of this Actionstatic voidsetThreadPoolMaximum(int num)increase the maximum number of Threads allowed in the ThreadPoolvoidstop()stop activity in this ActionImplstatic voidstopThreadPool()destroy all threads after they've drained the job queuebooleanthingChanged(ThingChangedEvent e)a linked ThingReference has changed, requesting activity in this ActionImplvoidwaitForTasks()wait for all queued tasks in ThreadPool to finish
-
-
-
Field Detail
-
TRACE_TIME
public static final boolean TRACE_TIME
Indicates whether we print out the trace from where an action is invoked and print its run time
-
TRACE_STACK
public static final boolean TRACE_STACK
-
-
Constructor Detail
-
ActionImpl
public ActionImpl(java.lang.String name)
construct an ActionImpl- Parameters:
name- - String name, used only for debugging
-
-
Method Detail
-
getTaskCount
public static int getTaskCount()
return the number of tasks in the threadpool queue- Returns:
- number of queued and active tasks
-
printPool
public static void printPool()
-
stopThreadPool
public static void stopThreadPool()
destroy all threads after they've drained the job queue
-
setThreadPoolMaximum
public static void setThreadPoolMaximum(int num) throws java.lang.Exceptionincrease the maximum number of Threads allowed in the ThreadPool- Parameters:
num- - new maximum number of Threads in ThreadPool- Throws:
java.lang.Exception- - num is less than previous maximum
-
stop
public void stop()
stop activity in this ActionImpl
-
checkTicks
public boolean checkTicks()
- Returns:
- boolean that is disjunction (or) of flags saved in setTicks() calls to each linked ReferenceActionLink
-
enableAction
public void enableAction()
enable activity in this ActionImpl and trigger any pending activity
-
disableAction
public void disableAction()
disable activity in this ActionImpl and if necessary wait for end of current doAction() call
-
setEnabled
public boolean setEnabled(boolean enable)
Set the "enabled" state of this action. This may be used in code like the following to ensure that the action has the same "enabled" state on leaving the code as it did on entering it:ActionImpl action = ...; boolean wasEnabled = action.setEnabled(false); ... action.setEnabled(wasEnabled);- Parameters:
enable- The new "enabled" state for this action.- Returns:
- The previous "enabled" state of this action.
-
getCurrentActionThread
public java.lang.Thread getCurrentActionThread()
return Thread currently active in run() method of this ActionImpl, or null is run() is not active- Returns:
- currently active thread or null
-
run
public void run()
invoked by a Thread from the ThreadPool whenever there is a request for activity in this ActionImpl- Specified by:
runin interfacejava.lang.Runnable
-
doAction
public abstract void doAction() throws VisADException, java.rmi.RemoteExceptionabstract method that implements activity of this ActionImpl- Throws:
VisADException- a VisAD error occurredjava.rmi.RemoteException- an RMI error occurred
-
thingChanged
public boolean thingChanged(ThingChangedEvent e) throws VisADException, java.rmi.RemoteException
a linked ThingReference has changed, requesting activity in this ActionImpl- Specified by:
thingChangedin interfaceThingChangedListener- Parameters:
e- ThingChangedEvent for change to ThingReference- Returns:
- true if the ThingReference changed
- Throws:
VisADException- a VisAD error occurredjava.rmi.RemoteException- an RMI error occurred
-
waitForTasks
public void waitForTasks()
wait for all queued tasks in ThreadPool to finish
-
addReference
public void addReference(ThingReference ref) throws ReferenceException, RemoteVisADException, VisADException, java.rmi.RemoteException
Creates a link to a ThingReference. Note that this method causes this object to register itself with the ThingReference.- Specified by:
addReferencein interfaceAction- Parameters:
ref- The ThingReference to which to create the link. Subsequent invocation ofthingChanged(ThingChangedEvent)causes invocation ofref.acknowledgeThingChanged(this). This method invokesref.addThingChangedListener(this, ...).- Throws:
RemoteVisADException- if the reference isn't aThingReferenceImpl.ReferenceException- if the reference has already been added.VisADException- if a VisAD failure occurs.java.rmi.RemoteException- if a Java RMI failure occurs.- See Also:
thingChanged(ThingChangedEvent),ThingReference.addThingChangedListener(ThingChangedListener, long)
-
removeReference
public void removeReference(ThingReference ref) throws VisADException, java.rmi.RemoteException
Removes a link to a ThingReference.
This implementation invokes
findReference(ThingReference).- Specified by:
removeReferencein interfaceAction- Parameters:
ref- The reference to be removed.- Throws:
RemoteVisADException- if the reference isn't aThingReferenceImpl.ReferenceException- if the reference isn't a part of this instance.VisADException- if a VisAD failure occurs.java.rmi.RemoteException- if a Java RMI failure occurs.
-
removeAllReferences
public void removeAllReferences() throws VisADException, java.rmi.RemoteExceptiondelete all links to ThingReferences- Specified by:
removeAllReferencesin interfaceAction- Throws:
java.rmi.RemoteExceptionVisADException
-
findReference
public ReferenceActionLink findReference(ThingReference ref) throws VisADException
Returns the link associated with a ThingReference.- Parameters:
ref- The reference to find.- Returns:
- The link associated with the reference.
- Throws:
ReferenceException- if the argument isnull.VisADException- if the argument isnull.
-
getLinks
public java.util.Vector getLinks()
- Returns:
- Vector of linked ReferenceActionLinks
-
getName
public java.lang.String getName()
-
setName
public void setName(java.lang.String name)
change the name of this Action- Parameters:
name- new String name
-
-
DMelt 3.0 © DataMelt by jWork.ORG