You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Mahammad Nasir <ma...@huawei.com> on 2010/04/13 11:27:21 UTC

How to check if a bundle is already installed?

 
HI,
I have bundle name /bundle symbolic name. and i have a bundle path which i
want to install next. But for some reason i must check if a bundle is
already installed or not. i have around 100 bundles installed.
 
How can i check if a bundle is already installed? i dint find any api to
check if it is already installed. Pls help me
 
 
Regards
Nasir

Re: How to check if a bundle is already installed?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Apr 13, 2010 at 11:27 AM, Mahammad Nasir
<ma...@huawei.com> wrote:
> ...How can i check if a bundle is already installed? i dint find any api to
> check if it is already installed...

you can do something like

           String bundleSymbolicName = ...
           Bundle[] bundles = bundleContext.getBundles();
            for (Bundle bundle : bundles) {
                if (bundleSymbolicName.equals(bundle.getSymbolicName())) {
                    return bundle;
                }
            }

-Bertrand

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


RE: How to check if a bundle is already installed?

Posted by Mahammad Nasir <ma...@huawei.com>.
 


Yes bundle filename.

Since second installation also has  same file name..I think this would work
for me.

-----Original Message-----
From: Bertrand Delacretaz [mailto:bdelacretaz@apache.org] 
Sent: Wednesday, April 14, 2010 12:44 PM
To: users@felix.apache.org; mahammadnasir@huawei.com
Subject: Re: How to check if a bundle is already installed?

On Wed, Apr 14, 2010 at 5:00 AM, Mahammad Nasir <ma...@huawei.com>
wrote:
>
> Thanks, I think this will solve my problem wherever I have symbolic 
> name. I have some places I have only bundle physical name. Is there 
> any otherways to check based on physical name?...

The bundle filename you mean?

There's Bundle.getLocation() but that does not change if the bundle is
updated after being installed, see
http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#getLocation
()
- so you usually cannot rely on that. The Bundle-SymbolicName/Version combo
is the only stable identifier AFAIK.

-Bertrand

---------------------------------------------------------------------
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: How to check if a bundle is already installed?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Apr 14, 2010 at 5:00 AM, Mahammad Nasir
<ma...@huawei.com> wrote:
>
> Thanks, I think this will solve my problem wherever I have symbolic name. I
> have some places I have only bundle physical name. Is there any otherways to
> check based on physical name?...

The bundle filename you mean?

There's Bundle.getLocation() but that does not change if the bundle is
updated after being installed, see
http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html#getLocation()
- so you usually cannot rely on that. The Bundle-SymbolicName/Version
combo is the only stable identifier AFAIK.

-Bertrand

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


RE: How to check if a bundle is already installed?

Posted by Mahammad Nasir <ma...@huawei.com>.
 
Thanks, I think this will solve my problem wherever I have symbolic name. I
have some places I have only bundle physical name. Is there any otherways to
check based on physical name?


-----Original Message-----
From: Justin Edelson [mailto:justinedelson@gmail.com] 
Sent: Tuesday, April 13, 2010 6:25 PM
To: users@felix.apache.org; mahammadnasir@huawei.com
Subject: Re: How to check if a bundle is already installed?

PackageAdmin.getBundles(symbolicName, null)

See
http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/PackageAdmin
.html#getBundles%28java.lang.String,%20java.lang.String%29



On Tue, Apr 13, 2010 at 5:27 AM, Mahammad Nasir
<ma...@huawei.com>wrote:

>
> HI,
> I have bundle name /bundle symbolic name. and i have a bundle path 
> which i want to install next. But for some reason i must check if a 
> bundle is already installed or not. i have around 100 bundles installed.
>
> How can i check if a bundle is already installed? i dint find any api 
> to check if it is already installed. Pls help me
>
>
> Regards
> Nasir
>


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


Re: How to check if a bundle is already installed?

Posted by Justin Edelson <ju...@gmail.com>.
PackageAdmin.getBundles(symbolicName, null)

See
http://www.osgi.org/javadoc/r4v42/org/osgi/service/packageadmin/PackageAdmin.html#getBundles%28java.lang.String,%20java.lang.String%29



On Tue, Apr 13, 2010 at 5:27 AM, Mahammad Nasir <ma...@huawei.com>wrote:

>
> HI,
> I have bundle name /bundle symbolic name. and i have a bundle path which i
> want to install next. But for some reason i must check if a bundle is
> already installed or not. i have around 100 bundles installed.
>
> How can i check if a bundle is already installed? i dint find any api to
> check if it is already installed. Pls help me
>
>
> Regards
> Nasir
>