1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.ihe.hl7v3;
17
18 import java.util.HashMap;
19 import java.util.Map;
20 import java.util.concurrent.atomic.AtomicInteger;
21
22 import org.apache.cxf.interceptor.Fault;
23 import org.apache.cxf.message.Message;
24 import org.apache.cxf.phase.AbstractPhaseInterceptor;
25 import org.apache.cxf.phase.Phase;
26
27
28
29
30
31 public class CustomInterceptor extends AbstractPhaseInterceptor<Message> {
32 private static Map<String, AtomicInteger> map = new HashMap<>();
33
34 public CustomInterceptor(String id) {
35 super(id, Phase.PRE_PROTOCOL);
36 map.put(id, new AtomicInteger(0));
37 }
38
39 @Override
40 public void handleMessage(Message message) throws Fault {
41 map.get(getId()).incrementAndGet();
42 }
43
44 public static int getAt(String key) {
45 return map.get(key).get();
46 }
47
48 public static void clear() {
49 map.clear();
50 }
51 }