01: package example;
02:
03: import java.util.ArrayList;
04: import java.util.HashMap;
05: import java.util.List;
06:
07: import javax.jws.WebService;
08:
09: @WebService(endpointInterface="example.UserService")
10: public class UserServiceImpl implements UserService {
11: private final HashMap<Integer, List<User>> _userGroupMap = new HashMap<Integer, List<User>>();
12:
13: public UserServiceImpl() {
14: List<User> group1 = new ArrayList<User>();
15: group1.add(new User(1, 1, "Bruce"));
16: group1.add(new User(2, 1, "Harvey"));
17:
18: List<User> group2 = new ArrayList<User>();
19: group2.add(new User(1, 2, "Lois"));
20: group2.add(new User(2, 2, "Lex"));
21:
22: _userGroupMap.put(1, group1);
23: _userGroupMap.put(2, group2);
24: }
25:
26: public List<User> getUsers(int groupId)
27: throws InvalidGroupIdException {
28: List<User> users = _userGroupMap.get(groupId);
29:
30: if (users == null)
31: throw new InvalidGroupIdException("Invalid group id");
32:
33: return users;
34: }
35: }
|