Antti Koivunen wrote:

Nicola Ken Barozzi wrote:

Andrzej Jan Taramina wrote:

Antti said:


2. Logger, LogEnabled & Co.

I wouldn't include these in the core interfaces. Logger is just another
component that could be acquired through the context. This might also help
to reduce friction between different projects, as using Avalon wouldn't
force them to use a specific logging interface.


Absolutely agree.


Actually, I don't, but I still do %-)

Imagine that I (admion) have my happy Avalon container running services. Then I get a VeryNiceService and want to add it to my services.

What I would imagine is that I can manage the confifuration and the Logging in the same way as other services... oops, I cannot. I have to learn another logging package. Another configuration system. Blah.

Is this doable with Avalon4... nope ;-)


So, yes, I agree that the current way of doing things can be replaced as you say above. But what I would really like, is a way of managing the above things in a completely uniform manner.

I see your point, but dont't worry :) We could still have have our AbstractLoggable, but this time it could even support several logging implementations:

Object logger = context.get(LOGGER);
if (logger instanceof avalon.Logger) {
m_logger = (avalon.Logger) logger;
} else if (logger instanceof commons.Log) {
m_logger = new Commons2AvalonLogger((commons.Log) logger);
}

This would of course also work the other way round, i.e. you could put an instance of VeryNiceLogger2AvalonLogger to the context of VeryNiceService. However, if VeryNiceCompany had never heard of Avalon (or IoC), and used static factories for accessing the loggers, there'd be little we could do without changing the code.

Burrrrk!
(i.e. I don;t like the approach)

:-)

It's putting responsibility into the component to do defensive thinking. What the container needs to know is "what does this component need to do its stuff" - and what the component needs to know is that "the container is going to give it what it needs". So lets consider this in more detail:

Component declares a logging strategy to the container:

<type>
<loggers>
<attributes>
<attribute key="urn:assembly:lifecycle.logging.strategy"
value="org.somwhere.MyPreferredLoggingInterface"/>
</attributes>
</loggers>
</type>

Cantainer reolves a logging handler and uses this during the logging stage of the deployment lifecycle.

Take a look in avalon-sandbox/merlin/src/test/org/apache/avalon/playground/
You will find the file: StandardComponent.xinfo. This component is doing exactly the same thing except its declaring that it wants to use a custom context interface. If you run the merlin demo you will see it working:

$ merlin -profile config/demo.xml

Cheers, Steve.

--

Stephen J. McConnell
mailto:[EMAIL PROTECTED]
http://www.osm.net




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

Reply via email to