org.abstracthorizon.danube.http
Class Selector

java.lang.Object
  extended by org.abstracthorizon.danube.http.Selector
All Implemented Interfaces:
ConnectionHandler
Direct Known Subclasses:
HTTPContext

public class Selector
extends Object
implements ConnectionHandler

This class selects appropriate ConnectionHandler based on matching based on the URI from the http connection.

Author:
Daniel Sendula

Field Summary
protected  List<Matcher> components
          List of Matcher objects
protected  ConnectionHandler errorResponse
          Error response if uri hasn't been matched
 
Constructor Summary
Selector()
          Constructor
 
Method Summary
 List<Matcher> getComponents()
          Returns list of connection handlers
 ConnectionHandler getErrorResponse()
          Returns error response
 void handleConnection(Connection connection)
          Selects ConnectionHandler checking all Matcher from components list.
 void setComponents(List<Matcher> components)
          Sets list of connection handlers
 void setErrorResponse(ConnectionHandler errorResponse)
          Sets error response
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

components

protected List<Matcher> components
List of Matcher objects


errorResponse

protected ConnectionHandler errorResponse
Error response if uri hasn't been matched

Constructor Detail

Selector

public Selector()
Constructor

Method Detail

handleConnection

public void handleConnection(Connection connection)

Selects ConnectionHandler checking all Matcher from components list. If Matcher.matches(HTTPConnection) returns true then ConnectionHandler stored in Matcher is called. Depending on Matcher.isStopOnMatch() selector will proceed with rest of the list or not.

If no matches are found errorResponse is used to generate error. Default value is ErrorConnectionHandler.

Specified by:
handleConnection in interface ConnectionHandler
Parameters:
connection - http connection

setComponents

public void setComponents(List<Matcher> components)
Sets list of connection handlers

Parameters:
components - list of connection handlers

getComponents

public List<Matcher> getComponents()
Returns list of connection handlers

Returns:
list of connection handlers

getErrorResponse

public ConnectionHandler getErrorResponse()
Returns error response

Returns:
error response

setErrorResponse

public void setErrorResponse(ConnectionHandler errorResponse)
Sets error response

Parameters:
errorResponse - error response


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.