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