(1) service locator option: names of impl classes are stored in META-
INF/services/ as resource files.

PROS: I believe this is what generally recommended by Sun
CONS: The resource files are supposed to be read by class loader and
class loaders in non-trivial environments tend to create non-trivial
problems (think commons-logging)

Please, please, please don't do this! :)� Going off searching for resources that may or may not exist is very very bad in applets as it causes the ClassLoader to send a request back to the server which then returns a 404 and logs it.� This seriously reduces performance and really annoys web administrators.� I've not come across a lookup scheme that didn't cause huge problems for applets yet.

(2) dependency injection option: dependent interface or a class factory
is introduced though a setter or a contractor parameter

PROS: No need to retrieve any data from a file; Compatibility with
popular DI/IoC containers
CONS: Somewhat uglier API

Big fan of this - simple, effective and easily understood.

Oleg

Adrian Sutton.

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to