You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Peter Klotz <pe...@blue-elephant-systems.com> on 2006/06/26 14:25:10 UTC
dependencies betweem LW SM components and other Spring beans
Hi,
a question regarding servicemix-lwcontainer. I have both SM lightweight
components that participate in message exchanges as well as many helper Spring
beans outside of
<sm:serviceunit id="jbi">
<sm:activationSpecs>
...
</sm:activationSpecs>
</sm:serviceunit>
what works well is that a SM component has a property that is a reference to a
bean outside but I have problems defining a property in a bean that references a
SM componnt or a property between two SM components that use Spring properterty
references
So in
<sm:serviceunit id="jbi">
<sm:activationSpecs>
<sm:activationSpec componentName="sm-bean" service="bes:sm-bean"
endpoint="sm-bean">
<sm:component>
<bean id="sm-bean" class="...">
<property name="other"> <!-- this works fine -->
<ref local="other-bean"/>
</property>
<property name="other-sm"> <!-- this does not -->
<ref local="other-sm-bean"/>
</property>
</bean>
</sm:component>
</sm:activationSpec>
<sm:activationSpec componentName="other-sm-bean"
service="bes:other-sm-bean" endpoint="other-sm-bean">
<sm:component>
<bean id="other-sm-bean" class="..."/>
</sm:component>
</sm:activationSpec>
</sm:activationSpecs>
</sm:serviceunit>
<bean id="bean" class="...">
<property name="property"> <!-- this does not -->
<ref local="sm-bean"/>
</property>
</bean>
<bean id="other-bean" class="..."/>
Why would these 2 cases not work, a SM bean is a Spring bean and should behave
like one? Or is there a trick?
Please don't come back and say why do these two beans not use a ME, the one is a
receiver and the other a sender and a normal backend-bean might need a sending
bean. So I really want a property here.
Thanks, Peter
Re: dependencies betweem LW SM components and other Spring beans
Posted by Guillaume Nodet <gn...@gmail.com>.
On 6/27/06, Peter Klotz <pe...@blue-elephant-systems.com> wrote:
>
> Guillaume Nodet wrote:
> > Spring references only works with top-level beans.
> > So you should also define your component as a reference, using
> > <sm:activationSpec component="#myComponent" .../>
> > and
> > <bean id="myComponent">
> > ...
> > </>
>
> as you see in my example I try this, sm-bean has componentName set,
> I also tried all combinations of #sm-bean or sm-bean the error that
> is reported is that in the "bean" bean the reference "sm-bean" or
> "#sm-bean"
> however I try it is not found.
The componentName attribute is used by ServiceMix as a display string, the
same way it is used
when put in the jbi descriptor. The component attribute is of
javax.jbi.Component type and you
should try this one.
Also, keep in mind, that all references beans have to be top-level beans, ie
you can not reference a bean which has been defined inside a property, a
list, or something like that.
Cheers,
Guillaume Nodet
>> <sm:serviceunit id="jbi">
> >> <sm:activationSpecs>
> >> <sm:activationSpec componentName="sm-bean" service="bes:sm-bean"
> >> endpoint="sm-bean">
> >> <sm:component>
> >> <bean id="sm-bean" class="...">
> [...]
> >> </bean>
> >> </sm:component>
> >> </sm:activationSpec>
> [...]
> >> </sm:activationSpecs>
> >> </sm:serviceunit>
> >>
> >> <bean id="bean" class="...">
> >> <property name="property"> <!-- this does not -->
> >> <ref local="sm-bean"/>
> >> </property>
> >> </bean>
>
> on the SM-component both id and componentName are set but the bean outside
> of
> the SU bean cannot access the SM-bean anyway.
>
>
> Peter
>
>
Re: dependencies betweem LW SM components and other Spring beans
Posted by Peter Klotz <pe...@blue-elephant-systems.com>.
Guillaume Nodet wrote:
> Spring references only works with top-level beans.
> So you should also define your component as a reference, using
> <sm:activationSpec component="#myComponent" .../>
> and
> <bean id="myComponent">
> ...
> </>
as you see in my example I try this, sm-bean has componentName set,
I also tried all combinations of #sm-bean or sm-bean the error that
is reported is that in the "bean" bean the reference "sm-bean" or "#sm-bean"
however I try it is not found.
>> <sm:serviceunit id="jbi">
>> <sm:activationSpecs>
>> <sm:activationSpec componentName="sm-bean" service="bes:sm-bean"
>> endpoint="sm-bean">
>> <sm:component>
>> <bean id="sm-bean" class="...">
[...]
>> </bean>
>> </sm:component>
>> </sm:activationSpec>
[...]
>> </sm:activationSpecs>
>> </sm:serviceunit>
>>
>> <bean id="bean" class="...">
>> <property name="property"> <!-- this does not -->
>> <ref local="sm-bean"/>
>> </property>
>> </bean>
on the SM-component both id and componentName are set but the bean outside of
the SU bean cannot access the SM-bean anyway.
Peter
Re: dependencies betweem LW SM components and other Spring beans
Posted by Guillaume Nodet <gn...@gmail.com>.
This is the xbean style for referencing other beans.
This is a shortcut for
<sm:activationSpec>
<property name="component" ref="myComponent"/>
Cheers,
Guillaume Nodet
On 6/29/06, Stefan Kleineikenscheidt <st...@kleineikenscheidt.de> wrote:
>
>
> Hi Guillaume,
>
> What does the '#' stand for?
>
> > <sm:activationSpec component="#myComponent" .../>
> ^^^
> > and
> > <bean id="myComponent">
> > ...
> > </>
>
> Is that XBean-style or is Spring? (Didn't find anything in the docs)
>
> Thanks for any insight.
>
> -Stefan
>
>
>
> -----Original Message-----
> From: Guillaume Nodet [mailto:gnodet@gmail.com]
> Sent: Monday, June 26, 2006 11:15 PM
> To: servicemix-users@geronimo.apache.org
> Subject: Re: dependencies betweem LW SM components and other Spring beans
>
> Spring references only works with top-level beans.
> So you should also define your component as a reference, using
> <sm:activationSpec component="#myComponent" .../>
> and
> <bean id="myComponent">
> ...
> </>
>
> Cheers,
> Guillaume Nodet
>
> On 6/26/06, Peter Klotz <pe...@blue-elephant-systems.com> wrote:
> >
> > Hi,
> >
> > a question regarding servicemix-lwcontainer. I have both SM lightweight
> > components that participate in message exchanges as well as many helper
> > Spring
> > beans outside of
> >
> > <sm:serviceunit id="jbi">
> > <sm:activationSpecs>
> > ...
> > </sm:activationSpecs>
> > </sm:serviceunit>
> >
> > what works well is that a SM component has a property that is a
> reference
> > to a
> > bean outside but I have problems defining a property in a bean that
> > references a
> > SM componnt or a property between two SM components that use Spring
> > properterty
> > references
> >
> > So in
> >
> > <sm:serviceunit id="jbi">
> > <sm:activationSpecs>
> > <sm:activationSpec componentName="sm-bean" service="bes:sm-bean"
> > endpoint="sm-bean">
> > <sm:component>
> > <bean id="sm-bean" class="...">
> > <property name="other"> <!-- this works fine -->
> > <ref local="other-bean"/>
> > </property>
> > <property name="other-sm"> <!-- this does not -->
> > <ref local="other-sm-bean"/>
> > </property>
> > </bean>
> > </sm:component>
> > </sm:activationSpec>
> >
> > <sm:activationSpec componentName="other-sm-bean"
> > service="bes:other-sm-bean" endpoint="other-sm-bean">
> > <sm:component>
> > <bean id="other-sm-bean" class="..."/>
> > </sm:component>
> > </sm:activationSpec>
> > </sm:activationSpecs>
> > </sm:serviceunit>
> >
> > <bean id="bean" class="...">
> > <property name="property"> <!-- this does not -->
> > <ref local="sm-bean"/>
> > </property>
> > </bean>
> >
> > <bean id="other-bean" class="..."/>
> >
> >
> > Why would these 2 cases not work, a SM bean is a Spring bean and should
> > behave
> > like one? Or is there a trick?
> >
> > Please don't come back and say why do these two beans not use a ME, the
> > one is a
> > receiver and the other a sender and a normal backend-bean might need a
> > sending
> > bean. So I really want a property here.
> >
> >
> > Thanks, Peter
> >
> >
>
>
RE: dependencies betweem LW SM components and other Spring beans
Posted by Stefan Kleineikenscheidt <st...@kleineikenscheidt.de>.
Hi Guillaume,
What does the '#' stand for?
> <sm:activationSpec component="#myComponent" .../>
^^^
> and
> <bean id="myComponent">
> ...
> </>
Is that XBean-style or is Spring? (Didn't find anything in the docs)
Thanks for any insight.
-Stefan
-----Original Message-----
From: Guillaume Nodet [mailto:gnodet@gmail.com]
Sent: Monday, June 26, 2006 11:15 PM
To: servicemix-users@geronimo.apache.org
Subject: Re: dependencies betweem LW SM components and other Spring beans
Spring references only works with top-level beans.
So you should also define your component as a reference, using
<sm:activationSpec component="#myComponent" .../>
and
<bean id="myComponent">
...
</>
Cheers,
Guillaume Nodet
On 6/26/06, Peter Klotz <pe...@blue-elephant-systems.com> wrote:
>
> Hi,
>
> a question regarding servicemix-lwcontainer. I have both SM lightweight
> components that participate in message exchanges as well as many helper
> Spring
> beans outside of
>
> <sm:serviceunit id="jbi">
> <sm:activationSpecs>
> ...
> </sm:activationSpecs>
> </sm:serviceunit>
>
> what works well is that a SM component has a property that is a reference
> to a
> bean outside but I have problems defining a property in a bean that
> references a
> SM componnt or a property between two SM components that use Spring
> properterty
> references
>
> So in
>
> <sm:serviceunit id="jbi">
> <sm:activationSpecs>
> <sm:activationSpec componentName="sm-bean" service="bes:sm-bean"
> endpoint="sm-bean">
> <sm:component>
> <bean id="sm-bean" class="...">
> <property name="other"> <!-- this works fine -->
> <ref local="other-bean"/>
> </property>
> <property name="other-sm"> <!-- this does not -->
> <ref local="other-sm-bean"/>
> </property>
> </bean>
> </sm:component>
> </sm:activationSpec>
>
> <sm:activationSpec componentName="other-sm-bean"
> service="bes:other-sm-bean" endpoint="other-sm-bean">
> <sm:component>
> <bean id="other-sm-bean" class="..."/>
> </sm:component>
> </sm:activationSpec>
> </sm:activationSpecs>
> </sm:serviceunit>
>
> <bean id="bean" class="...">
> <property name="property"> <!-- this does not -->
> <ref local="sm-bean"/>
> </property>
> </bean>
>
> <bean id="other-bean" class="..."/>
>
>
> Why would these 2 cases not work, a SM bean is a Spring bean and should
> behave
> like one? Or is there a trick?
>
> Please don't come back and say why do these two beans not use a ME, the
> one is a
> receiver and the other a sender and a normal backend-bean might need a
> sending
> bean. So I really want a property here.
>
>
> Thanks, Peter
>
>
Re: dependencies betweem LW SM components and other Spring beans
Posted by Guillaume Nodet <gn...@gmail.com>.
Spring references only works with top-level beans.
So you should also define your component as a reference, using
<sm:activationSpec component="#myComponent" .../>
and
<bean id="myComponent">
...
</>
Cheers,
Guillaume Nodet
On 6/26/06, Peter Klotz <pe...@blue-elephant-systems.com> wrote:
>
> Hi,
>
> a question regarding servicemix-lwcontainer. I have both SM lightweight
> components that participate in message exchanges as well as many helper
> Spring
> beans outside of
>
> <sm:serviceunit id="jbi">
> <sm:activationSpecs>
> ...
> </sm:activationSpecs>
> </sm:serviceunit>
>
> what works well is that a SM component has a property that is a reference
> to a
> bean outside but I have problems defining a property in a bean that
> references a
> SM componnt or a property between two SM components that use Spring
> properterty
> references
>
> So in
>
> <sm:serviceunit id="jbi">
> <sm:activationSpecs>
> <sm:activationSpec componentName="sm-bean" service="bes:sm-bean"
> endpoint="sm-bean">
> <sm:component>
> <bean id="sm-bean" class="...">
> <property name="other"> <!-- this works fine -->
> <ref local="other-bean"/>
> </property>
> <property name="other-sm"> <!-- this does not -->
> <ref local="other-sm-bean"/>
> </property>
> </bean>
> </sm:component>
> </sm:activationSpec>
>
> <sm:activationSpec componentName="other-sm-bean"
> service="bes:other-sm-bean" endpoint="other-sm-bean">
> <sm:component>
> <bean id="other-sm-bean" class="..."/>
> </sm:component>
> </sm:activationSpec>
> </sm:activationSpecs>
> </sm:serviceunit>
>
> <bean id="bean" class="...">
> <property name="property"> <!-- this does not -->
> <ref local="sm-bean"/>
> </property>
> </bean>
>
> <bean id="other-bean" class="..."/>
>
>
> Why would these 2 cases not work, a SM bean is a Spring bean and should
> behave
> like one? Or is there a trick?
>
> Please don't come back and say why do these two beans not use a ME, the
> one is a
> receiver and the other a sender and a normal backend-bean might need a
> sending
> bean. So I really want a property here.
>
>
> Thanks, Peter
>
>