You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Vinicius Carvalho <ja...@gmail.com> on 2005/07/18 22:14:02 UTC

Question on Ioc

Hello there! I've asked this before in another topic...
I know that Hivemind uses dependency injection in a trasparent way (it
could be using setter or constructor right). But I'm always getting an
error when trying to set via setter, all my services have the same
interface and implementation (they differ only on another injected
property), and so hivemind complains about not being able to find the
right service (I'm sorry I don't have the message right now) and tells
me to disable autowiring. I
 tried <constructor ..autowire-services="false"> and then...
<service>productDAO</service>

my classe has a setDAO(DAO dao) method. but it's not working. But when
I modify the constructor of the class to receive a DAO instance, it
works fine.

Any ideias???

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Question on Ioc

Posted by Hugo Palma <hp...@digitalis.pt>.
Hope this helps.
What i usually do to construct a service and inject some properties 
using setters is:

<service-point id="MyServiceid" interface="org.mypackage.MyInterface">
    <invoke-factory>
       <construct class="org.mypackage.MyClass">
          <set-object property="myproperty" value="myvalue"/>
       </construct>
    </invoke-factory>
</service-point>


Cheers

Hugo

Vinicius Carvalho wrote:
> Thanks Knut, I'm sorry for the dumb question, but this is not very
> well described on the docs. I haven't see that <set-*> parameter you
> spoke of. So If I want to instantiate a class and use setter
> injection, I must not use <constructor> element? Could you send me an
> example?
> 
> Thanks a lot
> 
> On 7/19/05, Knut Wannheden <kn...@gmail.com> wrote:
> 
>>Vinicius,
>>
>>The <service> element is for constructor based injection only. All the
>><set-*> elements are for setter based injection while the others are
>>for constructor based injection. Further, if you use any constructor
>>parameter elements at all, then these must match an existing
>>constructor.
>>
>>HTH,
>>
>>--knut
>>
>>On 7/18/05, Vinicius Carvalho <ja...@gmail.com> wrote:
>>
>>>Hello there! I've asked this before in another topic...
>>>I know that Hivemind uses dependency injection in a trasparent way (it
>>>could be using setter or constructor right). But I'm always getting an
>>>error when trying to set via setter, all my services have the same
>>>interface and implementation (they differ only on another injected
>>>property), and so hivemind complains about not being able to find the
>>>right service (I'm sorry I don't have the message right now) and tells
>>>me to disable autowiring. I
>>> tried <constructor ..autowire-services="false"> and then...
>>><service>productDAO</service>
>>>
>>>my classe has a setDAO(DAO dao) method. but it's not working. But when
>>>I modify the constructor of the class to receive a DAO instance, it
>>>works fine.
>>>
>>>Any ideias???
>>>
>>>Thanks
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
>>>
>>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Question on Ioc

Posted by Knut Wannheden <kn...@gmail.com>.
Vinicius,

On 7/19/05, Vinicius Carvalho <ja...@gmail.com> wrote:
> Thanks Knut, I'm sorry for the dumb question, but this is not very
> well described on the docs. I haven't see that <set-*> parameter you
> spoke of. So If I want to instantiate a class and use setter
> injection, I must not use <constructor> element? Could you send me an
> example?
> 

You must have missed the documentation on the BuilderFactory:
http://jakarta.apache.org/hivemind/hivemind/BuilderFactory.html. It's
linked to from the description of <invoke-factory>. By <set-*> I was
referring to the various elements starting with "set-"; like
<set-configuration>, <set-service>, and <set-object>.

--knut

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Question on Ioc

Posted by Vinicius Carvalho <ja...@gmail.com>.
Thanks Knut, I'm sorry for the dumb question, but this is not very
well described on the docs. I haven't see that <set-*> parameter you
spoke of. So If I want to instantiate a class and use setter
injection, I must not use <constructor> element? Could you send me an
example?

Thanks a lot

On 7/19/05, Knut Wannheden <kn...@gmail.com> wrote:
> Vinicius,
> 
> The <service> element is for constructor based injection only. All the
> <set-*> elements are for setter based injection while the others are
> for constructor based injection. Further, if you use any constructor
> parameter elements at all, then these must match an existing
> constructor.
> 
> HTH,
> 
> --knut
> 
> On 7/18/05, Vinicius Carvalho <ja...@gmail.com> wrote:
> > Hello there! I've asked this before in another topic...
> > I know that Hivemind uses dependency injection in a trasparent way (it
> > could be using setter or constructor right). But I'm always getting an
> > error when trying to set via setter, all my services have the same
> > interface and implementation (they differ only on another injected
> > property), and so hivemind complains about not being able to find the
> > right service (I'm sorry I don't have the message right now) and tells
> > me to disable autowiring. I
> >  tried <constructor ..autowire-services="false"> and then...
> > <service>productDAO</service>
> >
> > my classe has a setDAO(DAO dao) method. but it's not working. But when
> > I modify the constructor of the class to receive a DAO instance, it
> > works fine.
> >
> > Any ideias???
> >
> > Thanks
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: Question on Ioc

Posted by Knut Wannheden <kn...@gmail.com>.
Vinicius,

The <service> element is for constructor based injection only. All the
<set-*> elements are for setter based injection while the others are
for constructor based injection. Further, if you use any constructor
parameter elements at all, then these must match an existing
constructor.

HTH,

--knut

On 7/18/05, Vinicius Carvalho <ja...@gmail.com> wrote:
> Hello there! I've asked this before in another topic...
> I know that Hivemind uses dependency injection in a trasparent way (it
> could be using setter or constructor right). But I'm always getting an
> error when trying to set via setter, all my services have the same
> interface and implementation (they differ only on another injected
> property), and so hivemind complains about not being able to find the
> right service (I'm sorry I don't have the message right now) and tells
> me to disable autowiring. I
>  tried <constructor ..autowire-services="false"> and then...
> <service>productDAO</service>
> 
> my classe has a setDAO(DAO dao) method. but it's not working. But when
> I modify the constructor of the class to receive a DAO instance, it
> works fine.
> 
> Any ideias???
> 
> Thanks
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: hivemind-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org