You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Sorin Silaghi <so...@gmail.com> on 2011/09/05 14:24:25 UTC

Prototype scope doesn't work with osgi:service

Hi all,


            I need to declare a service that has scope="prototype" but it
doesn't seem to work. Here's what I did:

<bean id="randomFileListFTPClient"
class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
scope="prototype"/>
<osgi:service id="randomFileListFTPClientService"
ref="randomFileListFTPClient"
interface="org.apache.commons.net.ftp.FTPClient" />


            I also tried scope="bundle" and it's the same thing. I expected
that to work. Any ideas ?


thank you,
                Sorin.

Re: Prototype scope doesn't work with osgi:service

Posted by Sorin Silaghi <so...@gmail.com>.
Well for now I just exported the class and using spring to create the bean
in the SA where I need it. I'll try to figure something out later on.

On Mon, Sep 5, 2011 at 9:16 PM, Johan Edstrom <se...@gmail.com> wrote:

> True :)
>
> A Managed Service Factory would work though….
> Not exactly the same thing since the starting bundle would hold more
> responsibility.
>
>
>
> On Sep 5, 2011, at 12:08 PM, Guillaume Nodet wrote:
>
> > The factory result is cached by the framework on a per bundle basis.
> >
> > On Monday, September 5, 2011, Johan Edstrom <se...@gmail.com> wrote:
> >> Use a servicefactory.
> >>
> >> On Sep 5, 2011, at 6:24 AM, Sorin Silaghi wrote:
> >>
> >>> Hi all,
> >>>
> >>>
> >>>           I need to declare a service that has scope="prototype" but it
> >>> doesn't seem to work. Here's what I did:
> >>>
> >>> <bean id="randomFileListFTPClient"
> >>> class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
> >>> scope="prototype"/>
> >>> <osgi:service id="randomFileListFTPClientService"
> >>> ref="randomFileListFTPClient"
> >>> interface="org.apache.commons.net.ftp.FTPClient" />
> >>>
> >>>
> >>>           I also tried scope="bundle" and it's the same thing. I
> > expected
> >>> that to work. Any ideas ?
> >>>
> >>>
> >>> thank you,
> >>>               Sorin.
> >>
> >>
> >
> > --
> > ------------------------
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> > ------------------------
> > Open Source SOA
> > http://fusesource.com
>
>

Re: Prototype scope doesn't work with osgi:service

Posted by Johan Edstrom <se...@gmail.com>.
True :)

A Managed Service Factory would work though….
Not exactly the same thing since the starting bundle would hold more responsibility.



On Sep 5, 2011, at 12:08 PM, Guillaume Nodet wrote:

> The factory result is cached by the framework on a per bundle basis.
> 
> On Monday, September 5, 2011, Johan Edstrom <se...@gmail.com> wrote:
>> Use a servicefactory.
>> 
>> On Sep 5, 2011, at 6:24 AM, Sorin Silaghi wrote:
>> 
>>> Hi all,
>>> 
>>> 
>>>           I need to declare a service that has scope="prototype" but it
>>> doesn't seem to work. Here's what I did:
>>> 
>>> <bean id="randomFileListFTPClient"
>>> class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
>>> scope="prototype"/>
>>> <osgi:service id="randomFileListFTPClientService"
>>> ref="randomFileListFTPClient"
>>> interface="org.apache.commons.net.ftp.FTPClient" />
>>> 
>>> 
>>>           I also tried scope="bundle" and it's the same thing. I
> expected
>>> that to work. Any ideas ?
>>> 
>>> 
>>> thank you,
>>>               Sorin.
>> 
>> 
> 
> -- 
> ------------------------
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com


Re: Prototype scope doesn't work with osgi:service

Posted by Guillaume Nodet <gn...@gmail.com>.
The factory result is cached by the framework on a per bundle basis.

