Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[e4-dev] Injector Questions

Hi,

I have a few questions about inject usage and dynamic injection. I'm
using the injector directly with without the context.

In my PrimaryObjectSupplier#get implementation I'm registering some
listener somewhere then track is true (i.e. dynamic injection is
enabled). The listeners gets notified of updates which might change the
injection condition. The listener is somewhat associated with the
injected argument. It wraps the passed in requestor so that it can
notify the requestor when a re-injection is necessary.

A change in the condition may mean the an argument becomes invalid so
that it's no-longer suitable of injection. This may lead to a situation
where no replacement argument for injection is available. How are those
intended to be addressed? Currently, IRequestor#resolveArguments logs a
silent message but does not throw any exception. Is it possible to force
an exception in that case?

Is it possible to really un-inject an object, i.e. set all injected
fields explicitly to null even if they are not optional? The JavaDoc of
uninject states that it only works with optional arguments.

How can I remove/dispose listeners that are no longer needed? I noticed
that there seems to be a gap. At some point, I call IInjector#make. This
creates an object that may have dynamic injected arguments (updated when
they change). When the object is no longer needed, the code no longer
references it. Will there be references to it from the IRequestor or
will it be garbage collected at some time?

Assuming it will be garbage collected ... how do I then discover that I
no longer need the listeners? Is that what IRequestor#isValid is for? If
yes then this may lead to a situation where the listeners won't be
removed when the system doesn't change and the listeners aren't
triggered. I'm wondering if there is a better story for this. Any ideas?

Thanks! Any help is really appreciated.

-Gunnar

-- 
Gunnar Wagenknecht
gunnar@xxxxxxxxxxxxxxx
http://wagenknecht.org/



Back to the top