Stefano Bagnara wrote:
Alan D. Cabrera wrote:
I want to critically look at the statement
if (obj instanceof Disposable) (Disposable) obj).dispose();
More frequently you will find ContainerUtil.dispose(obj) that is the
same thing, but cleaner to read and simplify code "browsability".
which is being used not in the container but inside server objects.
This strikes me as odd since IMO the interface should be a marker for
the container. It should not be a plea to sibling code to please
call this method at the appropriate time.
THe problem is that you think to Avalon as a "Container stuff" while
avalon is an application framework.
That said, James is implemented using the avalon application
framework, so the patterns/code included in Avalon are used in James
internals, like the dnsjava library, or a common-collection framework.
Avalon compliant containers manage the top-level application
wiring/lifecycle/configuration but the internal handling of more
granular object is left to the components. Most components use the
avalon framework to do that: James often manage sub-components
lifecycle/configuration/dependecies this way.
Ok, this clears it up for me.
When ever I see a statement like that inside the server code I say to
myself "All instances of this object should just implement Disposable
and those that don't want to do anything should have empty method
implementations".
This is another solution to the same problem: we could use
reflections, or we could deprecate the disposable and use the
finalizer method, or we could use an "object manager" that create
objects and keep track of their lifecycle.
I don't think that generally speaking one solution is always better
than the other and I didn't analyze the specific "dispose" methods in
James.
I see at least some big issue to not do the change:
- backward compatibility
I'm curious, does this statement assume that others have embedded James?
- I don't generally like having lifecycle methods or pattern specific
methods in business interfaces.
Agreed.
Regards,
Alan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]