You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Krishanu <co...@gmail.com> on 2008/08/18 17:06:43 UTC

Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Hi, 

I am currently working on POCs to check whether we will be able to use OSGI
in my current project, that deals with a framework development using thick
client. If things go well, OSGI will be used for the kernel implementation
of the framework.

My requirement is something like this:
I will have to fetch a bundle(and its dependent bundles) on demand, from a
repository and deploy them in  my OSGI runtime. The order of looking up is:
First, it will look into my local repository, if it finds that   particular
bundle, it fetches it. Otherwise it looks into the remote repository and so
on. Once a bundle(s) have been deployed, it should be available in the local
repository for future reference.

What I have done so far:
I am using felix as an OSGI implementation. I am having a local OBR and a
remote OBR. I have generated the repository.xmls using Bindex tool.
Local obr    : Bundle1-1.0.0, Bundle3-1.0.0
Remote obr : Bundle2-1.0.0, Bundle3-1.0.1
Dependency: Bundle1 depends on Bundle3 and Bundle3 depends on
Bundle2.(B1->B3->B2)

This a code snippet in one of the bundles that I deploy:
RepositoryAdmin repoAdmin = (RepositoryAdmin)serviceTracker.getService();
repoAdmin.addRepository(localRepositoryURL);
repoAdmin.addRepository(remoteRepositoryURL);
Resource[] resources =
repoAdmin.discoverResources("(|(symbolicname=Bundle1))");
Resolver resolver = repoAdmin.resolver();
if (resolver.resolve())
{
   resolver.deploy(true);
}

What is happening as of now:
Bundles Bundle1-1.0.0, Bundle2-1.0.0 and Bundle3-1.0.1 gets installed in my
OSGI runtime and I can see all these jars in the cache directory I did set
using configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "E:/cache");
This is what was expected, and is working properly. 

But, this is what I want, and cant achieve:
Bundle2-1.0.0 and Bundle3-1.0.1 do not get installed in my local OBR. So,
when I uninstall these bundles from my virtual machine(it gets removed from
the cache), all the bundles again needs to get fetched from the remote URL
with the next reference of Bundle1.

Can you please give me some pointers about how I can retain the bundles
installed in OSGI virtual machine in some local OBR(residing on same
machine); so that even after it has been uninstalled from the runtime;  the
jars won't have to be fetched from the remote OBR. I understand, that I need
to regenerate my local repository.xml with every installation in local
repository, if it happens.

I have not used OSGI in any of my previous applications, so an elaborate
answer is highly appreciated.

thanks,
krish
-- 
View this message in context: http://www.nabble.com/Retaining-bundles-installed-in-OSGI-virtual-machine-from-remote-OBR%2C-in-local-OBR-tp19033664p19033664.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Felix Meschberger wrote:
> Hi,
>
> Richard S. Hall schrieb:
>   
>> Stuart McCulloch wrote:
>>     
>>> 2008/8/28 Felix Meschberger <fm...@gmail.com>
>>>       
>>>> I completely agree. Why not change the RepositoryAdminImpl as
>>>> proposed by
>>>> Krishanu. This would at least give a somewhat easier user experience
>>>> in that
>>>> the user might just get the repositories back in the order of calling
>>>> the
>>>> add method (mostly though because referrals may add additional
>>>> repositories,
>>>> which might interfere, but I think this is a minor issue here).
>>>>
>>>> WDYT ?
>>>>
>>>>     
>>>>         
>>> +1, using LinkedHashMap would also make things more more consistent
>>> between
>>> runs
>>>   
>>>       
>> I am not against making them ordered either, it shouldn't impact
>> anything else I don't think.
>>     
>
> Hmm, LinkedHashMap has a drawback: It is only available in JRE 1.4 and
> later. To be able to run the bundlerepository bundle in JRE 1.3
> (assuming there are still people out there using this) we have to
> probably find a different solution.
>   

Yep, that would be an issue.

-> richard

