org.apache.james.userrepository
Class DefaultUsersJdbcRepository

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.userrepository.AbstractUsersRepository
          extended by org.apache.james.userrepository.AbstractJdbcUsersRepository
              extended by org.apache.james.userrepository.DefaultUsersJdbcRepository
All Implemented Interfaces:
org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, UsersRepository

public class DefaultUsersJdbcRepository
extends AbstractJdbcUsersRepository

A Jdbc-backed UserRepository which handles User instances of the DefaultUser class. Although this repository can handle subclasses of DefaultUser, like DefaultJamesUser, only properties from the DefaultUser class are persisted. TODO Please note that default configuration uses JamesUsersJdbcRepository instead of this class. So we could also delete this implementation.


Field Summary
 
Fields inherited from class org.apache.james.userrepository.AbstractJdbcUsersRepository
context, m_sqlParameters
 
Fields inherited from interface org.apache.james.services.UsersRepository
ROLE, USER
 
Constructor Summary
DefaultUsersJdbcRepository()
           
 
Method Summary
 boolean addUser(java.lang.String username, java.lang.String password)
          Adds a user to the repository with the specified password
protected  User readUserFromResultSet(java.sql.ResultSet rsUsers)
          Reads properties for a User from an open ResultSet.
protected  void setUserForInsertStatement(User user, java.sql.PreparedStatement userInsert)
          Set parameters of a PreparedStatement object with property values from a User instance.
protected  void setUserForUpdateStatement(User user, java.sql.PreparedStatement userUpdate)
          Set parameters of a PreparedStatement object with property values from a User instance.
 
Methods inherited from class org.apache.james.userrepository.AbstractJdbcUsersRepository
configure, contextualize, doAddUser, doRemoveUser, doUpdateUser, getUserByName, initialize, listAllUsers, listUserNames, service
 
Methods inherited from class org.apache.james.userrepository.AbstractUsersRepository
addUser, addUser, contains, containsCaseInsensitive, countUsers, getRealName, getUserByName, getUserByNameCaseInsensitive, list, removeUser, test, updateUser
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultUsersJdbcRepository

public DefaultUsersJdbcRepository()
Method Detail

readUserFromResultSet

protected User readUserFromResultSet(java.sql.ResultSet rsUsers)
                              throws java.sql.SQLException
Reads properties for a User from an open ResultSet.

Specified by:
readUserFromResultSet in class AbstractJdbcUsersRepository
Parameters:
rsUsers - A ResultSet with a User record in the current row.
Returns:
A User instance
Throws:
java.sql.SQLException - if an exception occurs reading from the ResultSet

setUserForInsertStatement

protected void setUserForInsertStatement(User user,
                                         java.sql.PreparedStatement userInsert)
                                  throws java.sql.SQLException
Set parameters of a PreparedStatement object with property values from a User instance.

Specified by:
setUserForInsertStatement in class AbstractJdbcUsersRepository
Parameters:
user - a User instance, which should be an implementation class which is handled by this Repostory implementation.
userInsert - a PreparedStatement initialised with SQL taken from the "insert" SQL definition.
Throws:
java.sql.SQLException - if an exception occurs while setting parameter values.

setUserForUpdateStatement

protected void setUserForUpdateStatement(User user,
                                         java.sql.PreparedStatement userUpdate)
                                  throws java.sql.SQLException
Set parameters of a PreparedStatement object with property values from a User instance.

Specified by:
setUserForUpdateStatement in class AbstractJdbcUsersRepository
Parameters:
user - a User instance, which should be an implementation class which is handled by this Repostory implementation.
userUpdate - a PreparedStatement initialised with SQL taken from the "update" SQL definition.
Throws:
java.sql.SQLException - if an exception occurs while setting parameter values.

addUser

public boolean addUser(java.lang.String username,
                       java.lang.String password)
Description copied from interface: UsersRepository
Adds a user to the repository with the specified password

Specified by:
addUser in interface UsersRepository
Overrides:
addUser in class AbstractUsersRepository
Parameters:
username - the username of the user to be added
password - the password of the user to add
Returns:
true if succesful, false otherwise
See Also:
UsersRepository.addUser(java.lang.String, java.lang.String)


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.