|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |
java.lang.Objectcom.opensymphony.xwork2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.ScopeInterceptor
public class ScopeInterceptor
This is designed to solve a few simple issues related to wizard-like functionality in Struts. One of those issues is that some applications have a application-wide parameters commonly used, such pageLen (used for records per page). Rather than requiring that each action check if such parameters are supplied, this interceptor can look for specified parameters and pull them out of the session.
This works by setting listed properties at action start with values from session/application attributes keyed after the action's class, the action's name, or any supplied key. After action is executed all the listed properties are taken back and put in session or application context. To make sure that each execution of the action is consistent it makes use of session-level locking. This way it guarantees that each action execution is atomic at the session level. It doesn't guarantee application level consistency however there has yet to be enough reasons to do so. Application level consistency would also be a big performance overkill. Note that this interceptor takes a snapshot of action properties just before result is presented (using aPreResultListener
), rather than after action is invoked. There is a reason for that: At this moment we know that
action's state is "complete" as it's values may depend on the rest of the stack and specifically - on the values of
nested interceptors.
Interceptor parameters:
<!-- As the filter and orderBy parameters are common for all my browse-type actions, you can move control to the scope interceptor. In the session parameter you can list action properties that are going to be automatically managed over session. You can do the same for application-scoped variables--> <action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="basicStack"/> <interceptor-ref name="hibernate"/> <interceptor-ref name="scope"> <param name="session">filter,orderBy</param> <param name="autoCreateSession">true</param> </interceptor-ref> <result name="success">good_result.ftl</result> </action>
构造方法摘要 | |
---|---|
ScopeInterceptor()
The constructor |
方法摘要 | |
---|---|
void |
beforeResult(com.opensymphony.xwork2.ActionInvocation invocation,
String resultCode)
|
String |
getSessionReset()
|
String |
getType()
|
String |
intercept(com.opensymphony.xwork2.ActionInvocation invocation)
|
boolean |
isReset()
|
void |
setApplication(String s)
Sets a list of application scoped properties |
void |
setAutoCreateSession(String value)
Sets if the session should be automatically created |
void |
setKey(String key)
|
void |
setReset(boolean reset)
|
void |
setSession(String s)
Sets a list of session scoped properties |
void |
setSessionReset(String sessionReset)
|
void |
setType(String type)
Sets the type of scope operation |
从类 com.opensymphony.xwork2.interceptor.AbstractInterceptor 继承的方法 |
---|
destroy, init |
从类 java.lang.Object 继承的方法 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
构造方法详细信息 |
---|
public ScopeInterceptor()
方法详细信息 |
---|
public void setApplication(String s)
s
- A comma-delimited listpublic void setSession(String s)
s
- A comma-delimited listpublic void setAutoCreateSession(String value)
value
- True if it should be createdpublic void setKey(String key)
public void beforeResult(com.opensymphony.xwork2.ActionInvocation invocation, String resultCode)
com.opensymphony.xwork2.interceptor.PreResultListener
中的 beforeResult
public String getType()
public void setType(String type)
type
- Either "start" or "end"public String getSessionReset()
public void setSessionReset(String sessionReset)
sessionReset
- The session reset parameter namepublic String intercept(com.opensymphony.xwork2.ActionInvocation invocation) throws Exception
com.opensymphony.xwork2.interceptor.Interceptor
中的 intercept
com.opensymphony.xwork2.interceptor.AbstractInterceptor
中的 intercept
Exception
public boolean isReset()
public void setReset(boolean reset)
reset
- True if the scope should be reset
|
||||||||||
上一个类 下一个类 | 框架 无框架 | |||||||||
摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 |