james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicola Ken Barozzi" <nicola...@apache.org>
Subject Re: [Mailet API] Logging Proposal
Date Mon, 10 Jun 2002 19:48:09 GMT
Noel J. Bergman wrote:
 > [Needless to say, these definitions include only the logging related
 > portion]
 >
 > interface MailetContext
 > {
 >    org.apache.avalon.framework.logger.Logger getLogger();
 >
 >    void log(String message);              // deprecated
 >    void log(String message, Throwable t); // deprecated
 > }
 >
 > abstract class GenericMailet implements Mailet, MailetConfig
 > {
 >    void log(String message);              // deprecated
 >    void log(String message, Throwable t); // deprecated
 >
 >    /*
 >  allows getLogger()."cat"(msg[, t]) instead of
 >       getMailetContext().getLogger()."cat"(message[, t]);
 >
 >       implementation may wrap the logger to include
 >       config.getMailetName() + ": " in the message
 >
 >     */
 >    org.apache.avalon.framework.logger.Logger getLogger();
 > }
 >
 > Alternative would be to break with the Mailet v1 API entirely, and go
with:
 >
 >    interface Mailet extends org.apache.avalon.framework.logger.LogEnabled
 >
 > but I'm less inclined in that direction.
 >
 > Please comment with specific changes (or even rewrites), so we can
keep the
 > discussion concrete.

Ok, good :-)

Personally, I always prefer not to have utility methods, and have only
one way of doing things. Which would mean keeping logging only in the
Context, and keep the Mailet interface free of it.

On the other hand, I think that using avalon logging without inversion
of control is not really gaining the benefits...
Having a getLogger instead of two log methods is not very different, and
the current way, if we stay with the above proposal, is better.
Why tie the classes to Avalon just to get a Logger?
In this sense, I understand what you were saying on logging.

Let me try to show you a more deeply Avalonized solution...


interface MailetContext
    implements org.apache.avalon.framework.context.Context
{
     void log(String message);              // deprecated
     void log(String message, Throwable t); // deprecated
}

abstract class Mailet
   implements org.apache.avalon.framework.logging.LogEnabled,
              org.apache.avalon.framework.context.Contextualizable
              org.apache.avalon.framework.parameters.Parameterizable
{

     void enableLogging( Logger logger );

     void contextualize( Context context )
          throws ContextException;

      void parameterize( Parameters parameters )
          throws ParameterException;
}


As you see, here we have inversion of control.
It's not the Mailet that asks, but the container that gives.

--
Nicola Ken Barozzi                   nicolaken@apache.org
              - verba volant, scripta manent -
     (discussions get forgotten, just code remains)
---------------------------------------------------------------------


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


Mime
View raw message