Stefano Bagnara wrote:
Alan,

I think that we should start by steps, and I'm sure we'll find a few problems in the first refactorings. Then we'll have some concrete things to talk about and to decide.

Removing Avalon is like removing the "concurrency.jar" framework: it is a framework and not "container code". If you want to remove it you have to replace it with something else.

One example:

Disposable is an Avalon interface meaning the object has a "dispose()" method that should be called when disposing it.

Our MimeMessageWrapper depends on this dispose() method being called.

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();
--

To remove the Disposable interface you have 2 options:
1) clone the Disposable interface in a james package and keep the same behaviour code (change only the import)
2) change the whole behaviour/pattern used.

That said, about the 2 solutions:
1) I'm currently AGAINST this code cloning: I don't get the advantages of cloning the avalon.jar code to the james sources. I would switch to custom interfaces ONLY if we need different interfaces.


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.

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

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

Reply via email to