1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.plugin;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21
22
23
24
25 public class InterceptorChain {
26
27 private final List<Interceptor> interceptors = new ArrayList<Interceptor>();
28
29 public Object pluginAll(Object target) {
30 for (Interceptor interceptor : interceptors) {
31 target = interceptor.plugin(target);
32 }
33 return target;
34 }
35
36 public void addInterceptor(Interceptor interceptor) {
37 interceptors.add(interceptor);
38 }
39
40 public List<Interceptor> getInterceptors() {
41 return Collections.unmodifiableList(interceptors);
42 }
43
44 }