We're back to having the UserManager create the UserRepository but now it

does so in a way that can be overridden by derived classes.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@733 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-05-11 19:20:15 +00:00
parent c4d313b2d3
commit 4dc46a6340
@@ -1,5 +1,5 @@
// //
// $Id: UserManager.java,v 1.14 2002/05/08 00:25:54 shaper Exp $ // $Id: UserManager.java,v 1.15 2002/05/11 19:20:15 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -85,11 +85,9 @@ public class UserManager
} }
/** /**
* A user manager must be supplied with a {@link UserRepository} * Constructs a user manager and prepares it for operation. Presently
* through which it loads and saves user records. * the user manager requires the following configuration information:
* *
* <p> Presently the user manager requires the following configuration
* information:
* <ul> * <ul>
* <li><code>login_url</code>: Should be set to the URL to which to * <li><code>login_url</code>: Should be set to the URL to which to
* redirect a requester if they are required to login before accessing * redirect a requester if they are required to login before accessing
@@ -106,14 +104,14 @@ public class UserManager
* </ul> * </ul>
* *
* @param config the user manager configuration properties. * @param config the user manager configuration properties.
* @param repository the user repository through which user records * @param conprov the database connection provider that will be used
* are loaded and saved. * to obtain a connection to the user database.
*/ */
public UserManager (Properties config, UserRepository repository) public UserManager (Properties config, ConnectionProvider conprov)
throws PersistenceException throws PersistenceException
{ {
// save off the user repository // create the user repository
_repository = repository; _repository = createRepository(conprov);
// fetch the login URL from the properties // fetch the login URL from the properties
_loginURL = config.getProperty("login_url"); _loginURL = config.getProperty("login_url");
@@ -137,6 +135,16 @@ public class UserManager
null, true); null, true);
} }
/**
* Called by the user manager to create the user repository. Derived
* classes can override this and create a specialized repository if
* they so desire.
*/
protected UserRepository createRepository (ConnectionProvider conprov)
{
return new UserRepository(conprov);
}
public void shutdown () public void shutdown ()
{ {
// cancel our session table pruning thread // cancel our session table pruning thread