1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.testclient1;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21 import java.util.concurrent.ConcurrentHashMap;
22 import java.util.concurrent.atomic.AtomicInteger;
23
24 import org.apache.cxf.message.Message;
25 import org.apache.cxf.phase.PhaseInterceptorChain;
26 import org.kuali.rice.ksb.messaging.remotedservices.BaseballCard;
27 import org.kuali.rice.ksb.messaging.remotedservices.BaseballCardCollectionService;
28 import org.kuali.rice.ksb.messaging.remotedservices.ServiceCallInformationHolder;
29
30 import javax.annotation.Resource;
31 import javax.ws.rs.core.Context;
32 import javax.ws.rs.core.HttpHeaders;
33 import javax.xml.ws.WebServiceContext;
34
35
36
37
38
39
40
41 public class BaseballCardCollectionServiceImpl implements BaseballCardCollectionService {
42
43
44
45 private Map<Integer, BaseballCard> cards = new ConcurrentHashMap<Integer, BaseballCard>();
46 private AtomicInteger nextId = new AtomicInteger(1);
47
48
49
50
51 public Integer add(BaseballCard card) {
52 Integer result = null;
53 if (card != null) {
54 int id = nextId.addAndGet(1);
55 cards.put(id, card);
56 result = id;
57 }
58 return result;
59 }
60
61
62
63
64 public void delete(Integer id) {
65 cards.remove(id);
66 }
67
68
69
70
71 public BaseballCard get(Integer id) {
72 return cards.get(id);
73 }
74
75
76
77
78 public List<BaseballCard> get(String playerName) {
79 List<BaseballCard> results = new ArrayList<BaseballCard>();
80 for (BaseballCard card : cards.values()) {
81 if (playerName.equals(card.getPlayerName())) results.add(card);
82 }
83 return results;
84 }
85
86
87
88
89 public List<BaseballCard> getAll() {
90
91
92 ServiceCallInformationHolder.multiValues = (Map<String, List<String>>)PhaseInterceptorChain.getCurrentMessage().get(Message.PROTOCOL_HEADERS);
93 return new ArrayList<BaseballCard>(cards.values());
94 }
95
96
97
98
99 public void update(Integer id, BaseballCard card) {
100 cards.put(id, card);
101 }
102
103
104
105
106
107
108 public void unannotatedMethod() {
109
110 }
111
112 }