1
2
3 package org.apache.struts2.impl;
4
5 import static org.apache.struts2.impl.RequestContextImpl.ILLEGAL_PROCEED;
6
7 import java.util.concurrent.Callable;
8
9 import com.opensymphony.xwork2.ActionInvocation;
10 import com.opensymphony.xwork2.interceptor.Interceptor;
11
12 public class InterceptorAdapter implements Interceptor {
13
14 private static final long serialVersionUID = 8020658947818231684L;
15 final org.apache.struts2.spi.Interceptor delegate;
16
17 public InterceptorAdapter(org.apache.struts2.spi.Interceptor delegate) {
18 this.delegate = delegate;
19 }
20
21 public String intercept(final ActionInvocation invocation) throws Exception {
22 final RequestContextImpl requestContext = RequestContextImpl.get();
23
24
25 Callable<String> previous = requestContext.getProceed();
26
27 requestContext.setProceed(new Callable<String>() {
28 public String call() throws Exception {
29
30 requestContext.setProceed(ILLEGAL_PROCEED);
31 try {
32 return invocation.invoke();
33 } finally {
34
35 requestContext.setProceed(this);
36 }
37 }
38 });
39
40 try {
41 return delegate.intercept(requestContext);
42 } finally {
43 requestContext.setProceed(previous);
44 }
45 }
46
47 public void destroy() {}
48 public void init() {}
49 }