View Javadoc

    1   /*
    2    * $Id: UserDatabase.java 471754 2006-11-06 14:55:09Z husted $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    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      // --------------------------------------------------------- Public Methods
    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 }