net.sf.j2ep
Class ServerChain

java.lang.Object
  extended by net.sf.j2ep.ServerChain

public class ServerChain
extends java.lang.Object

A ServerChain is a list of server considered in order. The first server with a rule that successfully matches tops the evaluation of servers This is only a slightly modified version of the RuleChain used with the balancer webapp shipped with tomcat.

Author:
Anders Nyman, Yoav Shapira

Constructor Summary
ServerChain(java.util.List serverContainers)
          Constructor.
 
Method Summary
 void addServer(Server theServer)
          Adds a server to evaluate.
 Server evaluate(HttpServletRequest request)
          Evaluates the given request to see if any of the rules matches.
protected  java.util.Iterator getServerIterator()
          Returns an iterator over the list of servers to evaluate.
 Server getServerMapped(java.lang.String location)
          Finds a server with the full path specified by the location sent in.
protected  java.util.List getServers()
          Returns the list of servers to evaluate.
 java.lang.String toString()
          Returns a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerChain

public ServerChain(java.util.List serverContainers)
Constructor.

Method Detail

getServers

protected java.util.List getServers()
Returns the list of servers to evaluate.

Returns:
The servers

getServerIterator

protected java.util.Iterator getServerIterator()
Returns an iterator over the list of servers to evaluate.

Returns:
The iterator

addServer

public void addServer(Server theServer)
Adds a server to evaluate.

Parameters:
theServer - The server to add

evaluate

public Server evaluate(HttpServletRequest request)
Evaluates the given request to see if any of the rules matches. Returns the the server linked to the first matching rule.

Parameters:
request - The request
Returns:
The first matching server, null if no rule matched the request
See Also:
Rule.matches(HttpServletRequest)

getServerMapped

public Server getServerMapped(java.lang.String location)
Finds a server with the full path specified by the location sent in. This is used when we want to find a server that can handle a request.

Parameters:
location - The location we want a server for.
Returns:
The matching server, if no server is found null is returned
See Also:
ServerContainer.getServerMapped(String)

toString

public java.lang.String toString()
Returns a String representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation