1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.struts.webapp.example;
24
25
26 /**
27 * <p>A <strong>Data Access Object</strong> (DAO) interface describing
28 * the available operations for retrieving and storing {@link User}s
29 * (and their associated {@link Subscription}s) in some persistence layer
30 * whose characteristics are not specified here. One or more implementations
31 * will be created to perform the actual I/O that is required.</p>
32 *
33 * @author Craig R. McClanahan
34 * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
35 * @since Struts 1.1
36 */
37
38 public interface UserDatabase {
39
40
41
42
43
44 /**
45 * <p>Create and return a new {@link User} defined in this user database.
46 * </p>
47 *
48 * @param username Username of the new user
49 *
50 * @exception IllegalArgumentExceptionif the specified username
51 * is not unique
52 */
53 public User createUser(String username);
54
55
56 /**
57 * <p>Finalize access to the underlying persistence layer.</p>
58 *
59 * @exception Exception if a database access error occurs
60 */
61 public void close() throws Exception;
62
63
64 /**
65 * <p>Return the existing {@link User} with the specified username,
66 * if any; otherwise return <code>null</code>.</p>
67 *
68 * @param username Username of the user to retrieve
69 */
70 public User findUser(String username);
71
72
73 /**
74 * <p>Return the set of {@link User}s defined in this user database.</p>
75 */
76 public User[] findUsers();
77
78
79 /**
80 * <p>Initiate access to the underlying persistence layer.</p>
81 *
82 * @exception Exception if a database access error occurs
83 */
84 public void open() throws Exception;
85
86
87 /**
88 * Remove the specified {@link User} from this database.
89 *
90 * @param user User to be removed
91 *
92 * @exception IllegalArgumentException if the specified user is not
93 * associated with this database
94 */
95 public void removeUser(User user);
96
97
98 /**
99 * <p>Save any pending changes to the underlying persistence layer.</p>
100 *
101 * @exception Exception if a database access error occurs
102 */
103 public void save() throws Exception;
104
105
106 }