01: /*
02: * Enhydra Java Application Server
03: * The Initial Developer of the Original Code is Lutris Technologies Inc.
04: * Portions created by Lutris are Copyright (C) 1997-2000 Lutris Technologies
05: * Inc.
06: * All Rights Reserved.
07: *
08: * The contents of this file are subject to the Enhydra Public License Version
09: * 1.0 (the "License"); you may not use this file except in compliance with the
10: * License. You may obtain a copy of the License at
11: * http://www.enhydra.org/software/license/epl.html
12: *
13: * Software distributed under the License is distributed on an "AS IS" basis,
14: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15: * License for the specific language governing rights and limitations under the
16: * License.
17: *
18: *
19: */
20:
21: package golfShop.data.user;
22:
23: import java.util.Vector;
24: import java.util.Enumeration;
25: import golfShop.data.user.UserDOImpl;
26: import golfShop.data.user.UserStore;
27:
28: /**
29: * This is one flavor of a UserStore. The storage medium in this case
30: * is memory. A set of users is kept in memory. When the application exits,
31: * all the users are lost.
32: *
33: * @author Andrew John
34: * @version $Revision: 1.1 $
35: */
36: public class MemoryUserStore extends UserStore {
37:
38: /**
39: * This is the storage medium. Just keep a set of users in memory.
40: */
41: private Vector allUsers = new Vector();
42:
43: /**
44: * Initialize the set of users.
45: */
46: protected void initializeUserStore(String dir) {
47: }
48:
49: protected void initializeUserStore() {
50: UserDOImpl u = new UserDOImpl("enhydra", "lutris", "", "", "",
51: "", "", "", "");
52: allUsers.addElement(u);
53: }
54:
55: protected boolean usernameInUserStore(String username) {
56: Enumeration e = allUsers.elements();
57: while (e.hasMoreElements()) {
58: UserDOImpl u = (UserDOImpl) e.nextElement();
59: if (username.equals(u.username))
60: return true;
61: }
62: return false;
63: }
64:
65: protected UserDOImpl lookupUserFromUserStore(String username) {
66: Enumeration e = allUsers.elements();
67: while (e.hasMoreElements()) {
68: UserDOImpl u = (UserDOImpl) e.nextElement();
69: if (username.equals(u.username))
70: return u;
71: }
72: return null;
73: }
74:
75: protected void addUserToUserStore(UserDOImpl user) {
76: allUsers.addElement(user);
77: }
78:
79: /**
80: * There is nothing to do! A pointer to the object is already in the
81: * storage vector. There is really only one copy of the object. So in
82: * effect, it is already modified in the storeage medium.
83: */
84: protected void updateUserInUserStore(UserDOImpl user) {
85: }
86:
87: }
|