FileDocCategorySizeDatePackage
EmployeeRegistryBean.javaAPI DocExample1877Tue Jun 08 11:26:42 BST 2004com.mycompany.messages

EmployeeRegistryBean

public class EmployeeRegistryBean extends Object implements Serializable
This class is an example of an application specific interface to a data source (faked here, but it could be a database). It contains methods for authenticating a user, and retrieving and updating user information.
author
Hans Bergsten, Gefion software
version
1.0

Fields Summary
private Map
dataSource
Constructors Summary
Methods Summary
public EmployeeBeanauthenticate(java.lang.String username, java.lang.String password)
Returns an EmployeeBean if the specified user name and password match an employee in the database, otherwise null.

        EmployeeBean empInfo = getEmployee(username);
        if (empInfo != null && empInfo.getPassword().equals(password)) {
            return empInfo;
        }
        return null;
    
public EmployeeBeangetEmployee(java.lang.String username)
Returns an EmployeeBean initialized with the information found in the database for the specified employee, or null if not found.


	return (EmployeeBean) dataSource.get(username);        
    
public voidsaveEmployee(EmployeeBean empInfo)
Inserts the information about the specified employee, or updates the information if it's already defined.

	dataSource.put(empInfo.getUsername(), empInfo);
    
public voidsetDataSource(java.util.Map dataSource)
Sets the dataSource property value.

	if (dataSource != null) {
	    Iterator i = dataSource.entrySet().iterator();
	    while (i.hasNext()) {
		Map.Entry me = (Map.Entry) i.next();
	    }
	}
	
        this.dataSource = dataSource;