pt.digitalis.dif.controller
Class AbstractChAL<RequestType,ResponseType>

java.lang.Object
  extended by pt.digitalis.dif.controller.AbstractChAL<RequestType,ResponseType>
Type Parameters:
RequestType - type original request type
ResponseType - the original response type
All Implemented Interfaces:
IChAL<RequestType,ResponseType>

public abstract class AbstractChAL<RequestType,ResponseType>
extends Object
implements IChAL<RequestType,ResponseType>

Base implementation for all ChALs The API exposed to the Listener entities is the serve() method. All the communication between AbstractChAL and Listener is done through this API.

Author:
Rodrigo Gonçalves rgoncalves@digitalis.pt, Pedro Viegas pviegas@digitalis.pt
Created on:
2007/03/27

Field Summary
protected  IMessageManager messageManager
          The message manager.
 
Constructor Summary
AbstractChAL()
           
 
Method Summary
 String getChannelID()
          Get the id of the channel associated to the ChAL.
protected abstract  ClientDescriptor getClientDescriptor(RequestType originalRequest)
          Creates a client descriptor object identifying the client agent who issued the request
protected  IDIFDispatcher getDispatcher()
          Inspector of the dispatcher assigned to this channel.
protected  IDispatcherErrorHandler getErrorHandler()
          Inspector of the dispatcher assigned to this channel.
 IDIFResponse serve(RequestType originalRequest, ResponseType finalResponse, RESTAction restAction)
          This method will be called by the client via Listener.
protected abstract  boolean validateRequest(RequestType originalRequest)
          Validates the original request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface pt.digitalis.dif.controller.interfaces.IChAL
publish, translateRequest
 

Field Detail

messageManager

protected IMessageManager messageManager
The message manager.

Constructor Detail

AbstractChAL

public AbstractChAL()
Method Detail

getChannelID

public String getChannelID()
Get the id of the channel associated to the ChAL. If the id is unset the method reads the channel id from the annotation.

Returns:
the channel ID read from the Channel annotation

getClientDescriptor

protected abstract ClientDescriptor getClientDescriptor(RequestType originalRequest)
                                                 throws ControllerException
Creates a client descriptor object identifying the client agent who issued the request

Parameters:
originalRequest - the original request object
Returns:
the client descriptor for the current request
Throws:
ControllerException - when any runtime exception is thrown

getDispatcher

protected IDIFDispatcher getDispatcher()
Inspector of the dispatcher assigned to this channel.

Returns:
theDispatcher attribute

getErrorHandler

protected IDispatcherErrorHandler getErrorHandler()
Inspector of the dispatcher assigned to this channel.

Returns:
theDispatcher attribute

serve

public IDIFResponse serve(RequestType originalRequest,
                          ResponseType finalResponse,
                          RESTAction restAction)
Description copied from interface: IChAL
This method will be called by the client via Listener.

Specified by:
serve in interface IChAL<RequestType,ResponseType>
Parameters:
originalRequest - the original request object
finalResponse - the final response object
restAction - the REST action, if specified
Returns:
the processed DIFResponse
See Also:
IChAL.serve(java.lang.Object, java.lang.Object, pt.digitalis.dif.controller.objects.RESTAction)

validateRequest

protected abstract boolean validateRequest(RequestType originalRequest)
                                    throws ControllerException
Validates the original request. It can be used to check if a particular request is valid for the channel. It may also perform other validations, as the request parameters integrity.

Parameters:
originalRequest - The original request received from the client.
Returns:
T case the request is well formed, F otherwise
Throws:
ControllerException - when any runtime exception is thrown


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.