On 3/22/07, Stefano Bagnara <[EMAIL PROTECTED]> wrote:
robert burrell donkin ha scritto:
> i took a look at the avalon coupling. IIRC the major issue is going to
> be logging.

Wrong: the LogEnabled issue can be solved with a simple search and
replace and is trivial once we agree on the solution (agreement is not
trivial here)

The major issue instead is the code using ContainerUtil to propagate
avalon lifecycles to child objects.

this is just the same general problem as logging: in each case the
question is how to propogate container specific configurations through
the object graph. in the case of logging, we want to propogate logging
settings throughout the object graph. in the case of lifecycles, we
want to propogate settings.

Almost an year I took care to replace every
---
if (object instanceof ServiceEnablingInterface) {
   ((ServiceEnablingInterface) object).serviceEnable(service);
}
---
with the equivalent ContainerUtil.serviceEnable(object, service), so it
should be easy to run a find in files for the ContainerUtil object to
understand what is happening.

i like the pico-container approach to lifecycles: define your own
lifecycle interfaces appropriate to the problem and then glue together
with byte-code engineering.

but you're right that construction of child objects is an issue

Imho the key is to create factory services so that you never inject the
lifecycle but instead you ask a factory to provide you a lifecycled
object. Once we'll have removed the ContainerUtil usage with top level
avalon services it will be trivial to extract the avalon interfaces to
avalon-specific extensions of the "pojo" services.

the design issue that will need to be overcome with factory services
is how to inject these services whilst avoiding unwanted coupling. not
impossible, but possibly messy (i don't know the codebase well enough
to make a good judgement about that).

i had been thinking thinking about just using protected factory
methods within each POJO for the moment. it's not great from a design
perspective but is quick and reliable.

a more elegant solution would be to use aspects for container support.
cross-cuts may save a lot of legwork.

but i need to take a closer look at the code...

- robert

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

Reply via email to