You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Harmeet Bedi <hb...@yahoo.com> on 2001/05/02 14:11:44 UTC

Proposal to factor Common code in James Protocol Servers into AbstractService.

There is a some common code in

james/pop3server/POP3Server.java
james/smtpserver/SMTPServer.java
james/remotemanager/RemoteManager.java
james/imapserver/IMAPServer.java
james/nntpserver/NNTPServer.java

All of these classes derive from
avalon/cornerstone/services/connection/AbstractService.

If the base class handled <configure> then the only code needed would be
implementation of
    protected ConnectionHandlerFactory createFactory();

I don't think this vastly improves the James system but it would have these
benefits:
- duplication would be removed. This would mean consistent behaviour and
better maintainability.
- If the code could be factored into Avalon, other prototocol servers that
are not related to James but do similar things to POP, SMTP etc. could reuse
the same pattern.
- Avalon Stack will be more full featured and would capture the code pattern
better. This may make Avalon more attractive.




Here is a specific proposal.
a) have AbstractService handle configure and any other code in James
protocol servers for logging etc.
b) James protocol servers POP3Server etc. will only implement 1 method
<createFactory>. Nothing else.

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

thoughts, votes ?

Harmeet


----- Original Message -----
From: "Peter Donald" <do...@apache.org>
To: <ja...@jakarta.apache.org>
Sent: Wednesday, May 02, 2001 3:08 AM
Subject: Re: Logging


> At 10:23  2/5/01 +0000, Charles Benett wrote:
> >How can we get the logging from SMTPHandler into the smtpserver.log and
> >that from POP3Handler into the POP3server.log? At the moment they mainly
> >log to connections.log.
>
> ug thats a bug in cornerstone.blocks.connection I think. You should be
able
> to fix it by removing the line "setupLogger( m_handler );" in
> cornerstone.blocks.connection.ConnectionRunner.run().
>
> >I thought this was a case of calling setupLogger(this, smtp) to create a
> >category connections.smtp. Then in server.xml, category smtpserver and
> >category connections.smtp could be pointed at the same target.
>
> If that was called from a block named "connections" then this would be the
> case. However the handler is created in block smtpserver so that should be
> fine (once you fix the above bug).
>
> >(And my
> >Avalon question was: could we till do that under your new proposal).
>
> yep. About the only differency is that default category priority (ie
> debug/warn) for smtp will be taken from connections category.
>
> >However, looking today, SMTPHandler extends BaseConnectionHandler. But
> >BaseConnectionHandler is logging to the right log (line 71) whereas
> >SMTPHandler and POP3Handler aren't. As they all use getLogger(), I'm
> >mystified as to how they can be logging to different places.
>
> basically SMTP/POP3Handlers have setLogger() called multiple times and
> second time wipes out original logger object ;/
> 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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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


Re: Proposal to factor Common code in James Protocol Servers into AbstractService.

Posted by Peter Donald <do...@apache.org>.
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