FileDocCategorySizeDatePackage
RemoteManager.javaAPI DocApache James 2.3.110407Fri Jan 12 12:56:26 GMT 2007org.apache.james.remotemanager

RemoteManager

public class RemoteManager extends org.apache.james.core.AbstractJamesService implements RemoteManagerMBean
Provides a really rude network interface to administer James. Allow to add accounts. TODO: -improve protocol -add remove user -much more...
version
1.0.0, 24/04/1999

Fields Summary
private HashMap
adminAccounts
A HashMap of (user id, passwords) for James administrators
private org.apache.james.services.UsersStore
usersStore
The UsersStore that contains all UsersRepositories managed by this RemoteManager
private org.apache.james.services.UsersRepository
users
The current UsersRepository being managed/viewed/modified
private String
prompt
The service prompt to be displayed when waiting for input.
private org.apache.james.services.MailServer
mailServer
The reference to the internal MailServer service
private org.apache.avalon.excalibur.pool.Pool
theHandlerPool
The pool used to provide RemoteManager Handler objects
private org.apache.avalon.excalibur.pool.ObjectFactory
theHandlerFactory
The pool used to provide RemoteManager Handler objects
private org.apache.james.util.watchdog.WatchdogFactory
theWatchdogFactory
The factory used to generate Watchdog objects
private RemoteManagerHandlerConfigurationData
theConfigData
The configuration data to be passed to the handler
Constructors Summary
Methods Summary
public voidconfigure(org.apache.avalon.framework.configuration.Configuration configuration)

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


        super.configure(configuration);
        if (isEnabled()) {
            Configuration handlerConfiguration = configuration.getChild("handler");
            Configuration admin = handlerConfiguration.getChild( "administrator_accounts" );
            Configuration[] accounts = admin.getChildren( "account" );
            for ( int i = 0; i < accounts.length; i++ ) {
                adminAccounts.put( accounts[ i ].getAttribute( "login" ),
                                   accounts[ i ].getAttribute( "password" ) );
            }
            Configuration promtConfiguration = handlerConfiguration.getChild("prompt", false);
            if (promtConfiguration != null) prompt = promtConfiguration.getValue();
            if (prompt == null) prompt = ""; 
            else if (!prompt.equals("") && !prompt.endsWith(" ")) prompt += " "; 
        }
    
protected intgetDefaultPort()

see
org.apache.james.core.AbstractJamesService#getDefaultPort()

        return 4555;
     
public java.lang.StringgetServiceType()

see
org.apache.james.core.AbstractJamesService#getServiceType()

        return "Remote Manager Service";
    
public voidinitialize()

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

        super.initialize();
        if (!isEnabled()) {
            return;
        }

        if (connectionLimit != null) {
            theHandlerPool = new HardResourceLimitingPool(theHandlerFactory, 5, connectionLimit.intValue());
            getLogger().debug("Using a bounded pool for RemoteManager handlers with upper limit " + connectionLimit.intValue());
        } else {
            // NOTE: The maximum here is not a real maximum.  The handler pool will continue to
            //       provide handlers beyond this value.
            theHandlerPool = new DefaultPool(theHandlerFactory, null, 5, 30);
            getLogger().debug("Using an unbounded pool for RemoteManager handlers.");
        }
        if (theHandlerPool instanceof LogEnabled) {
            ((LogEnabled)theHandlerPool).enableLogging(getLogger());
        }
        if (theHandlerPool instanceof Initializable) {
            ((Initializable)theHandlerPool).initialize();
        }

        theWatchdogFactory = getWatchdogFactory();
    
protected org.apache.avalon.cornerstone.services.connection.ConnectionHandlernewHandler()

see
org.apache.avalon.cornerstone.services.connection.AbstractHandlerFactory#newHandler()

        RemoteManagerHandler theHandler = (RemoteManagerHandler)theHandlerPool.get();
        theHandler.enableLogging(getLogger());

        Watchdog theWatchdog = theWatchdogFactory.getWatchdog(theHandler.getWatchdogTarget());

        theHandler.setConfigurationData(theConfigData);
        theHandler.setWatchdog(theWatchdog);
        return theHandler;
    
public voidreleaseConnectionHandler(org.apache.avalon.cornerstone.services.connection.ConnectionHandler connectionHandler)

see
org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory#releaseConnectionHandler(ConnectionHandler)

        if (!(connectionHandler instanceof RemoteManagerHandler)) {
            throw new IllegalArgumentException("Attempted to return non-RemoteManagerHandler to pool.");
        }
        theHandlerPool.put((Poolable)connectionHandler);
    
public voidservice(org.apache.avalon.framework.service.ServiceManager componentManager)

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


           
          
          
        super.service(componentManager);
        mailServer = (MailServer)componentManager.
            lookup( MailServer.ROLE );
        usersStore = (UsersStore)componentManager.
            lookup( UsersStore.ROLE );
        users = (UsersRepository) componentManager.lookup(UsersRepository.ROLE);
        if (users == null) {
            throw new ServiceException("","The user repository could not be found.");
        }