Bernd Fondermann wrote:
Stefano Bagnara wrote:
MailImpl objects have references to MimeMessageWrappers and are Disposable too. When we destroy MailImpls we call ContainerUtil.dispose(mail) or if you prefer we write this code:
--
if (mail instanceof Disposable) ((Disposable) mail).dispose();
--
[...]
2) This kind of pattern is used in many places in James: btw, how would you change it?

one strategy would be to make the current indirection even more indirect:

change ContainerUtils.dispose() so that it looks up a method dispose() on the parameter object and calls it, instead of typecasting.

then remove the Disposable interface from all James classes.

IMHO this is a step in the wrong direction.

The interface is not a limitation of James portability.

I'm -1 on removing our working interfaces in favor of reflections. THis is not good programming. I'm against bad practice to follow the POJO religion.

should work quite well. but it of course fails for those dispose() calls from within Avalon which rely on the Disposable interface.

(another approach would be proxying)

--

if this refactoring could be iterated over the code base the components could be more easily put in a different container because they are free from Avalon marker interfaces.

for example, a container could be configured to call the dispose() method declarative where Avalon uses Disposable casts.
pseudocode: <component class="X" onDestroy="dispose" />
(while dispose calls from within James still use the ContainerUtils-approach.)

  Bernd

We can do this without removing the Disposable interface.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to