KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > client > prefs > LoginInfoStore


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.appserv.management.client.prefs;
24 import java.util.Collection JavaDoc;
25
26 /**
27  * An interface that represents the database of LoginInfo objects. Provides methods
28  * to access and mutate the store. The general contract of store update comprises of the following:
29  * <ul>
30  * <li> The store can contain at the most one LoginInfo for a host and port combination </li>
31  * <li> There is <i> no guarantee </i> that concurrent modification of this store by two
32  * different programs will always be consistent. </li>
33  * </ul>
34  * @since Appserver 9.0
35  */

36 public interface LoginInfoStore {
37     
38     /**
39      * Returns a {@link LoginInfo} corresponding to the given host and port, from this store.
40      * The host may not be null. For a given host and port, there can be at most
41      * one LoginInfo in this store.
42      * @param host a non null String representing host name
43      * @param port an integer specifying the port number
44      * @return the corresponding LoginInfo, null if there is none
45      * @throws StoreException if there is something wrong with reading the store
46      * @throws IllegalArgumentException if the parameter host is null
47      */

48     public LoginInfo read(final String JavaDoc host, final int port) throws StoreException;
49     
50     /**
51      * Removes the {@link LoginInfo} corresponding to the given host and port, from this store.
52      * The host may not be null. If no such LoginInfo exists, StoreException results.
53      * The caller thus must ensure if such a LoginInfo exists before calling this method.
54      * Upon successful return, size of this store decreases by one.
55      * @param host a non null String representing host name
56      * @param port an integer specifying the port number
57      * @throws StoreException if there is something wrong with reading the store or if there is
58      * no such LoginInfo
59      * @throws IllegalArgumentException if the parameter host is null
60      */

61     public void remove(final String JavaDoc host, final int port) throws StoreException;
62     
63     /**
64      * Stores the given LoginInfo in this store. Given LoginInfo may not be null.
65      * Upon successful return, the size of this store increases by one. An exception is thrown
66      * if there is already a LoginInfo with given host and port.
67      * @param login a LoginInfo that needs to be stored
68      * @throws StoreException if there's any problem or if there is already a LoginInfo
69      * with given host and port
70      * @throws IllegalArgumentException if the given LoginInfo is null
71      */

72     public void store(final LoginInfo login) throws StoreException;
73     
74     /**
75      * Stores the given LoginInfo in this store. Given LoginInfo may not be null.
76      * Upon successful return, the size of this store increases by one. An exception is thrown
77      * if there is already a LoginInfo with given host and port and overwrite is false.
78      * If overwrite is true, the given LoginInfo is stored regardless of whether it already
79      * exists in this store. Depending upon the value of overwrite, the store is either unchanged
80      * or not.
81      * @param login a LoginInfo that needs to be stored
82      * @throws StoreException if there's any problem in storing or if overwrite is false and
83      * the LoginInfo with given host and port already exists
84      * @throws IllegalArgumentException if the given LoginInfo is null
85      */

86     public void store(final LoginInfo login, final boolean overwrite) throws StoreException;
87     
88    /**
89      * Checks whether a LoginInfo for given host and port exists in this store.
90      * @param host a non null String representing host name
91      * @param port an integer specifying the port number
92      * @throws StoreException if there's any problem reading the store
93      */

94     public boolean exists(final String JavaDoc host, final int port) throws StoreException;
95     
96     /**
97      * A convenience method that returns the Collection of LoginInfo instances stored in this store.
98      * An empty Collection is returned when there are no LoginInfo items stored.
99      * @return the Collection of LoginInfo instances
100      * @throws StoreException if there's any problem reading the store
101      */

102     public Collection JavaDoc<LoginInfo> list() throws StoreException;
103     
104     /**
105      * A convenience method that returns the number of LoginInfo instances stored in this store.
106      * Zero is returned when no login information is stored.
107      * @return an integer representing number of stored login information elements, 0 if none
108      * @throws StoreException if there's any problem reading the store
109      */

110     public int size() throws StoreException;
111     
112     /** Returns the name of the store.
113      * This is any name that the store implementation wants to use for identification, for instance.
114      */

115     public String JavaDoc getName();
116 }
Popular Tags