View Javadoc

1   /*
2    * Copyright 1999-2002,2004 The Apache Software Foundation.
3    * 
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
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
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.
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      // --------------------------------------------------------- Public Methods
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 }