felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karl Pauls" <karlpa...@gmail.com>
Subject Re: Running multiple instances of one bundle?
Date Tue, 18 Nov 2008 20:16:15 GMT
You are not running multiple instances of your test case as a bundle.
You are running _one_ instance on the outside.

You are getting confused because you are creating multiple instances
of felix. The problem is they are sharing one instance of your
testcase.

However, what you need to do is to create a bundle with your testcase
inside it. Then you can create multiple instances of felix (as you do
right now) and _load_ the bundle into each of it. This way you will
get what you want.

Assume your app is bundled in ThingWithSingleton.jar.
Then you need to do this:

Map map = new HashMap();
map.put("org.osgi.framework.storage", "felix-cache1");

Felix felix1 = new Felix(map);
felix1.start();
felix1.getBundleContext.installBundle("file:ThingWithSingletion.jar").start();

map.put("org.osgi.framework.storage", "felix-cache2");
Felix felix2 =  new Felix(map);
felix2.start();
felix2.getBundleContext.installBundle("file:ThingWithSingletion.jar").start();

That's it.

regards,

Karl

On Tue, Nov 18, 2008 at 8:54 PM,  <Anthony.Holland@barclayscapital.com> wrote:
> Thanks Karl. Ha ha, yes, my 70 lines are messy, but my messy program is
> 7800 files written over 5 years by 40 people. Not wanting to post this
> to the usergroup I boiled it down to one core case: ThingWithSingleton.
> So for the test case, ThingWithSingleton represents the program that I
> want to run multiple times in one JRE, and I was hoping to use Felix to
> do it in such a way that the singleton would get called "freshly" in
> each bundle, because I figured OSGi can partition up the namespace in
> which classes exist so that classes of the same name could exist twice
> without interfering with each other.
>
> Were you suggesting I run each instance of Felix in a separate JRE? Then
> I may as well just run each instance of my program in a separate JRE
> (and not use Felix). I have reasons for not wanting to do that,
> involving memory management.
>
> You said:
>> I guess the clean way to do this would be to run multiple instances of
>
>> felix site-by-site (i.e., in the same vm).
>
> Having read the link you posted, I thought my program was the way to do
> that. How else would I run multiple instances of Felix in one VM?
>
>
> -----Original Message-----
> From: Karl Pauls [mailto:karlpauls@gmail.com]
> Sent: 18 November 2008 19:39
> To: users@felix.apache.org
> Subject: Re: Running multiple instances of one bundle?
>
> Well, you are doing it sort of the other way around then I was thinking
> of.
>
> Didn't you say that you wanted to use OSGi to run multiple instances of
> a messy program? My suggestion was to use multiple instances of felix
> which each would run one instance of the messy program as a bundle. Your
> example below, on the other hand, is running a single instance of a
> messy program which has multiple instance of felix embedded...
>
> regards,
>
> Karl
>
> On Tue, Nov 18, 2008 at 8:11 PM,  <Anthony.Holland@barclayscapital.com>
> wrote:
>> Paul, unfortunately the below program has the following output. Note
>> that I'm only using reflection in order to give Felix an oppportunity
>> to use it's own class loader, because it seemed pretty obvious that
>> the class
>> (ThingWithSingleton) would get class-loaded before Felix started if I
>> didn't use relection. Code attached.
>>
>> Have I completely misunderstood Felix?
>>
>> Host Activator started.
>> Felix done starting.
>> Host Activator started.
>> singleton already instantiated for number2 Felix done starting.
>> Host Activator started.
>> singleton already instantiated for number3 Felix done starting.
>>
>>
>> -----Original Message-----
>> From: Karl Pauls [mailto:karlpauls@gmail.com]
>> Sent: 18 November 2008 15:01
>> To: users@felix.apache.org
>> Subject: Re: Running multiple instances of one bundle?
>>
>> I guess the clean way to do this would be to run multiple instances of
>
>> felix site-by-site (i.e., in the same vm). This is easily possible and
>
>> you could even bridge some stuff between the frameworks. Have a look
>> at:
>>
>> http://felix.apache.org/site/apache-felix-framework-launching-and-embe
>> dding.html#ApacheFelixFrameworkLaunchingandEmbedding-embedding
>>
>> regards,
>>
>> Karl
>>
>> On Tue, Nov 18, 2008 at 3:54 PM, Richard S. Hall
>> <heavy@ungoverned.org>
>> wrote:
>>> It used to be that you could do this by just installing the bundle
>>> again using a different location, but OSGi R4 added the additional
>>> requirement that the symbolic name + version pair must be unique, so
>>> this is no longer possible.
>>>
>>> It all depends on how isolated you want your instances to be, but one
>
>>> approach is to modify your bundle to provide a factory for creating
>>> instances of you app, then you can creating as many instances as you
> want.
>>>
>>> A hacky approach is to create another copy of your bundle with a
>>> different symbolic name and install two copies.
>>>
>>> -> richard
>>>
>>> Anthony.Holland@barclayscapital.com wrote:
>>>>
>>>> Hi all
>>>>
>>>> Is it possible to run multiple instances of one bundle
> simultaneously?
>>>> The idea here is to use OSGi as a way of running multiple instances,
>
>>>> in one JRE, of a very messy client application that uses lots of
>>>> singletons and so on. The multiple instances would be used to
>>>> load-test a server.
>>>> They would differ only in that they would each "log in" to the
>>>> server using a different userID, which could be passed in as a
>>>> parameter or fetched from a distinct OSGi service.
>>>>
>>>> Thanks,
>>>> Anthony
>>>> _______________________________________________
>>>>
>>>> This e-mail may contain information that is confidential, privileged
>
>>>> or otherwise protected from disclosure. If you are not an intended
>>>> recipient of this e-mail, do not duplicate or redistribute it by any
>
>>>> means. Please delete it and any attachments and notify the sender
>>>> that you have received it in error. Unless specifically indicated,
>>>> this e-mail is not an offer to buy or sell or a solicitation to buy
>>>> or sell any securities, investment products or other financial
>>>> product or service, an official confirmation of any transaction, or
>>>> an official statement of Barclays. Any views or opinions presented
>>>> are solely those of the author and do not necessarily represent
>>>> those of Barclays. This e-mail is subject to terms available at the
>>>> following link: www.barcap.com/emaildisclaimer. By messaging with
>>>> Barclays you consent to the foregoing.  Barclays Capital is the
>>>> investment banking division of Barclays Bank PLC, a company
>>>> registered in England (number
>>>> 1026167) with its registered office at 1 Churchill Place, London,
>>>> E14 5HP.
>>>>  This email may relate to or be sent from other members of the
>>>> Barclays Group.
>>>> _______________________________________________
>>>>
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>> For additional commands, e-mail: users-help@felix.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Karl Pauls
>> karlpauls@gmail.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>> _______________________________________________
>>
>>
>>
>> This e-mail may contain information that is confidential, privileged
>> or otherwise protected from disclosure. If you are not an intended
>> recipient of this e-mail, do not duplicate or redistribute it by any
>> means. Please delete it and any attachments and notify the sender that
>
>> you have received it in error. Unless specifically indicated, this
>> e-mail is not an offer to buy or sell or a solicitation to buy or sell
>
>> any securities, investment products or other financial product or
>> service, an official confirmation of any transaction, or an official
>> statement of Barclays. Any views or opinions presented are solely
>> those of the author and do not necessarily represent those of
>> Barclays. This e-mail is subject to terms available at the following
>> link: www.barcap.com/emaildisclaimer. By messaging with Barclays you
>> consent to the foregoing.  Barclays Capital is the investment banking
>> division of Barclays Bank PLC, a company registered in England (number
>> 1026167) with its registered office at 1 Churchill Place, London, E14
> 5HP.
>> This email may relate to or be sent from other members of the Barclays
>
>> Group.
>>
>> _______________________________________________
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>
>
>
> --
> Karl Pauls
> karlpauls@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
> _______________________________________________
>
> This e-mail may contain information that is confidential, privileged or otherwise protected
from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or
redistribute it by any means. Please delete it and any attachments and notify the sender that
you have received it in error. Unless specifically indicated, this e-mail is not an offer
to buy or sell or a solicitation to buy or sell any securities, investment products or other
financial product or service, an official confirmation of any transaction, or an official
statement of Barclays. Any views or opinions presented are solely those of the author and
do not necessarily represent those of Barclays. This e-mail is subject to terms available
at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent
to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC,
a company registered in England (number 1026167) with its registered office at 1 Churchill
Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays
Group.
> _______________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message