org.openqa.grid.web.servlet.handler
Class RequestHandler

java.lang.Object
  extended by org.openqa.grid.web.servlet.handler.RequestHandler
All Implemented Interfaces:
Comparable<RequestHandler>

public class RequestHandler
extends Object
implements Comparable<RequestHandler>

Base stuff to handle the request coming from a remote. Threading notes; RequestHandlers are instantiated per-request, run on the servlet container thread. The instance is also accessed by the matcher thread.


Constructor Summary
RequestHandler(SeleniumBasedRequest request, javax.servlet.http.HttpServletResponse response, Registry registry)
           
 
Method Summary
 void bindSession(TestSession session)
           
 int compareTo(RequestHandler o)
           
 String debug()
           
 boolean equals(Object obj)
           
 void forwardNewSessionRequestAndUpdateRegistry(TestSession session)
          Forward the new session request to the TestSession that has been assigned, and parse the response to extract and return the external key assigned by the remote.
protected  void forwardRequest(TestSession session, RequestHandler handler)
           
 Registry getRegistry()
           
 SeleniumBasedRequest getRequest()
          the SeleniumBasedRequest this hanlder is processing.
 javax.servlet.http.HttpServletResponse getResponse()
          the HttpServletResponse the handler is writing to.
 ExternalSessionKey getServerSession()
          return the session from the server ( = opaque handle used by the server to determine where to route session-specific commands fro mthe JSON wire protocol ).
 TestSession getSession()
           
 int hashCode()
           
 void process()
          forwards the request to the remote, allocating / releasing the resources if necessary.
protected  void setSession(TestSession session)
           
 void stop()
           
 String toString()
           
 void waitForSessionBound()
          wait for the registry to match the request with a TestSlot.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RequestHandler

public RequestHandler(SeleniumBasedRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      Registry registry)
Method Detail

forwardNewSessionRequestAndUpdateRegistry

public void forwardNewSessionRequestAndUpdateRegistry(TestSession session)
                                               throws NewSessionException
Forward the new session request to the TestSession that has been assigned, and parse the response to extract and return the external key assigned by the remote.

Throws:
NewSessionException - in case anything wrong happens during the new session process.

forwardRequest

protected void forwardRequest(TestSession session,
                              RequestHandler handler)
                       throws IOException
Throws:
IOException

process

public void process()
forwards the request to the remote, allocating / releasing the resources if necessary.


waitForSessionBound

public void waitForSessionBound()
                         throws InterruptedException,
                                TimeoutException
wait for the registry to match the request with a TestSlot.

Throws:
TimeoutException - if the request reaches the new session wait timeout before being assigned.
InterruptedException

getRequest

public SeleniumBasedRequest getRequest()
the SeleniumBasedRequest this hanlder is processing.


getResponse

public javax.servlet.http.HttpServletResponse getResponse()
the HttpServletResponse the handler is writing to.


compareTo

public int compareTo(RequestHandler o)
Specified by:
compareTo in interface Comparable<RequestHandler>

setSession

protected void setSession(TestSession session)

bindSession

public void bindSession(TestSession session)

getSession

public TestSession getSession()

getServerSession

public ExternalSessionKey getServerSession()
return the session from the server ( = opaque handle used by the server to determine where to route session-specific commands fro mthe JSON wire protocol ). will be null until the request has been processed.


stop

public void stop()

toString

public String toString()
Overrides:
toString in class Object

debug

public String debug()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getRegistry

public Registry getRegistry()


Copyright © 2012. All Rights Reserved.