net.fenyo.gnetwatch.activities
Class Background

java.lang.Object
  extended by net.fenyo.gnetwatch.activities.Background
All Implemented Interfaces:
java.lang.Runnable

public class Background
extends java.lang.Object
implements java.lang.Runnable

This class creates queues at startup and manages them through a background thread: long active actions in a queue are interrupted after a timeout.

Version:
$Id: Background.java,v 1.27 2008/05/21 16:46:06 fenyo Exp $
Author:
Alexandre Fenyo

Field Summary
private  Config config
           
private  java.lang.Thread interrupt_thread
           
private static Log log
           
private  java.util.Map<java.lang.String,Queue> queues
           
 
Constructor Summary
Background(Config config)
          Constructor.
 
Method Summary
 void addActionQueue(Action action)
          Adds an action to a running queue.
 void createBackgroundThread()
          Starts the background thread.
 void end()
          Terminates background threads.
 java.util.Map<java.lang.String,Queue> getQueues()
          Returns the list of background queues.
 void informQueue(java.lang.String name, java.lang.Object obj)
           
 void removeActionQueue(Action action)
          Removes an action from a running queue.
 void run()
          Interrupts long actions.
 
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

config

private final Config config

interrupt_thread

private java.lang.Thread interrupt_thread

queues

private final java.util.Map<java.lang.String,Queue> queues
Constructor Detail

Background

public Background(Config config)
Constructor. main thread.

Parameters:
config - configuration.
Method Detail

informQueue

public void informQueue(java.lang.String name,
                        java.lang.Object obj)

end

public void end()
         throws java.lang.InterruptedException
Terminates background threads.

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

getQueues

public java.util.Map<java.lang.String,Queue> getQueues()
Returns the list of background queues.

Parameters:
none. -
Returns:
Map list of queues.

addActionQueue

public void addActionQueue(Action action)
                    throws GeneralException
Adds an action to a running queue.

Parameters:
action - action to add.
Throws:
GeneralException - queue does not exist.

removeActionQueue

public void removeActionQueue(Action action)
                       throws GeneralException
Removes an action from a running queue.

Parameters:
action - action to remove.
Throws:
GeneralException - queue does not exist.

createBackgroundThread

public void createBackgroundThread()
Starts the background thread.

Parameters:
none. -

run

public void run()
Interrupts long actions.

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