CADI.Server.Request
Class RequestQueue

java.lang.Object
  extended by CADI.Server.Request.RequestQueue

public class RequestQueue
extends java.lang.Object

This class implements a queue where the received client requests are saved and then they are readed by the RequestDispatcher thead to be processed.

NOTE:
Implementing of different kinds of priorities is very easy. Using several queues with differents priorities and then doing the necessary changes in the add and get methods.

Usage example:
  construct
  add
  get

Version:
1.0 2007/10/26
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  java.util.ArrayList<RequestQueueNode> queue
          Contains a list of the client request.
 
Constructor Summary
RequestQueue()
          Constructor.
 
Method Summary
 void add(RequestQueueNode nodeInfo)
          Adds new client request nodes to the queue, and it notifies it to the dispatcher requests.
 RequestQueueNode get()
          Returns the first element of the queue if it isn't empty, otherwise null.
 boolean isEmpty()
          Returns true if the list is empty, false otherwise.
 void list(java.io.PrintStream out)
          Prints this Request Queue fields out to the specified output stream.
 int size()
          Returns the size of the queue.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queue

private java.util.ArrayList<RequestQueueNode> queue
Contains a list of the client request. The ArrayList is not a synchronized data list, so the class methods implement the concurrence to avoid simultaneous access.

Constructor Detail

RequestQueue

public RequestQueue()
Constructor.

Method Detail

add

public void add(RequestQueueNode nodeInfo)
Adds new client request nodes to the queue, and it notifies it to the dispatcher requests.

Parameters:
nodeInfo -

get

public RequestQueueNode get()
                     throws java.lang.InterruptedException
Returns the first element of the queue if it isn't empty, otherwise null.

Returns:
returns the first element of the queue.
Throws:
java.lang.InterruptedException

isEmpty

public boolean isEmpty()
Returns true if the list is empty, false otherwise.


size

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

Returns:
the size of the queue.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

list

public void list(java.io.PrintStream out)
Prints this Request Queue fields out to the specified output stream. This method is useful for debugging.

Parameters:
out - an output stream.


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)