FileDocCategorySizeDatePackage
AvalonUsersStore.javaAPI DocApache James 2.3.16414Fri Jan 12 12:56:22 GMT 2007org.apache.james.core

AvalonUsersStore

public class AvalonUsersStore extends org.apache.avalon.framework.logger.AbstractLogEnabled implements org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.configuration.Configurable, org.apache.james.services.UsersStore
Provides a registry of user repositories.

Fields Summary
private HashMap
repositories
A mapping of respository identifiers to actual repositories This mapping is obtained from the component configuration
protected org.apache.avalon.framework.context.Context
context
The Avalon context used by the instance
protected org.apache.avalon.framework.configuration.Configuration
configuration
The Avalon configuration used by the instance
protected org.apache.avalon.framework.service.ServiceManager
manager
The Avalon component manager used by the instance
Constructors Summary
Methods Summary
public voidconfigure(org.apache.avalon.framework.configuration.Configuration configuration)

see
org.apache.avalon.framework.configuration.Configurable#configure(Configuration)

        this.configuration = configuration;
    
public voidcontextualize(org.apache.avalon.framework.context.Context context)

see
org.apache.avalon.framework.context.Contextualizable#contextualize(Context)

        this.context = context;
    
public org.apache.james.services.UsersRepositorygetRepository(java.lang.String name)
Get the repository, if any, whose name corresponds to the argument parameter

param
name the name of the desired repository
return
the UsersRepository corresponding to the name parameter

        UsersRepository response = (UsersRepository) repositories.get(name);
        if ((response == null) && (getLogger().isWarnEnabled())) {
            getLogger().warn("No users repository called: " + name);
        }
        return response;
    
public java.util.IteratorgetRepositoryNames()
Yield an Iterator over the set of repository names managed internally by this store.

return
an Iterator over the set of repository names for this store

        return this.repositories.keySet().iterator();
    
public voidinitialize()

see
org.apache.avalon.framework.activity.Initializable#initialize()


        getLogger().info("AvalonUsersStore init...");
        repositories = new HashMap();

        Configuration[] repConfs = configuration.getChildren("repository");
        ClassLoader theClassLoader = null;
        for ( int i = 0; i < repConfs.length; i++ )
        {
            Configuration repConf = repConfs[i];
            String repName = repConf.getAttribute("name");
            String repClass = repConf.getAttribute("class");

            if (getLogger().isDebugEnabled()) {
                getLogger().debug("Starting " + repClass);
            }

            if (theClassLoader == null) {
                theClassLoader = this.getClass().getClassLoader();
            }

            UsersRepository rep = (UsersRepository) theClassLoader.loadClass(repClass).newInstance();

            setupLogger(rep);

            ContainerUtil.contextualize(rep,context);
            ContainerUtil.service(rep,manager);
            if (rep instanceof Composable) {
                final String error = "no implementation in place to support Composable";
                getLogger().error( error );
                throw new IllegalArgumentException( error );
            }
            ContainerUtil.configure(rep,repConf);
            ContainerUtil.initialize(rep);
            
            repositories.put(repName, rep);
            if (getLogger().isInfoEnabled()) {
                StringBuffer logBuffer = 
                    new StringBuffer(64)
                            .append("UsersRepository ")
                            .append(repName)
                            .append(" started.");
                getLogger().info(logBuffer.toString());
            }
        }
        getLogger().info("AvalonUsersStore ...init");
    
public voidservice(org.apache.avalon.framework.service.ServiceManager manager)

see
org.apache.avalon.framework.service.Serviceable#compose(ServiceManager)

        this.manager = manager;