The interface HandlerHook can be implemented by a bean that needs to bypass the portability offered by RSF and is wanting to take control of the complete request cycle in RSF. The interface is somewhat minimal reflecting the fact that the required dependencies of a HandlerHook cannot be known, since in general they will be highly non-portable (for example HttpServletRequest) and environmental:

/** Register a hook in the "handler chain" from the RootBeanHandler.
 * The hook returns <code>true</code> if it has successfully handled this
 * request, in which case further processing should terminate.
public interface HandlerHook {
  public boolean handle();
It's worth noting that HandlerHook fulfils a very similar function to the HandlerInterceptor interface supplied as part of SpringMVC. However unlike HandlerInterceptor, our interface is considerably more slimline, and also completely portable, not even containing any RSF dependencies. This is possible through RSF's widespread use of request-scope IoC. We need just one interface for every environment RSF is deployed into.

For efficiency reasons HandlerHooks must be declared at application scope. This would initially seem to represent a problem since many of the required dependencies will lie in the request scope - however RSF defines application-scope proxies for the majority of request-scope properties that it knows about (ViewParameters, HttpServletRequest, etc.) which can bridge to the HandlerHook. For example, an application-scope declaration of a HandlerHook might look as follows:

  <bean id="darwinHandlerHook" 
    <property name="httpServletRequest" ref="httpServletRequestProxy"/>
    <property name="httpServletResponse" ref="httpServletResponseProxy"/>
    <property name="requestTypeProxy" ref="requestTypeProxy"/>
    <property name="viewParametersProxy" ref="viewParametersProxy"/>
    <property name="pageRenderer" ref="pageRenderer"/>

HandlerHooks are registered with RSF using the standard parent definition (via TLAB) of handlerHookParent. For example the above HandlerHook would be registered using this definition:

  <bean parent="handlerHookParent">
    <property name="value" ref="darwinHandlerHook"/>

On the other hand, one may choose to declare the HandlerHook itself at request scope, where its dependencies may be acquired directly, and instead register a proxy for the HandlerHook. This may be done very compactly using a compound Spring definition like the following at application scope:

  <bean parent="handlerHookParent">
    <property name="value">
      <bean parent="RSACBridgeProxy">
        <property name="targetBeanName" value="reportHandlerHook" />

In this case reportHandlerHook would be a request-scope bean registered with RSAC. More information on the RSACBridgeProxy which appears above is on its own page.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-) was last changed on 15-Mar-2007 22:41 by UnknownAuthor