1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl; |
12 | |
|
13 | |
import org.mule.umo.Invocation; |
14 | |
import org.mule.umo.UMOException; |
15 | |
import org.mule.umo.UMOImmutableDescriptor; |
16 | |
import org.mule.umo.UMOInterceptor; |
17 | |
import org.mule.umo.UMOMessage; |
18 | |
|
19 | |
import java.util.List; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class InterceptorsInvoker extends Invocation |
26 | |
{ |
27 | |
private final List interceptors; |
28 | 0 | private int cursor = 0; |
29 | |
|
30 | |
public InterceptorsInvoker(List interceptors, MuleDescriptor descriptor, UMOMessage message) |
31 | |
{ |
32 | 0 | this(interceptors, new ImmutableMuleDescriptor(descriptor), message); |
33 | 0 | } |
34 | |
|
35 | |
public InterceptorsInvoker(List interceptors, UMOImmutableDescriptor descriptor, UMOMessage message) |
36 | |
{ |
37 | 0 | super(descriptor, message, null); |
38 | 0 | this.interceptors = interceptors; |
39 | 0 | } |
40 | |
|
41 | |
public UMOMessage execute() throws UMOException |
42 | |
{ |
43 | 0 | if (cursor < interceptors.size()) |
44 | |
{ |
45 | 0 | UMOInterceptor interceptor = (UMOInterceptor) interceptors.get(cursor); |
46 | 0 | incCursor(); |
47 | 0 | return interceptor.intercept(this); |
48 | |
} |
49 | 0 | return getMessage(); |
50 | |
} |
51 | |
|
52 | |
private synchronized void incCursor() |
53 | |
{ |
54 | 0 | cursor++; |
55 | 0 | } |
56 | |
|
57 | |
} |