cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Ziegeler <cziege...@apache.org>
Subject Re: [RT] Simplifying component handling
Date Fri, 30 Dec 2005 18:41:14 GMT
Sylvain Wallez wrote:
>>public void dispose() {
>>  if ( m != null ) {
>>    m.release(compA);
>>    m.release(compB);
>>  }
>>}
>>  
> 
> 
> The test "m != null" is useless, as dispose should never be called 
> twice. Removes 2 lines :-)
> 
No, it is not useless - if some exception happens during the init phase
of a component, the service method() might never be called, there "m" is
null. Without the null-test in dispose, you get an NPE :(

> 
> Seriously, I agree that writing less code is good, but not at the price 
> of too black magic implying weaker contracts.
> 
Agreed - ok, so a first step would be to implement the constructor
injection then - this is imho a compatible/transparent addition
simplyfing a lot.
Second step would be to use factories where currently pooled components
are used.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Mime
View raw message