Class MemoryHashLoginInfoStore
- java.lang.Object
-
- com.sun.appserv.management.client.prefs.MemoryHashLoginInfoStore
-
- All Implemented Interfaces:
LoginInfoStore
public class MemoryHashLoginInfoStore extends Object implements LoginInfoStore
ALoginInfoStore
that reads the information from the default file ".gfclient/pass" and stores it as a map in the memory. It is not guaranteed that the concurrent modifications will yield consistent results. This class is not thread safe. The serial access has to be ensured by the callers.- Since:
- Appserver 9.0
-
-
Constructor Summary
Constructors Constructor Description MemoryHashLoginInfoStore()
Creates a new instance of MemoryHashLoginInfoStore.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
exists(String host, int port)
Checks whether a LoginInfo for given host and port exists in this store.String
getName()
Returns the name of the store.Collection<LoginInfo>
list()
A convenience method that returns the Collection of LoginInfo instances stored in this store.LoginInfo
read(String host, int port)
Returns aLoginInfo
corresponding to the given host and port, from this store.void
remove(String host, int port)
Removes theLoginInfo
corresponding to the given host and port, from this store.int
size()
A convenience method that returns the number of LoginInfo instances stored in this store.void
store(LoginInfo login)
Stores the given LoginInfo in this store.void
store(LoginInfo login, boolean overwrite)
Stores the given LoginInfo in this store.
-
-
-
Constructor Detail
-
MemoryHashLoginInfoStore
public MemoryHashLoginInfoStore() throws StoreException
Creates a new instance of MemoryHashLoginInfoStore. A side effect of calling this constructor is that if the default store does not exist, it will be created. This does not pose any harm or surprises.- Throws:
StoreException
-
-
Method Detail
-
store
public void store(LoginInfo login) throws StoreException
Description copied from interface:LoginInfoStore
Stores the given LoginInfo in this store. Given LoginInfo may not be null. Upon successful return, the size of this store increases by one. An exception is thrown if there is already a LoginInfo with given host and port.- Specified by:
store
in interfaceLoginInfoStore
- Parameters:
login
- a LoginInfo that needs to be stored- Throws:
StoreException
- if there's any problem or if there is already a LoginInfo with given host and port
-
store
public void store(LoginInfo login, boolean overwrite) throws StoreException
Description copied from interface:LoginInfoStore
Stores the given LoginInfo in this store. Given LoginInfo may not be null. Upon successful return, the size of this store increases by one. An exception is thrown if there is already a LoginInfo with given host and port and overwrite is false. If overwrite is true, the given LoginInfo is stored regardless of whether it already exists in this store. Depending upon the value of overwrite, the store is either unchanged or not.- Specified by:
store
in interfaceLoginInfoStore
- Parameters:
login
- a LoginInfo that needs to be stored- Throws:
StoreException
- if there's any problem in storing or if overwrite is false and the LoginInfo with given host and port already exists
-
remove
public void remove(String host, int port)
Description copied from interface:LoginInfoStore
Removes theLoginInfo
corresponding to the given host and port, from this store. The host may not be null. If no such LoginInfo exists, StoreException results. The caller thus must ensure if such a LoginInfo exists before calling this method. Upon successful return, size of this store decreases by one.- Specified by:
remove
in interfaceLoginInfoStore
- Parameters:
host
- a non null String representing host nameport
- an integer specifying the port number
-
read
public LoginInfo read(String host, int port)
Description copied from interface:LoginInfoStore
Returns aLoginInfo
corresponding to the given host and port, from this store. The host may not be null. For a given host and port, there can be at most one LoginInfo in this store.- Specified by:
read
in interfaceLoginInfoStore
- Parameters:
host
- a non null String representing host nameport
- an integer specifying the port number- Returns:
- the corresponding LoginInfo, null if there is none
-
exists
public boolean exists(String host, int port)
Description copied from interface:LoginInfoStore
Checks whether a LoginInfo for given host and port exists in this store.- Specified by:
exists
in interfaceLoginInfoStore
- Parameters:
host
- a non null String representing host nameport
- an integer specifying the port number
-
size
public int size()
Description copied from interface:LoginInfoStore
A convenience method that returns the number of LoginInfo instances stored in this store. Zero is returned when no login information is stored.- Specified by:
size
in interfaceLoginInfoStore
- Returns:
- an integer representing number of stored login information elements, 0 if none
-
list
public Collection<LoginInfo> list()
Description copied from interface:LoginInfoStore
A convenience method that returns the Collection of LoginInfo instances stored in this store. An empty Collection is returned when there are no LoginInfo items stored.- Specified by:
list
in interfaceLoginInfoStore
- Returns:
- the Collection of LoginInfo instances
-
getName
public String getName()
Description copied from interface:LoginInfoStore
Returns the name of the store. This is any name that the store implementation wants to use for identification, for instance.- Specified by:
getName
in interfaceLoginInfoStore
-
-