2
* Copyright 1999-2002,2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
package org.apache.struts.webapp.example2;
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>
28
* @author Craig R. McClanahan
29
* @version $Revision: 1.2 $ $Date: 2004/03/08 02:49:53 $
33
public interface UserDatabase {
36
// --------------------------------------------------------- Public Methods
40
* <p>Create and return a new {@link User} defined in this user database.
43
* @param username Username of the new user
45
* @exception IllegalArgumentExceptionif the specified username
48
public User createUser(String username);
52
* <p>Finalize access to the underlying persistence layer.</p>
54
* @exception Exception if a database access error occurs
56
public void close() throws Exception;
60
* <p>Return the existing {@link User} with the specified username,
61
* if any; otherwise return <code>null</code>.</p>
63
* @param username Username of the user to retrieve
65
public User findUser(String username);
69
* <p>Return the set of {@link User}s defined in this user database.</p>
71
public User[] findUsers();
75
* <p>Initiate access to the underlying persistence layer.</p>
77
* @exception Exception if a database access error occurs
79
public void open() throws Exception;
83
* Remove the specified {@link User} from this database.
85
* @param user User to be removed
87
* @exception IllegalArgumentException if the specified user is not
88
* associated with this database
90
public void removeUser(User user);
94
* <p>Save any pending changes to the underlying persistence layer.</p>
96
* @exception Exception if a database access error occurs
98
public void save() throws Exception;