avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antti Koivunen <anryo...@users.sourceforge.net>
Subject Re: Avalon 5 Core Interfaces
Date Thu, 30 Jan 2003 06:57:51 GMT
Sorry for the delayed reply.

Stephen McConnell wrote:
> 
> 
> Antti Koivunen wrote:
> 
<snip/>
>>
>>   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)
> 
> :-)

(figured as much ;)

I suppose it does rather look like a hack :) And actually it would be 
possible to also hack around the static factory thing by using custom 
classloaders.


> 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.

Yes, this is a nice feature.


> 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

I get the following error:


commencing block construction phase

[ERROR  ] (sys): Message: Block installation phase failure.
===================================================================

Exception: java.lang.ClassCastException
null

===================================================================
java.lang.ClassCastException
	at 
org.apache.excalibur.source.impl.SourceResolverImpl.service(SourceResolverImpl.java:173)
	at 
org.apache.avalon.merlin.block.impl.DefaultBlockLoader.initialize(DefaultBlockLoader.java:280)
	at 
org.apache.avalon.merlin.kernel.impl.DefaultKernel.initialize(DefaultKernel.java:387)
	at 
org.apache.avalon.merlin.kernel.impl.KernelLoader.<init>(KernelLoader.java:108)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
	at Merlin.main(Merlin.java:284)
===================================================================

(: A ;)
-- 
Antti Koivunen (Mr.) <anryoshi@users.sf.net>


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


Mime
View raw message