It took me a while but I finally caught up with this thread I think. Wow
logging seems to generate nearly as much mail as discussions on coding
styles ;-)


I hear Geir's concerns and requirements of the LogUser and agree with
various other posters, particularly Costin's points. It got me thinking.
Should we make marker interfaces for setter methods for configuration stuff?

e.g. the Digester uses the pull approach (JAXP) to get a SAX XMLReader; yet
it also provides a setter method, setXMLReader(XMLReader) so that something
else can configure the Digester instance explicitly. So should there be a
XMLReaderEnabled marker interface to indentify components that can have
their XMLReader configured?


My gut feel is no, just use regular bean setters, otherwise it gets messy in
general. A component might have 2 Log instances (like Digester) and so might
need 2 setter methods. If a component needs 2 logs then any 'framework'
wishing to configure it should be able to do so, in which case the marker
interface seems to have little value.


So how about we

(i) agree on a standard method signature(s) we should try to use for setting
log-related information in components (though we don't have to use them).
Then this can be a naming convention or design pattern we follow, then
there's no huge need for a
marker interfade.

e.g.

    void setLog(Log)

(which I've seen in a few commons components already)

    or

    void setLogFactory(LogFactory)


(ii) any 'framework / app' thingy that wants to explicitly set Log objects
can use introspection.

So in Velocity land Geir could use this...

    Log log = myLogThingy;
    Object someComponent = ...;

    PropertyUtils.setProperty(
        someComponent
        "log",
        myLogThingy
    );


rather than...

    Log log = myLogThingy;
    Object someComponent = ...;

    if ( someComponent instanceof LogUser ) {
           ((LogUser) someComponent).setLog( someLogComponent );
    }


(iii) it might be nice to write MBeans for some components which will allow
JMX to manage them nicely which provides a standard hook to configure
components in a much more general way than the LogUser proposal.

James



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


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to