de.topicmapslab.majortom.queued.queue
Class TopicMapStoreQueue

java.lang.Object
  extended by java.lang.Thread
      extended by de.topicmapslab.majortom.queued.queue.TopicMapStoreQueue
All Implemented Interfaces:
java.lang.Runnable

public class TopicMapStoreQueue
extends java.lang.Thread

Author:
Sven Krosse

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  boolean busy
           
private  java.util.Set<IProcessingListener> listeners
           
private  java.util.Queue<IQueueTask> tasks
           
private  de.topicmapslab.majortom.model.store.ITopicMapStore topicMapStore
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TopicMapStoreQueue(de.topicmapslab.majortom.model.store.ITopicMapStore topicMapStore)
          constructor
 
Method Summary
 boolean add(IQueueTask e)
          Add the given task to internal queue
 void addProcessingListener(IProcessingListener listener)
          Register a new processing listener for the current queue instance.
 void clear()
          removes all tasks from the internal queue
 boolean isBusy()
          Checks if there is a task in progress or any tasks to do.
 void removeProcessingListener(IProcessingListener listener)
          Unregister a new processing listener for the current queue instance.
 void run()
          
 int size()
          Returns the number of tasks in the internal queue
 void start()
          
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

topicMapStore

private de.topicmapslab.majortom.model.store.ITopicMapStore topicMapStore

tasks

private java.util.Queue<IQueueTask> tasks

listeners

private java.util.Set<IProcessingListener> listeners

busy

private boolean busy
Constructor Detail

TopicMapStoreQueue

public TopicMapStoreQueue(de.topicmapslab.majortom.model.store.ITopicMapStore topicMapStore)
constructor

Parameters:
topicMapStore - the topic map store
Method Detail

start

public void start()

Overrides:
start in class java.lang.Thread

run

public void run()

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

size

public int size()
Returns the number of tasks in the internal queue

Returns:
the number of tasks

clear

public void clear()
removes all tasks from the internal queue


add

public boolean add(IQueueTask e)
Add the given task to internal queue

Parameters:
e - the new task
Returns:
true if the task could add to queue, false otherwise

addProcessingListener

public void addProcessingListener(IProcessingListener listener)
Register a new processing listener for the current queue instance. Each listener will be notified if a task was finished.

Parameters:
listener - the new listener

removeProcessingListener

public void removeProcessingListener(IProcessingListener listener)
Unregister a new processing listener for the current queue instance. Each listener will be notified if a task was finished.

Parameters:
listener - the listener to remove

isBusy

public boolean isBusy()
Checks if there is a task in progress or any tasks to do.

Returns:
true if there are any tasks to do or a task is currently in progress.