Java Doc for ScopeInterceptor.java in  » Web-Framework » struts-2.0.11 » org » apache » struts2 » interceptor » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » struts 2.0.11 » org.apache.struts2.interceptor 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.struts2.interceptor.ScopeInterceptor

ScopeInterceptor
public class ScopeInterceptor extends AbstractInterceptor implements PreResultListener(Code)
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 a PreResultListener ), 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:

  • session - a list of action properties to be bound to session scope
  • application - a list of action properties to be bound to application scope
  • key - a session/application attribute key prefix, can contain following values:
    • CLASS - that creates a unique key prefix based on action namespace and action class, it's a default value
    • ACTION - creates a unique key prefix based on action namespace and action name
    • any other value is taken literally as key prefix
  • type - with one of the following
    • start - means it's a start action of the wizard-like action sequence and all session scoped properties are reset to their defaults
    • end - means that session scoped properties are removed from session after action is run
    • any other value or no value means that it's in-the-middle action that is set with session properties before it's executed, and it's properties are put back to session after execution
  • sessionReset - boolean value causing all session values to be reset to action's default values or application scope values, note that it is similliar to type="start" and in fact it does the same, but in our team it is sometimes semantically preferred. We use session scope in two patterns - sometimes there are wizzard-like action sequences that have start and end, and sometimes we just want simply reset current session values.

Extending the interceptor:

There are no know extension points for this interceptor.

Example code:

 
 <!-- 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>
 
 



Constructor Summary
public  ScopeInterceptor()
    

Method Summary
protected  voidafter(ActionInvocation invocation, String result)
    
protected  voidbefore(ActionInvocation invocation)
    
public  voidbeforeResult(ActionInvocation invocation, String resultCode)
    
public  StringgetSessionReset()
    
public  StringgetType()
    
public  Stringintercept(ActionInvocation invocation)
    
public  booleanisReset()
    
final static  voidlock(Object o, ActionInvocation invocation)
    
public  voidsetApplication(String s)
    
public  voidsetAutoCreateSession(String value)
    
public  voidsetKey(String key)
    
public  voidsetReset(boolean reset)
    
public  voidsetSession(String s)
    
public  voidsetSessionReset(String sessionReset)
    
public  voidsetType(String type)
    
final static  voidunlock(Object o)
    


Constructor Detail
ScopeInterceptor
public ScopeInterceptor()(Code)
The constructor




Method Detail
after
protected void after(ActionInvocation invocation, String result) throws Exception(Code)



before
protected void before(ActionInvocation invocation) throws Exception(Code)



beforeResult
public void beforeResult(ActionInvocation invocation, String resultCode)(Code)



getSessionReset
public String getSessionReset()(Code)
Gets the session reset parameter name



getType
public String getType()(Code)
The type of scope operation, "start" or "end"



intercept
public String intercept(ActionInvocation invocation) throws Exception(Code)



isReset
public boolean isReset()(Code)
True if the scope is reset



lock
final static void lock(Object o, ActionInvocation invocation) throws Exception(Code)



setApplication
public void setApplication(String s)(Code)
Sets a list of application scoped properties
Parameters:
  s - A comma-delimited list



setAutoCreateSession
public void setAutoCreateSession(String value)(Code)
Sets if the session should be automatically created
Parameters:
  value - True if it should be created



setKey
public void setKey(String key)(Code)



setReset
public void setReset(boolean reset)(Code)

Parameters:
  reset - True if the scope should be reset



setSession
public void setSession(String s)(Code)
Sets a list of session scoped properties
Parameters:
  s - A comma-delimited list



setSessionReset
public void setSessionReset(String sessionReset)(Code)

Parameters:
  sessionReset - The session reset parameter name



setType
public void setType(String type)(Code)
Sets the type of scope operation
Parameters:
  type - Either "start" or "end"



unlock
final static void unlock(Object o)(Code)



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.