On Monday, September 5, 2011, Johan Edstrom <se...@gmail.com> wrote:
> Use a servicefactory.
>
> On Sep 5, 2011, at 6:24 AM, Sorin Silaghi wrote:
>
>> Hi all,
>>
>>
>>            I need to declare a service that has scope="prototype" but it
>> doesn't seem to work. Here's what I did:
>>
>> <bean id="randomFileListFTPClient"
>> class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
>> scope="prototype"/>
>> <osgi:service id="randomFileListFTPClientService"
>> ref="randomFileListFTPClient"
>> interface="org.apache.commons.net.ftp.FTPClient" />
>>
>>
>>            I also tried scope="bundle" and it's the same thing. I
expected
>> that to work. Any ideas ?
>>
>>
>> thank you,
>>                Sorin.
>
>

-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Prototype scope doesn't work with osgi:service

Posted by Johan Edstrom <se...@gmail.com>.
Use a servicefactory.

On Sep 5, 2011, at 6:24 AM, Sorin Silaghi wrote:

> Hi all,
> 
> 
>            I need to declare a service that has scope="prototype" but it
> doesn't seem to work. Here's what I did:
> 
> <bean id="randomFileListFTPClient"
> class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
> scope="prototype"/>
> <osgi:service id="randomFileListFTPClientService"
> ref="randomFileListFTPClient"
> interface="org.apache.commons.net.ftp.FTPClient" />
> 
> 
>            I also tried scope="bundle" and it's the same thing. I expected
> that to work. Any ideas ?
> 
> 
> thank you,
>                Sorin.


Re: Prototype scope doesn't work with osgi:service

Posted by Sorin Silaghi <so...@gmail.com>.
I'm trying to create a service that would behave exactly as a prototype
bean. I'll give spring proxy a look.


Thanks.

On Mon, Sep 5, 2011 at 3:36 PM, Guillaume Nodet <gn...@gmail.com> wrote:

> What kind of behavior do you expect ?
> OSGi does not support a per-invocation creation so a single service
> (or possibly one per calling bundle) is created.
> If you looking for a per-invocation proxy, maybe using a spring proxy
> would help.
>
> On Mon, Sep 5, 2011 at 14:24, Sorin Silaghi <so...@gmail.com> wrote:
> > Hi all,
> >
> >
> >            I need to declare a service that has scope="prototype" but it
> > doesn't seem to work. Here's what I did:
> >
> > <bean id="randomFileListFTPClient"
> > class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
> > scope="prototype"/>
> > <osgi:service id="randomFileListFTPClientService"
> > ref="randomFileListFTPClient"
> > interface="org.apache.commons.net.ftp.FTPClient" />
> >
> >
> >            I also tried scope="bundle" and it's the same thing. I
> expected
> > that to work. Any ideas ?
> >
> >
> > thank you,
> >                Sorin.
> >
>
>
>
> --
> ------------------------
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>

Re: Prototype scope doesn't work with osgi:service

Posted by Guillaume Nodet <gn...@gmail.com>.
What kind of behavior do you expect ?
OSGi does not support a per-invocation creation so a single service
(or possibly one per calling bundle) is created.
If you looking for a per-invocation proxy, maybe using a spring proxy
would help.

On Mon, Sep 5, 2011 at 14:24, Sorin Silaghi <so...@gmail.com> wrote:
> Hi all,
>
>
>            I need to declare a service that has scope="prototype" but it
> doesn't seem to work. Here's what I did:
>
> <bean id="randomFileListFTPClient"
> class="de.edigrid.util.servicemix.strategy.RandomFileListFTPClient"
> scope="prototype"/>
> <osgi:service id="randomFileListFTPClientService"
> ref="randomFileListFTPClient"
> interface="org.apache.commons.net.ftp.FTPClient" />
>
>
>            I also tried scope="bundle" and it's the same thing. I expected
> that to work. Any ideas ?
>
>
> thank you,
>                Sorin.
>



-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com