| org.apache.james.userrepository.AbstractUsersRepository org.apache.james.userrepository.AbstractJdbcUsersRepository
All known Subclasses: org.apache.james.userrepository.ListUsersJdbcRepository, org.apache.james.userrepository.JamesUsersJdbcRepository, org.apache.james.userrepository.DefaultUsersJdbcRepository,
AbstractJdbcUsersRepository | abstract public class AbstractJdbcUsersRepository extends AbstractUsersRepository implements Contextualizable,Serviceable,Configurable,Initializable(Code) | | An abstract base class for creating UserRepository implementations
which use a database for persistence.
To implement a new UserRepository using by extending this class,
you need to implement the 3 abstract methods defined below,
and define the required SQL statements in an SQLResources
file.
The SQL statements used by this implementation are:
| Required |
select | Select all users. |
insert | Insert a user. |
update | Update a user. |
delete | Delete a user by name. |
createTable | Create the users table. |
| Optional |
selectByLowercaseName | Select a user by name (case-insensitive lowercase). |
|
Method Summary | |
public void | configure(Configuration configuration) | public void | contextualize(Context context) | protected void | doAddUser(User user) Adds a user to the underlying Repository. | protected void | doRemoveUser(User user) Removes a user from the underlying repository. | protected void | doUpdateUser(User user) Updates a user record to match the supplied User. | protected User | getUserByName(String name, boolean ignoreCase) Gets a user by name, ignoring case if specified. | public void | initialize() | protected Iterator | listAllUsers() Returns a list populated with all of the Users in the repository. | protected List | listUserNames() Produces the complete list of User names, with correct case. | abstract protected User | readUserFromResultSet(ResultSet rsUsers) Reads properties for a User from an open ResultSet.
Subclass implementations of this method must have knowledge of the fields
presented by the "select" and "selectByLowercaseName" SQL statements.
These implemenations may generate a subclass-specific User instance.
Parameters: rsUsers - A ResultSet with a User record in the current row. | public void | service(ServiceManager componentManager) | abstract protected void | setUserForInsertStatement(User user, PreparedStatement userInsert) Set parameters of a PreparedStatement object with
property values from a User instance. | abstract protected void | setUserForUpdateStatement(User user, PreparedStatement userUpdate) Set parameters of a PreparedStatement object with
property values from a User instance. |
context | protected Context context(Code) | | The Avalon context used by the instance
|
m_sqlParameters | protected Map m_sqlParameters(Code) | | |
configure | public void configure(Configuration configuration) throws ConfigurationException(Code) | | Configures the UserRepository for JDBC access.
Requires a configuration element in the .conf.xml file of the form:
<repository name="LocalUsers"
class="org.apache.james.userrepository.JamesUsersJdbcRepository">
<!-- Name of the datasource to use -->
<data-source>MailDb</data-source>
<!-- File to load the SQL definitions from -->
<sqlFile>dist/conf/sqlResources.xml</sqlFile>
<!-- replacement parameters for the sql file -->
<sqlParameters table="JamesUsers"/>
</repository>
|
contextualize | public void contextualize(Context context) throws ContextException(Code) | | See Also: org.apache.avalon.framework.context.Contextualizable.contextualize(Context) |
doAddUser | protected void doAddUser(User user)(Code) | | Adds a user to the underlying Repository.
The user name must not clash with an existing user.
Parameters: user - the user to be added |
doRemoveUser | protected void doRemoveUser(User user)(Code) | | Removes a user from the underlying repository.
If the user doesn't exist this method doesn't throw
an exception.
Parameters: user - the user to be removed |
doUpdateUser | protected void doUpdateUser(User user)(Code) | | Updates a user record to match the supplied User.
Parameters: user - the updated user record |
getUserByName | protected User getUserByName(String name, boolean ignoreCase)(Code) | | Gets a user by name, ignoring case if specified.
If the specified SQL statement has been defined, this method
overrides the basic implementation in AbstractUsersRepository
to increase performance.
Parameters: name - the name of the user being retrieved Parameters: ignoreCase - whether the name is regarded as case-insensitive the user being retrieved, null if the user doesn't exist |
initialize | public void initialize() throws Exception(Code) | | Initialises the JDBC repository.
1) Tests the connection to the database.
2) Loads SQL strings from the SQL definition file,
choosing the appropriate SQL for this connection,
and performing parameter substitution,
3) Initialises the database with the required tables, if necessary.
throws: Exception - if an error occurs |
listAllUsers | protected Iterator listAllUsers()(Code) | | Returns a list populated with all of the Users in the repository.
an Iterator of JamesUser s. |
listUserNames | protected List listUserNames()(Code) | | Produces the complete list of User names, with correct case.
a List of String s representinguser names. |
readUserFromResultSet | abstract protected User readUserFromResultSet(ResultSet rsUsers) throws SQLException(Code) | | Reads properties for a User from an open ResultSet.
Subclass implementations of this method must have knowledge of the fields
presented by the "select" and "selectByLowercaseName" SQL statements.
These implemenations may generate a subclass-specific User instance.
Parameters: rsUsers - A ResultSet with a User record in the current row. A User instance throws: SQLException - if an exception occurs reading from the ResultSet |
service | public void service(ServiceManager componentManager) throws ServiceException(Code) | | See Also: org.apache.avalon.framework.service.Serviceable.compose(ServiceManager) |
setUserForInsertStatement | abstract protected void setUserForInsertStatement(User user, PreparedStatement userInsert) throws SQLException(Code) | | Set parameters of a PreparedStatement object with
property values from a User instance.
Implementations of this method have knowledge of the parameter
ordering of the "insert" SQL statement definition.
Parameters: user - a User instance, which should be an implementation class whichis handled by this Repostory implementation. Parameters: userInsert - a PreparedStatement initialised with SQL taken from the "insert" SQL definition. throws: SQLException - if an exception occurs while setting parameter values. |
setUserForUpdateStatement | abstract protected void setUserForUpdateStatement(User user, PreparedStatement userUpdate) throws SQLException(Code) | | Set parameters of a PreparedStatement object with
property values from a User instance.
Implementations of this method have knowledge of the parameter
ordering of the "update" SQL statement definition.
Parameters: user - a User instance, which should be an implementation class whichis handled by this Repostory implementation. Parameters: userUpdate - a PreparedStatement initialised with SQL taken from the "update" SQL definition. throws: SQLException - if an exception occurs while setting parameter values. |
|
|