james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hes Siemelink <hes-l...@izecom.com>
Subject Re: [James-NG] Avalon-free James proposal and reference implementation
Date Sat, 05 Feb 2005 02:53:00 GMT
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();
>     }
> }

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


Mime
View raw message