FileDocCategorySizeDatePackage
NNTPServer.javaAPI DocApache James 2.3.18756Fri Jan 12 12:56:24 GMT 2007org.apache.james.nntpserver

NNTPServer

public class NNTPServer extends org.apache.james.core.AbstractJamesService implements NNTPServerMBean
NNTP Server

Fields Summary
private boolean
authRequired
Whether authentication is required to access this NNTP server
private org.apache.james.nntpserver.repository.NNTPRepository
repo
The repository that stores the news articles for this NNTP server.
private org.apache.james.services.UsersRepository
userRepository
The repository that stores the local users. Used for authentication.
private org.apache.avalon.excalibur.pool.Pool
theHandlerPool
The pool used to provide NNTP Handler objects
private org.apache.avalon.excalibur.pool.ObjectFactory
theHandlerFactory
The pool used to provide NNTP Handler objects
private org.apache.james.util.watchdog.WatchdogFactory
theWatchdogFactory
The factory used to generate Watchdog objects
private NNTPHandlerConfigurationData
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");
            authRequired =
                handlerConfiguration.getChild("authRequired").getValueAsBoolean(false);
            if (getLogger().isDebugEnabled()) {
                if (authRequired) {
                    getLogger().debug("NNTP Server requires authentication.");
                } else {
                    getLogger().debug("NNTP Server doesn't require authentication.");
                }
            }
        }
    
protected intgetDefaultPort()

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

        return 119;
     
public java.lang.StringgetServiceType()

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

        return "NNTP 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 NNTP 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 NNTP 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()

        NNTPHandler theHandler = (NNTPHandler)theHandlerPool.get();

        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 NNTPHandler)) {
            throw new IllegalArgumentException("Attempted to return non-NNTPHandler 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);
        userRepository = (UsersRepository)componentManager.lookup(UsersRepository.ROLE);

        repo = (NNTPRepository)componentManager
            .lookup("org.apache.james.nntpserver.repository.NNTPRepository");