> Regards
> Felix
>
>   
>> -> richard
>>     
>>>  
>>>       
>>>> Regards
>>>> Felix
>>>>
>>>>
>>>>
>>>>
>>>>    
>>>>         
>>>>> -> richard
>>>>>
>>>>> Krishanu wrote:
>>>>>
>>>>>      
>>>>>           
>>>>>> Thanks a ton Richard. Following your algorithm, I could achieve
>>>>>> exactly
>>>>>> what I was looking for.
>>>>>> The only thing I find a little finicky, is that, we can not specify a
>>>>>> sequence in which the repositories needs to get searched( correct
>>>>>> me if I
>>>>>> am
>>>>>> wrong) for the bundle resolving to happen. To achieve that, I had to
>>>>>> modify
>>>>>> the felix OBR source code. I changed the map definition in
>>>>>> RepositoryAdminImpl class to "private Map m_repoMap = new
>>>>>> LinkedHashMap();"
>>>>>> from simple hashmap. Please suggest if there is a better way to do it.
>>>>>> Just to reiterate my requirement, I need to resolve the bundle from
>>>>>> my local
>>>>>> repository(if it is already there), and then look into the remote
>>>>>> repositories in the specified order.
>>>>>>
>>>>>> ->krish
>>>>>>
>>>>>>
>>>>>>         
>>>>>>             
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>> ---------------------------------------------------------------------
>> 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
>
>   

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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Richard S. Hall schrieb:
> Stuart McCulloch wrote:
>> 2008/8/28 Felix Meschberger <fm...@gmail.com>
>>> I completely agree. Why not change the RepositoryAdminImpl as
>>> proposed by
>>> Krishanu. This would at least give a somewhat easier user experience
>>> in that
>>> the user might just get the repositories back in the order of calling
>>> the
>>> add method (mostly though because referrals may add additional
>>> repositories,
>>> which might interfere, but I think this is a minor issue here).
>>>
>>> WDYT ?
>>>
>>>     
>>
>> +1, using LinkedHashMap would also make things more more consistent
>> between
>> runs
>>   
> 
> I am not against making them ordered either, it shouldn't impact
> anything else I don't think.

Hmm, LinkedHashMap has a drawback: It is only available in JRE 1.4 and
later. To be able to run the bundlerepository bundle in JRE 1.3
(assuming there are still people out there using this) we have to
probably find a different solution.

Regards
Felix

> 
> -> richard
>>
>>  
>>> Regards
>>> Felix
>>>
>>>
>>>
>>>
>>>    
>>>> -> richard
>>>>
>>>> Krishanu wrote:
>>>>
>>>>      
>>>>> Thanks a ton Richard. Following your algorithm, I could achieve
>>>>> exactly
>>>>> what I was looking for.
>>>>> The only thing I find a little finicky, is that, we can not specify a
>>>>> sequence in which the repositories needs to get searched( correct
>>>>> me if I
>>>>> am
>>>>> wrong) for the bundle resolving to happen. To achieve that, I had to
>>>>> modify
>>>>> the felix OBR source code. I changed the map definition in
>>>>> RepositoryAdminImpl class to "private Map m_repoMap = new
>>>>> LinkedHashMap();"
>>>>> from simple hashmap. Please suggest if there is a better way to do it.
>>>>> Just to reiterate my requirement, I need to resolve the bundle from
>>>>> my local
>>>>> repository(if it is already there), and then look into the remote
>>>>> repositories in the specified order.
>>>>>
>>>>> ->krish
>>>>>
>>>>>
>>>>>         
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>>     
>>
>>
>>   
> 
> ---------------------------------------------------------------------
> 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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Stuart McCulloch wrote:
> 2008/8/28 Felix Meschberger <fm...@gmail.com>
>
>   
>> Hi,
>>
>> Richard S. Hall schrieb:
>>
>>     
>>> I think you are correct, it currently does not allow you to control the
>>> order in which it searches the repositories. This is a general issue and is
>>> somewhat complicated to handle in a generic way. Another similar issue is
>>> that if two or more repositories offer the same bundles or bundles that
>>> offer the same needed capabilities, how to know from which repository to
>>> choose. If you strictly have an ordered set, then it might be possible to
>>> deal with it, but in the general case it is difficult.
>>>
>>>       
>> I completely agree. Why not change the RepositoryAdminImpl as proposed by
>> Krishanu. This would at least give a somewhat easier user experience in that
>> the user might just get the repositories back in the order of calling the
>> add method (mostly though because referrals may add additional repositories,
>> which might interfere, but I think this is a minor issue here).
>>
>> WDYT ?
>>
>>     
>
> +1, using LinkedHashMap would also make things more more consistent between
> runs
>   

I am not against making them ordered either, it shouldn't impact 
anything else I don't think.

-> richard
>
>   
>> Regards
>> Felix
>>
>>
>>
>>
>>     
>>> -> richard
>>>
>>> Krishanu wrote:
>>>
>>>       
>>>> Thanks a ton Richard. Following your algorithm, I could achieve exactly
>>>> what I was looking for.
>>>> The only thing I find a little finicky, is that, we can not specify a
>>>> sequence in which the repositories needs to get searched( correct me if I
>>>> am
>>>> wrong) for the bundle resolving to happen. To achieve that, I had to
>>>> modify
>>>> the felix OBR source code. I changed the map definition in
>>>> RepositoryAdminImpl class to "private Map m_repoMap = new
>>>> LinkedHashMap();"
>>>> from simple hashmap. Please suggest if there is a better way to do it.
>>>> Just to reiterate my requirement, I need to resolve the bundle from my local
>>>> repository(if it is already there), and then look into the remote
>>>> repositories in the specified order.
>>>>
>>>> ->krish
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>     
>
>
>   

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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by Stuart McCulloch <st...@jayway.net>.
2008/8/28 Felix Meschberger <fm...@gmail.com>

