cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <u....@cbim.it>
Subject [RT] Serviceable considered harmful (was Re: XSP not working in CVS head?)
Date Mon, 17 May 2004 14:25:39 GMT
Sylvain Wallez wrote:
> !!!!! A LogicSheet cannot be Serializable !!!!!
> 
> It extends AbstractLogEnabled and has attributes of type ServiceManager 
> and SourceResolver, which aren't serializable !

I'm really starting to appreciate the superior design of a container 
like Spring with respect to Avalon. If the LogicSheet were a 
Spring-managed bean, it would need no fscking ServiceManager:


   <bean id="logicSheet" 
class="org.apache.cocoon.components.language.markup.LogicSheet">
    <property name="xsltProcessor">
      <ref bean="xsltProcessor"/>
    </property>
   </bean>

...

   public class LogicSheet {

     private XSLTProcessor xsltProcessor;

     public void setXsltProcessor(XSLTProcessor xsltProcessor) {
       this.xsltProcessor = xsltProcessor;
     }
     ...
   }

Isn't this neater? No need to implement an Avalon interface. The problem 
is, Serviceable breaks IoC big time. We preach the Hollywood principle 
and then provide almost _ALL_ our components with a big telephone 
directory. Component should be injected with all the needed 
dependencies, not have to look them up through ServiceManager.

And while we're at it, since "AbstractLogEnabled" was mentioned by 
Sylvain, I'll vent my opinion on it too (feel free to spawn a different 
thread if you want to reply to me on this subject). Well, my 
(not-so-)humble opinion is that it sucks! It sucks because we are 
reusing an aspect like "being log-enabled" via concrete *implementation* 
inheritance. If this doesn't suck, in terms of good OO design, the tell 
me what does. And we are doing this just to avoid the hassle of 
declaring a "logger" member, a setter and a getter.

Oh, by the way, LogicSheet extends AbstractLogEnabled but does not 
actually log anything. So I removed "extends AbstractLogEnabled" in my 
local copy and will commit it after the release, if nobody objects.

	Ugo


Mime
View raw message