My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.googlecode.struts2webflow;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.util.ValueStack;

/**
* A helper intercepter that maintains the flow execution key in the session
* rather than pushing it out to the client.
*/
public class SessionFlowExecKeyInterceptor implements Interceptor {
public static final String DEFAULT_SESSION_KEY = "SessionFlowExecKeyInterceptor.SESSION_KEY";

/**
* Location in the session where the flow exec key is stored between flow
* requests.
*/
private String sessionKey = DEFAULT_SESSION_KEY;

public void init() {
}

public String intercept(ActionInvocation invocation) throws Exception {
Map session = invocation.getInvocationContext().getSession();
ValueStack stack = invocation.getStack();

String flowExecKey = (String) session.get(sessionKey);
if(flowExecKey != null) {
stack.setValue("flowExecutionKey", flowExecKey);
}
String result = invocation.invoke();
flowExecKey = (String) stack.findValue("flowExecutionKey");
session.put(sessionKey, flowExecKey);
return result;
}

public void destroy() {
}

public String getSessionKey() {
return sessionKey;
}

public void setSessionKey(String sessionKey) {
this.sessionKey = sessionKey;
}
}

Change log

r33 by schneidh on Feb 24, 2007   Diff
reformatted
Go to: 
Project members, sign in to write a code review

Older revisions

r6 by schneidh on Jan 3, 2007   Diff
initial checkin
All revisions of this file

File info

Size: 1467 bytes, 49 lines
Powered by Google Project Hosting