> Hi,
>
> Richard S. Hall schrieb:
>
>> I think you are correct, it currently does not allow you to control the
>> order in which it searches the repositories. This is a general issue and is
>> somewhat complicated to handle in a generic way. Another similar issue is
>> that if two or more repositories offer the same bundles or bundles that
>> offer the same needed capabilities, how to know from which repository to
>> choose. If you strictly have an ordered set, then it might be possible to
>> deal with it, but in the general case it is difficult.
>>
>
> I completely agree. Why not change the RepositoryAdminImpl as proposed by
> Krishanu. This would at least give a somewhat easier user experience in that
> the user might just get the repositories back in the order of calling the
> add method (mostly though because referrals may add additional repositories,
> which might interfere, but I think this is a minor issue here).
>
> WDYT ?
>

+1, using LinkedHashMap would also make things more more consistent between
runs


> Regards
> Felix
>
>
>
>
>> -> richard
>>
>> Krishanu wrote:
>>
>>> Thanks a ton Richard. Following your algorithm, I could achieve exactly
>>> what I was looking for.
>>> The only thing I find a little finicky, is that, we can not specify a
>>> sequence in which the repositories needs to get searched( correct me if I
>>> am
>>> wrong) for the bundle resolving to happen. To achieve that, I had to
>>> modify
>>> the felix OBR source code. I changed the map definition in
>>> RepositoryAdminImpl class to "private Map m_repoMap = new
>>> LinkedHashMap();"
>>> from simple hashmap. Please suggest if there is a better way to do it.
>>> Just to reiterate my requirement, I need to resolve the bundle from my local
>>> repository(if it is already there), and then look into the remote
>>> repositories in the specified order.
>>>
>>> ->krish
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>


-- 
Cheers, Stuart

Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Richard S. Hall schrieb:
> I think you are correct, it currently does not allow you to control the 
> order in which it searches the repositories. This is a general issue and 
> is somewhat complicated to handle in a generic way. Another similar 
> issue is that if two or more repositories offer the same bundles or 
> bundles that offer the same needed capabilities, how to know from which 
> repository to choose. If you strictly have an ordered set, then it might 
> be possible to deal with it, but in the general case it is difficult.

I completely agree. Why not change the RepositoryAdminImpl as proposed 
by Krishanu. This would at least give a somewhat easier user experience 
in that the user might just get the repositories back in the order of 
calling the add method (mostly though because referrals may add 
additional repositories, which might interfere, but I think this is a 
minor issue here).

WDYT ?

Regards
Felix


> 
> -> richard
> 
> Krishanu wrote:
>> Thanks a ton Richard. Following your algorithm, I could achieve 
>> exactly what I was looking for.
>> The only thing I find a little finicky, is that, we can not specify a
>> sequence in which the repositories needs to get searched( correct me 
>> if I am
>> wrong) for the bundle resolving to happen. To achieve that, I had to 
>> modify
>> the felix OBR source code. I changed the map definition in
>> RepositoryAdminImpl class to "private Map m_repoMap = new 
>> LinkedHashMap();"
>> from simple hashmap. Please suggest if there is a better way to do it. 
>> Just to reiterate my requirement, I need to resolve the bundle from my 
>> local
>> repository(if it is already there), and then look into the remote
>> repositories in the specified order.
>>
>> ->krish
>>   
> 
> ---------------------------------------------------------------------
> 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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by "Richard S. Hall" <he...@ungoverned.org>.
I think you are correct, it currently does not allow you to control the 
order in which it searches the repositories. This is a general issue and 
is somewhat complicated to handle in a generic way. Another similar 
issue is that if two or more repositories offer the same bundles or 
bundles that offer the same needed capabilities, how to know from which 
repository to choose. If you strictly have an ordered set, then it might 
be possible to deal with it, but in the general case it is difficult.

-> richard

