com.veriplace.web.spring
Class VeriplaceInterceptor

java.lang.Object
  extended by org.springframework.web.servlet.handler.HandlerInterceptorAdapter
      extended by com.veriplace.web.spring.VeriplaceInterceptor
All Implemented Interfaces:
HandlerExceptionResolver, HandlerInterceptor
Direct Known Subclasses:
LocationDiscoveryInterceptor, UserDiscoveryInterceptor

public class VeriplaceInterceptor
extends HandlerInterceptorAdapter
implements HandlerExceptionResolver

Base class for Veriplace-defined Spring Interceptors. Holds a reference to a Veriplace instance, and uses it to obtain a VeriplaceState for each request. Your controller can get the VeriplaceState object by calling VeriplaceState.getFromRequest(HttpServletRequest). After the controller executes, the interceptor also adds the VeriplaceState as a model object, using the name defined by the current StatusHandler's AbstractStatusViewRenderer.getStateAttributeName().

Besides being a base class for the other Interceptors, this class can be used by itself if you need to provide a VeriplaceState to a controller, but do not need to do location/user discovery ahead of time.


Field Summary
protected  Veriplace veriplace
           
 
Constructor Summary
VeriplaceInterceptor()
           
 
Method Summary
 Veriplace getVeriplace()
           
protected  Client getVeriplaceClient(HttpServletRequest request)
          Override this method if you might need to use a different Veriplace Client for some requests -- for instance, if the same interceptor is handling requests for more than one Veriplace application, each with its own consumer key and token.
protected  boolean handleInternal(VeriplaceState state, HttpServletRequest request, HttpServletResponse response)
          Override this method to do any necessary preprocessing of the request based on the corresponding VeriplaceState.
 void postHandle(HttpServletRequest request, HttpServletResponse response, java.lang.Object handler, ModelAndView mv)
           
 boolean preHandle(HttpServletRequest request, HttpServletResponse response, java.lang.Object handler)
           
 ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
          Handle RespondedExceptions by doing nothing.
 void setVeriplace(Veriplace veriplace)
          Specifies the Veriplace instance this interceptor will use.
 
Methods inherited from class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
afterCompletion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

veriplace

protected Veriplace veriplace
Constructor Detail

VeriplaceInterceptor

public VeriplaceInterceptor()
Method Detail

getVeriplace

public Veriplace getVeriplace()

setVeriplace

public void setVeriplace(Veriplace veriplace)
Specifies the Veriplace instance this interceptor will use.


postHandle

public void postHandle(HttpServletRequest request,
                       HttpServletResponse response,
                       java.lang.Object handler,
                       ModelAndView mv)
                throws java.lang.Exception
Specified by:
postHandle in interface HandlerInterceptor
Overrides:
postHandle in class HandlerInterceptorAdapter
Throws:
java.lang.Exception

preHandle

public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         java.lang.Object handler)
                  throws java.lang.Exception
Specified by:
preHandle in interface HandlerInterceptor
Overrides:
preHandle in class HandlerInterceptorAdapter
Throws:
java.lang.Exception

getVeriplaceClient

protected Client getVeriplaceClient(HttpServletRequest request)
                             throws ServletException,
                                    java.io.IOException
Override this method if you might need to use a different Veriplace Client for some requests -- for instance, if the same interceptor is handling requests for more than one Veriplace application, each with its own consumer key and token. A Client is a fairly lightweight object, so it's acceptable to create a new one for each request if you want to.

Throws:
ServletException
java.io.IOException

handleInternal

protected boolean handleInternal(VeriplaceState state,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
                          throws java.lang.Exception
Override this method to do any necessary preprocessing of the request based on the corresponding VeriplaceState.

Returns:
true if the request can be passed on to the regular handler; false if we have already handled the request (e.g. redirected it).
Throws:
java.lang.Exception

resolveException

public ModelAndView resolveException(HttpServletRequest request,
                                     HttpServletResponse response,
                                     java.lang.Object handler,
                                     java.lang.Exception ex)
Handle RespondedExceptions by doing nothing.

Specified by:
resolveException in interface HandlerExceptionResolver