james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: Proposal to factor Common code in James Protocol Servers into AbstractService.
Date Wed, 02 May 2001 23:41:55 GMT
At 05:11  2/5/01 -0700, Harmeet Bedi wrote:
>Here is a specific proposal.
>a) have AbstractService handle configure and any other code in James
>protocol servers for logging etc.

I would prefer a sub-class of AbstractService ... see below

>b) James protocol servers POP3Server etc. will only implement 1 method
><createFactory>. Nothing else.

Actually I think that we can even avoid this - see below...

>This is not directly related to the 'Logging' emails but, but by reducing
>code it would be easier to spot inconsistencies.
>
>thoughts, votes ?

I like the idea - but I would prefer it to be prototyped in James first.
Perhaps something like

public class DefaultNetworkService 
    extends AbstractService {

    protected Class m_clazz;

    protected ConnectionHandlerFactory createFactory()
    {
        return new DefaultHandlerFactory( m_clazz );
    }

    public void configure( final Configuration configuration )
        throws ConfigurationException {

        m_port = configuration.getChild( "port" ).getValueAsInteger();

        try 
        { 
            final String bindAddress = configuration.getChild( "bind"
).getValue( null );
            if( null != bindAddress )
            {
                m_bindTo = InetAddress.getByName( bindAddress ); 
            }
        }
        catch( final UnknownHostException unhe ) 
        {
            throw new ConfigurationException( "Malformed bind parameter",
unhe );
        }

        m_serverSocketType = 
              configuration.getChild( "socket-type" ).getValue( "plain" );

        try
        {
          String className = 
                  configuration.getChild( "handler" ).getValue( "class" );
          m_class = Class.forName( className );
        }

        super.configure( configuration.getChild( "handler" ) );
    }
}



Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message