net.fenyo.gnetwatch.activities
Class Queue

java.lang.Object
  extended by net.fenyo.gnetwatch.GUI.VisualElement
      extended by net.fenyo.gnetwatch.activities.Queue
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
DebugQueue, FloodQueue, GenericProcessQueue, GenericSrcQueue, HTTPQueue, MergeQueue, NmapQueue, PingQueue, SNMPQueue

public abstract class Queue
extends VisualElement
implements java.lang.Runnable

Queue is the base class for any queue. It implements the main queueing process.

Version:
$Id: Queue.java,v 1.27 2008/04/28 23:00:57 fenyo Exp $
Author:
Alexandre Fenyo

Field Summary
private  java.util.List<Action> actions
           
private  java.util.Vector<Action> actions_copy
           
private  Config config
           
private  Action current_action
           
private static Log log
           
private  long max_time
           
private  java.lang.String name
           
private  java.lang.Thread thread
           
 
Constructor Summary
protected Queue(java.lang.String name, Config config)
          Constructor.
 
Method Summary
 void addAction(Action action)
          Adds a new action to this queue.
 void end()
          Stops this queue thread.
protected abstract  int getActionDelay()
          Returns the time to wait between two actions.
protected  Config getConfig()
           
protected abstract  int getCycleDelay()
          Returns the time to wait after each cycle.
protected abstract  int getEmptyCycleDelay()
          Returns the time to wait between empty cycles.
 void inform(java.lang.Object obj)
           
protected  void informCycle()
          Called after each cycle.
protected  void initialize(GUI gui)
          Sets the current GUI instance.
 void interrupt(Action.InterruptCause cause)
          Stops this queue thread.
 boolean isExhausted()
          Checks that the timeout occured.
 void removeAction(Action action)
          Removes an action from this queue.
 void removeVisualElements(VisualElement visual_parent)
          Detaches this queue from the selected parent.
 void run()
          Loops among the actions currently in this queue.
 int size()
          Returns the size of the queue.
 
Methods inherited from class net.fenyo.gnetwatch.GUI.VisualElement
addParent, canManageThisChild, contains, disposed, duplicateTreeItemOnce, expandTreeItems, getAllParents, getChildren, getDescription, getGUI, getId, getItem, getParents, getProgress, getSubElements, getSubElements, getTreeItems, getType, informSelected, isDisposed, isThisOurTreeItem, selected, setChildren, setDescription, setGUI, setId, setImage, setImageExec, setImageFolder, setImageHost, setImageHost6, setImageHost6SNMP, setImageHostSNMP, setImageInterface, setImageMultiRow, setImageNetwork, setImageOscillo, setImageQueue, setImageWatch, setItem, setParent, setParent, setProgress, setType, unselected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static Log log

name

private final java.lang.String name

config

private final Config config

thread

private final java.lang.Thread thread

max_time

private long max_time

actions

private final java.util.List<Action> actions

actions_copy

private java.util.Vector<Action> actions_copy

current_action

private Action current_action
Constructor Detail

Queue

protected Queue(java.lang.String name,
                Config config)
Constructor.

Parameters:
name - queue name.
config - configuration.
Method Detail

initialize

protected final void initialize(GUI gui)
Sets the current GUI instance.

Overrides:
initialize in class VisualElement
Parameters:
GUI - current GUI instance.

size

public int size()
Returns the size of the queue.

Parameters:
none. -
Returns:
int size.

addAction

public void addAction(Action action)
Adds a new action to this queue.

Parameters:
action - new action to add.

removeAction

public void removeAction(Action action)
Removes an action from this queue.

Parameters:
action - action to remove.

informCycle

protected void informCycle()
Called after each cycle.

Parameters:
none. -

inform

public void inform(java.lang.Object obj)

getCycleDelay

protected abstract int getCycleDelay()
Returns the time to wait after each cycle.

Parameters:
none. -
Returns:
int time to wait.

getEmptyCycleDelay

protected abstract int getEmptyCycleDelay()
Returns the time to wait between empty cycles.

Parameters:
none. -
Returns:
time to wait.

getActionDelay

protected abstract int getActionDelay()
Returns the time to wait between two actions.

Parameters:
none. -
Returns:
time to wait.

run

public void run()
Loops among the actions currently in this queue.

Specified by:
run in interface java.lang.Runnable
Parameters:
none. -

isExhausted

public boolean isExhausted()
Checks that the timeout occured.

Parameters:
none. -
Returns:
boolean true if timeout occured.

end

public void end()
         throws java.lang.InterruptedException
Stops this queue thread.

Parameters:
none. -
Throws:
java.lang.InterruptedException - exception.

interrupt

public void interrupt(Action.InterruptCause cause)
               throws java.io.IOException
Stops this queue thread.

Parameters:
cause - cause.
Throws:
java.lang.InterruptedException - exception.
java.io.IOException

removeVisualElements

public void removeVisualElements(VisualElement visual_parent)
Detaches this queue from the selected parent.

Overrides:
removeVisualElements in class VisualElement
Parameters:
visual_parent - selected parent.

getConfig

protected Config getConfig()