Java Doc for ScopeInterceptor.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.interceptor 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.opensymphony.webwork.interceptor.ScopeInterceptor

ScopeInterceptor
public class ScopeInterceptor implements Interceptor,PreResultListener(Code)
This is designed to solve a few simple issues related to wizard-like functionality in WebWork. 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>
 
 

author:
   Mike Mosiewicz
author:
   Rainer Hermanns


Field Summary
 String[]application
    
 booleanautoCreateSession
    
 Stringkey
    
 booleanreset
    
 String[]session
    
 StringsessionReset
    
 Stringtype
    

Constructor Summary
public  ScopeInterceptor()
    

Method Summary
protected  voidafter(ActionInvocation invocation, String result)
    
protected  voidbefore(ActionInvocation invocation)
    
public  voidbeforeResult(ActionInvocation invocation, String resultCode)
    
public  voiddestroy()
    
public  StringgetSessionReset()
    
public  StringgetType()
    
public  voidinit()
    
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)
    

Field Detail
application
String[] application(Code)



autoCreateSession
boolean autoCreateSession(Code)



key
String key(Code)



reset
boolean reset(Code)



session
String[] session(Code)



sessionReset
String sessionReset(Code)



type
String type(Code)




Constructor Detail
ScopeInterceptor
public ScopeInterceptor()(Code)




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)



destroy
public void destroy()(Code)



getSessionReset
public String getSessionReset()(Code)



getType
public String getType()(Code)



init
public void init()(Code)



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



isReset
public boolean isReset()(Code)



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



setApplication
public void setApplication(String s)(Code)



setAutoCreateSession
public void setAutoCreateSession(String value)(Code)



setKey
public void setKey(String key)(Code)



setReset
public void setReset(boolean reset)(Code)



setSession
public void setSession(String s)(Code)



setSessionReset
public void setSessionReset(String sessionReset)(Code)



setType
public void setType(String type)(Code)



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



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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