Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.action.interceptor
Class ConditionalInterceptor

java.lang.Object
  extended by com.jivesoftware.base.action.interceptor.ConditionalInterceptor
All Implemented Interfaces:
com.opensymphony.xwork.interceptor.Interceptor, java.io.Serializable

public abstract class ConditionalInterceptor
extends java.lang.Object
implements com.opensymphony.xwork.interceptor.Interceptor

An interceptor which will conditionally execute its logic based on rules around what method of the action is being called.

For example, if you want to intercept and execute something on all methods except for 'default', set the disallow property to "default". If you want to disable execution for the 'foo' method as well, set the disallow property to "default,foo". Similarly, to enable execution for the 'bar' method and no others, set the allow property to 'bar'. If the allow or disallow properties were never set then the interceptor logic is executed for all methods.

Additionally, you can specify when the logic should be executed - either before or after the interceptor chain is called. By default the logic will be executed *before*.

See Also:
Serialized Form

Field Summary
static java.lang.String AFTER
          Constant to indicate the interceptor logic should be invoked after passing control down the interceptor chain.
static java.lang.String BEFORE
          Constant to indicate the interceptor logic should be invoked before passing control down the interceptor chain.
 
Constructor Summary
ConditionalInterceptor()
           
 
Method Summary
 void destroy()
          Does nothing in this implementation.
 java.lang.String getAllow()
          Returns the allow parameter.
 java.lang.String getDisallow()
          Returns the disallow parameter.
 java.lang.String getType()
          Sets the type of interceptor this is - whether or not to execute its logic before or after passing control down the interceptor chain.
 void init()
          Sets the default type to be BEFORE.
 java.lang.String intercept(com.opensymphony.xwork.ActionInvocation in)
          Calls ActionInvocation.invoke() based on the type - it will be called either before or after the main logic of this interceptor is called.
protected abstract  java.lang.String performAction(com.opensymphony.xwork.ActionInvocation in)
          The core logic of the interceptor.
 void setAllow(java.lang.String allow)
          Sets the allow parameter.
 void setDisallow(java.lang.String disallow)
          Sets the disallow parameter.
 void setType(java.lang.String type)
          Sets the type of interceptor this is - a before or after one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEFORE

public static final java.lang.String BEFORE
Constant to indicate the interceptor logic should be invoked before passing control down the interceptor chain.

See Also:
Constant Field Values

AFTER

public static final java.lang.String AFTER
Constant to indicate the interceptor logic should be invoked after passing control down the interceptor chain.

See Also:
Constant Field Values
Constructor Detail

ConditionalInterceptor

public ConditionalInterceptor()
Method Detail

getAllow

public java.lang.String getAllow()
Returns the allow parameter.


setAllow

public void setAllow(java.lang.String allow)
Sets the allow parameter. The string should be a comma-delimited list of allowable method names.


getDisallow

public java.lang.String getDisallow()
Returns the disallow parameter.


setDisallow

public void setDisallow(java.lang.String disallow)
Sets the disallow parameter. This should be a comma-delimited list of allowable method names.


getType

public java.lang.String getType()
Sets the type of interceptor this is - whether or not to execute its logic before or after passing control down the interceptor chain. Will return BEFORE or AFTER.

Returns:
type indicates when the logic of this interceptor will be executed - either before or after passing control down the interceptor chain.

setType

public void setType(java.lang.String type)
Sets the type of interceptor this is - a before or after one. This indicates when the interceptor should execute its logic - either before or after passing control down the interceptor chain.

Parameters:
type - either BEFORE or AFTER

init

public void init()
Sets the default type to be BEFORE.

Specified by:
init in interface com.opensymphony.xwork.interceptor.Interceptor

destroy

public void destroy()
Does nothing in this implementation.

Specified by:
destroy in interface com.opensymphony.xwork.interceptor.Interceptor

intercept

public java.lang.String intercept(com.opensymphony.xwork.ActionInvocation in)
                           throws java.lang.Exception
Calls ActionInvocation.invoke() based on the type - it will be called either before or after the main logic of this interceptor is called. Additionally, the logic may be skipped depending on the allow or disallow rules.

Specified by:
intercept in interface com.opensymphony.xwork.interceptor.Interceptor
Parameters:
in - the action's invocation which is basically the execution state.
Returns:
the action/interceptor response code.
Throws:
java.lang.Exception - if an error occurs when executing the interceptor.

performAction

protected abstract java.lang.String performAction(com.opensymphony.xwork.ActionInvocation in)
                                           throws java.lang.Exception
The core logic of the interceptor. Developers should override this method in a subclass to specify the logic that will be executed for this interceptor.

Parameters:
in - the action invocation.
Returns:
A result code, or null if the interceptor's action does't shortcircuit the interceptor chain
Throws:
java.lang.Exception - if an error occurs when executing the interceptor.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.