Hi,

I wasn't aware of your need for dependency injection.
In HiveMind 1.1 the autowiring is directly linked with
the BuilderFactory.
This will probably change in the future which will make
it easy to implement a <create-instance> rule
or an object provider with autowiring.

Achim


Am Thu, 21 Dec 2006 23:13:10 +0100 schrieb [EMAIL PROTECTED] <[EMAIL PROTECTED]>:

Hi Achim,

thank you for your reply

when i use instance:service.ServiceAImpl i don't have dependency
injection (DI) so the setReference(IReference r) method of the
ServiceAImpl instance is never called. And the reference within
ServiceAImpl stays null :) Another way to solve this would be
to have a service that reads all objects from the contribution
and sets the reference manually. But this approach implies the
use of at least a common interface with the required setter
method that i want to avoid (..as using reflection)... in fact
can't influence or control (at least not that easy:)).

in my case these objects are provided by a drop-in jar. any object
that requires some sort of infrastructure should provide the desired
setter methods to have it injected by hivemind.

As i understand <invoke-factory> is the only way in hivemind to
have dependency injection. Am i right? :) Wouldn't it be nice to have a
rule like <create-instance> with a autowire attribute? ... just
a thought :)

g,
kris



Achim Hügen wrote:
You could use the object translator and the "instance" ObjectProvider:
 <attribute name="service" translator="object" />
 <contribution configuration-id="serviceconfig">
    <service id="a" service="instance:service.ServiceAImpl" />
    <service id="b" service="instance:service.ServiceBImpl" />
</contribution>
 ServiceAImpl and ServiceBImpl must define a no arguments constructor.
 Achim
Am Tue, 19 Dec 2006 23:05:09 +0100 schrieb kristian marinkovic <[EMAIL PROTECTED]>:

hi,

is it possible to easily create a contribution with services
without actually defining the service explicitly :)
I currently ended up coding something like the xml snippet
below because i want the IReference injected into
ServiceAImpl and ServiceBImpl. Is there a way of applying
Dependency Injection on object created withing <rules>?

g,
kris

    <service-point id="ref" interface="service.IReference">
        <invoke-factory>
            <construct class="service.Reference" />
        </invoke-factory>
    </service-point>

    <service-point id="service_a" interface="service.IServiceA">
        <invoke-factory>
            <construct class="service.ServiceAImpl"/>
        </invoke-factory>
    </service-point>

    <service-point id="service_b" interface="service.IServiceB">
        <invoke-factory>
            <construct class="service.ServiceBImpl"/>
        </invoke-factory>
    </service-point>

    <schema id="services">
        <element name="service" key-attribute="id">
            <attribute name="id"/>
            <attribute name="service" translator="service" />
            <rules>
                <push-attribute attribute="service" />
                <invoke-parent method="addElement" />
            </rules>
        </element>
    </schema>

<configuration-point id="serviceconfig" schema-id="services" />

<contribution configuration-id="serviceconfig">
    <service id="a" service="service_a" />
    <service id="b" service="service_b" />
</contribution>



Reply via email to