org.szegedi.spring.web.jsflow
Class OpenContextInViewInterceptor

java.lang.Object
  extended by org.szegedi.spring.web.jsflow.OpenContextInViewInterceptor
All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor

public class OpenContextInViewInterceptor
extends java.lang.Object
implements org.springframework.web.servlet.HandlerInterceptor

A Spring handler interceptor that opens a Rhino context and associates it with the current thread for the complete duration of the handling, including view rendering. In most situations, you will not need a live Rhino Context object during view rendering, so you need not use this interceptor. However, if you receive an exception saying there is no current Rhino context during view rendering, you will need to use the interceptor.

Version:
$Id: OpenContextInViewInterceptor.java 104 2009-12-01 18:44:14Z szegedia $
Author:
Attila Szegedi

Constructor Summary
OpenContextInViewInterceptor()
           
 
Method Summary
 void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)
           
 void postHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, org.springframework.web.servlet.ModelAndView modelAndView)
           
 boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)
           
 void setContextFactory(org.mozilla.javascript.ContextFactory contextFactory)
          Sets the Rhino context factory to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenContextInViewInterceptor

public OpenContextInViewInterceptor()
Method Detail

setContextFactory

public void setContextFactory(org.mozilla.javascript.ContextFactory contextFactory)
Sets the Rhino context factory to use. If not set, the global context factory returned by ContextFactory.getGlobal() will be used. Note that this feature (customized context factory in the interceptor) requires at least Rhino 1.6R3.

Parameters:
contextFactory -

preHandle

public boolean preHandle(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         java.lang.Object handler)
                  throws java.lang.Exception
Specified by:
preHandle in interface org.springframework.web.servlet.HandlerInterceptor
Throws:
java.lang.Exception

afterCompletion

public void afterCompletion(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            java.lang.Object handler,
                            java.lang.Exception ex)
                     throws java.lang.Exception
Specified by:
afterCompletion in interface org.springframework.web.servlet.HandlerInterceptor
Throws:
java.lang.Exception

postHandle

public void postHandle(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       java.lang.Object handler,
                       org.springframework.web.servlet.ModelAndView modelAndView)
                throws java.lang.Exception
Specified by:
postHandle in interface org.springframework.web.servlet.HandlerInterceptor
Throws:
java.lang.Exception