Krishanu wrote:
> Thanks a ton Richard. 
> Following your algorithm, I could achieve exactly what I was looking for.
> The only thing I find a little finicky, is that, we can not specify a
> sequence in which the repositories needs to get searched( correct me if I am
> wrong) for the bundle resolving to happen. To achieve that, I had to modify
> the felix OBR source code. I changed the map definition in
> RepositoryAdminImpl class to "private Map m_repoMap = new LinkedHashMap();"
> from simple hashmap. Please suggest if there is a better way to do it. 
> Just to reiterate my requirement, I need to resolve the bundle from my local
> repository(if it is already there), and then look into the remote
> repositories in the specified order.
>
> ->krish
>   

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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by Krishanu <co...@gmail.com>.
Thanks a ton Richard. 
Following your algorithm, I could achieve exactly what I was looking for.
The only thing I find a little finicky, is that, we can not specify a
sequence in which the repositories needs to get searched( correct me if I am
wrong) for the bundle resolving to happen. To achieve that, I had to modify
the felix OBR source code. I changed the map definition in
RepositoryAdminImpl class to "private Map m_repoMap = new LinkedHashMap();"
from simple hashmap. Please suggest if there is a better way to do it. 
Just to reiterate my requirement, I need to resolve the bundle from my local
repository(if it is already there), and then look into the remote
repositories in the specified order.

->krish
-- 
View this message in context: http://www.nabble.com/Retaining-bundles-installed-in-OSGI-virtual-machine-from-remote-OBR%2C-in-local-OBR-tp19033664p19090292.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


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


Re: Retaining bundles installed in OSGI virtual machine from remote OBR, in local OBR

Posted by "Richard S. Hall" <he...@ungoverned.org>.
I am not sure if I understand your use case entirely, but it sounds like 
you want to pull bundles from a remote OBR and keep them around in a 
local OBR, even if you uninstall them from the framework. If that is the 
case, you really need to make your deployment a three-step process:

   1. First, use the remote OBR to resolve the dependencies.
   2. Then see which bundles it has selected and download these yourself
      to stick them into your local repository.
   3. Finally, deploy the bundles from the remote repository. (Or you
      could deploy them from the local repository at this point.)

Is that what you are getting at?

-> richard

Krishanu wrote:
> Hi, 
>
> I am currently working on POCs to check whether we will be able to use OSGI
> in my current project, that deals with a framework development using thick
> client. If things go well, OSGI will be used for the kernel implementation
> of the framework.
>
> My requirement is something like this:
> I will have to fetch a bundle(and its dependent bundles) on demand, from a
> repository and deploy them in  my OSGI runtime. The order of looking up is:
> First, it will look into my local repository, if it finds that   particular
> bundle, it fetches it. Otherwise it looks into the remote repository and so
> on. Once a bundle(s) have been deployed, it should be available in the local
> repository for future reference.
>
> What I have done so far:
> I am using felix as an OSGI implementation. I am having a local OBR and a
> remote OBR. I have generated the repository.xmls using Bindex tool.
> Local obr    : Bundle1-1.0.0, Bundle3-1.0.0
> Remote obr : Bundle2-1.0.0, Bundle3-1.0.1
> Dependency: Bundle1 depends on Bundle3 and Bundle3 depends on
> Bundle2.(B1->B3->B2)
>
> This a code snippet in one of the bundles that I deploy:
> RepositoryAdmin repoAdmin = (RepositoryAdmin)serviceTracker.getService();
> repoAdmin.addRepository(localRepositoryURL);
> repoAdmin.addRepository(remoteRepositoryURL);
> Resource[] resources =
> repoAdmin.discoverResources("(|(symbolicname=Bundle1))");
> Resolver resolver = repoAdmin.resolver();
> if (resolver.resolve())
> {
>    resolver.deploy(true);
> }
>
> What is happening as of now:
> Bundles Bundle1-1.0.0, Bundle2-1.0.0 and Bundle3-1.0.1 gets installed in my
> OSGI runtime and I can see all these jars in the cache directory I did set
> using configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "E:/cache");
> This is what was expected, and is working properly. 
>
> But, this is what I want, and cant achieve:
> Bundle2-1.0.0 and Bundle3-1.0.1 do not get installed in my local OBR. So,
> when I uninstall these bundles from my virtual machine(it gets removed from
> the cache), all the bundles again needs to get fetched from the remote URL
> with the next reference of Bundle1.
>
> Can you please give me some pointers about how I can retain the bundles
> installed in OSGI virtual machine in some local OBR(residing on same
> machine); so that even after it has been uninstalled from the runtime;  the
> jars won't have to be fetched from the remote OBR. I understand, that I need
> to regenerate my local repository.xml with every installation in local
> repository, if it happens.
>
> I have not used OSGI in any of my previous applications, so an elaborate
> answer is highly appreciated.
>
> thanks,
> krish
>   

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