org.apache.struts.webapp.example.memory
Class MemoryUserDatabase

java.lang.Object
  extended byorg.apache.struts.webapp.example.memory.MemoryUserDatabase
All Implemented Interfaces:
UserDatabase
Direct Known Subclasses:
TestUserDatabase

public class MemoryUserDatabase
extends Object
implements UserDatabase

Concrete implementation of UserDatabase for an in-memory database backed by an XML data file.

Version:
$Id $

Field Summary
private  org.apache.commons.logging.Log log
          Logging output for this user database instance.
private  String pathname
          Absolute pathname to the persistent file we use for loading and storing persistent data.
private  String pathnameNew
           
private  String pathnameOld
           
private  HashMap users
          The Users associated with this UserDatabase, keyed by username.
 
Constructor Summary
MemoryUserDatabase()
           
 
Method Summary
 void close()
          Finalize access to the underlying persistence layer.
 User createUser(String username)
          Create and return a new User defined in this user database.
 User findUser(String username)
          Return the existing User with the specified username, if any; otherwise return null.
 User[] findUsers()
          Return the set of Users defined in this user database.
 String getPathname()
           
 void open()
          Initiate access to the underlying persistence layer.
 void removeUser(User user)
          Remove the specified User from this database.
 void save()
          Save any pending changes to the underlying persistence layer.
 void setPathname(String pathname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private org.apache.commons.logging.Log log
Logging output for this user database instance.


users

private HashMap users
The Users associated with this UserDatabase, keyed by username.


pathname

private String pathname
Absolute pathname to the persistent file we use for loading and storing persistent data.


pathnameOld

private String pathnameOld

pathnameNew

private String pathnameNew
Constructor Detail

MemoryUserDatabase

public MemoryUserDatabase()
Method Detail

getPathname

public String getPathname()

setPathname

public void setPathname(String pathname)

close

public void close()
           throws Exception
Description copied from interface: UserDatabase

Finalize access to the underlying persistence layer.

Specified by:
close in interface UserDatabase
Throws:
Exception - if a database access error occurs

createUser

public User createUser(String username)
Description copied from interface: UserDatabase

Create and return a new User defined in this user database.

Specified by:
createUser in interface UserDatabase
Parameters:
username - Username of the new user

findUser

public User findUser(String username)
              throws ExpiredPasswordException
Description copied from interface: UserDatabase

Return the existing User with the specified username, if any; otherwise return null.

Specified by:
findUser in interface UserDatabase
Parameters:
username - Username of the user to retrieve
Throws:
ExpiredPasswordException - if user password has expired and must be changed

findUsers

public User[] findUsers()
Description copied from interface: UserDatabase

Return the set of Users defined in this user database.

Specified by:
findUsers in interface UserDatabase

open

public void open()
          throws Exception
Description copied from interface: UserDatabase

Initiate access to the underlying persistence layer.

Specified by:
open in interface UserDatabase
Throws:
Exception - if a database access error occurs

removeUser

public void removeUser(User user)
Description copied from interface: UserDatabase
Remove the specified User from this database.

Specified by:
removeUser in interface UserDatabase
Parameters:
user - User to be removed

save

public void save()
          throws Exception
Description copied from interface: UserDatabase

Save any pending changes to the underlying persistence layer.

Specified by:
save in interface UserDatabase
Throws:
Exception - if a database access error occurs


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.