org.deegree_impl.services.wfs
Class Dispatcher_Impl

java.lang.Object
  extended byorg.deegree_impl.services.AbstractHandler
      extended byorg.deegree_impl.services.wfs.Dispatcher_Impl
All Implemented Interfaces:
Dispatcher, java.util.EventListener, Handler

public final class Dispatcher_Impl
extends AbstractHandler
implements Dispatcher

The dispatcher acts as source of events to inform registered WFSResponseListener as well as a reciever of requests that have to be performed by one of the registered DataStores (also definied as WFSRequestListener).

The class works as follows: When the first request is pushed to the dispatcher to loops are started that ckecks continously in defined time intervals (frequency) if new request and/or responses are present for processing. If so the request/response is take from the container it has been pushed to and will be deligated to the class that's responsible for its processing.

If for a defined time interval (timeout) no request/response has been pushed to the dispatcher the processing loops will be stopped. This also happens if a thread based exception will be throwen during the request/response processing.

-----------------------------------------------------

Version:
$Revision: 1.9 $ $Date: 2004/03/05 07:42:15 $

Author:
Andreas Poth

Nested Class Summary
private  class Dispatcher_Impl.RequestLoop
          inner class for processing requests
private  class Dispatcher_Impl.ResponseLoop
          inner class for processing WFS responses to requests
 
Nested classes inherited from class org.deegree_impl.services.AbstractHandler
AbstractHandler.Loop
 
Field Summary
protected  java.util.Map reqControl
           
protected  AbstractHandler.Loop reqThread
           
protected  java.util.List requests
          container for requests to be performed
protected  java.util.List responses
          container for responses to request that has be performed
protected  AbstractHandler.Loop resThread
           
 
Fields inherited from class org.deegree_impl.services.AbstractHandler
handlerList, inProgressList, loopFrequency, loopTimeout, requestList, responseList, responseTimeout, timestamp
 
Constructor Summary
Dispatcher_Impl()
           
 
Method Summary
protected  OGCWebServiceRequest getNextRequest()
          returns the next request to be processed.
protected  OGCWebServiceResponse getNextResponse()
          returns the next response to be processed.
 void handleRequest(OGCWebServiceEvent event)
          recieves a request that should be performed by the Dispatcher.
 void handleResponse(OGCWebServiceEvent event)
          recieves the response to a request that been performed by the Dispatcher.The Dispatcher will analyse the response and notify the responsible methods/classes.
 boolean isInterested(OGCWebServiceEvent event)
          returns true if the handler is interested in a event
private  void performOGCWebServiceException(java.lang.String message, java.lang.String location)
          creates an exception that should be used instead of a response if the performing of a request failed.
protected  void process()
          this method is called within the loop.
protected  void startProcessingRequests()
          starts the loop for processing requests and responses
protected  void startProcessingResponses()
          starts the loop for processing requests and responses
 void stopLoops()
          stops the processing loop(s)
 
Methods inherited from class org.deegree_impl.services.AbstractHandler
dispose, fireRequest, fireResponse, registerHandler, removeHandler, setLoopFrequency, setLoopTimeout, setResponseTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deegree.services.Handler
registerHandler, removeHandler
 

Field Detail

reqControl

protected java.util.Map reqControl

requests

protected java.util.List requests
container for requests to be performed


responses

protected java.util.List responses
container for responses to request that has be performed


reqThread

protected AbstractHandler.Loop reqThread

resThread

protected AbstractHandler.Loop resThread
Constructor Detail

Dispatcher_Impl

public Dispatcher_Impl()
Method Detail

handleRequest

public void handleRequest(OGCWebServiceEvent event)
recieves a request that should be performed by the Dispatcher. The Dispatcher will analyse the request and notify the responsible methods/classes.

Specified by:
handleRequest in interface Handler

handleResponse

public void handleResponse(OGCWebServiceEvent event)
recieves the response to a request that been performed by the Dispatcher.The Dispatcher will analyse the response and notify the responsible methods/classes.

Specified by:
handleResponse in interface Handler

isInterested

public boolean isInterested(OGCWebServiceEvent event)
returns true if the handler is interested in a event

Specified by:
isInterested in interface Handler

startProcessingRequests

protected void startProcessingRequests()
starts the loop for processing requests and responses


startProcessingResponses

protected void startProcessingResponses()
starts the loop for processing requests and responses


stopLoops

public void stopLoops()
stops the processing loop(s)

Specified by:
stopLoops in class AbstractHandler

getNextRequest

protected OGCWebServiceRequest getNextRequest()
returns the next request to be processed. This is the request that has been waiting the longest time.


getNextResponse

protected OGCWebServiceResponse getNextResponse()
returns the next response to be processed. This is the response that has been waiting the longest time.


performOGCWebServiceException

private void performOGCWebServiceException(java.lang.String message,
                                           java.lang.String location)
creates an exception that should be used instead of a response if the performing of a request failed.


process

protected void process()
this method is called within the loop. An extending class have to implement this method.