james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Zhukov <zhu...@ukrpost.net>
Subject Re: [James-NG] Avalon-free James proposal and reference implementation
Date Sun, 06 Feb 2005 12:52:36 GMT
Hes Siemelink wrote:
> Alexander Zhukov wrote:
> 
>> You might ask: "what do you mean, man?" :)
>>
>> Example:
>>
>> BAD:
>> class MyComponent ... {
>>     init() {
>>        context = InitialContext();
>>        Service s = context.lookup(...);
>>     }
>>
>>     run() {
>>        s.doSomething();
>>     }
>> }
>>
>> GOOD: (acceptable but not an excelent design solution)
>> class MyComponent {
>>     public MyComponent(Context ctx, ...) {
>>         Service s = ctx.lookup()
>>     }
>>
>>     run() {
>>        s.doSomething();
>>     }
>> }
> 
> 

You example is best-case scenario
CSI is not a good name though :) because Service in your example is just 
a dependency, which means CDI name still applies

> And if I understand correctly, CSI (Constructor Service Injection ;-) 
> would be
> 
> class MyComponent {
>    Service service;
> 
>    public MyComponent(Service service) {
>        this.service = service;
>    }
> 
>    run() {
>       service.doSomething();
>    }
> }
> 
> I think the latter approach is cleanest from an OO-modeling pointof 
> view, but what matters most is that the approach is consistent 
> throughout an application or library.
> 
> Cheers,
> 
>    Hes.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 


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


Mime
View raw message