You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Felix Meschberger <fm...@gmail.com> on 2007/09/27 09:23:54 UTC

Re: How to determine if a bundle with only service interfaces is still used?

As Richard said, checkout the PackageAdmin.getExportedPackages(Bundle)
method for the service interface bundles. For each ExportedPackage you
will have the wired imports. If you do not see any wirings, the bundle
is probably not used.

You do not need to uninstall the bundles and check whether the system
still resolves and thus potentially taking down the system.

Regards
Felix

Am Mittwoch, den 26.09.2007, 13:32 +0200 schrieb Bart Elen:
> Hallo,
> 
> 
> I use a lot of service dependencies between my bundles with the service interfaces in separate bundles.
> 
> 
> There is a large issue with this approach:
> When a lot of bundles have been installed and removed, it is difficult to determine which bundles 
> with only service interfaces are still used. This is because it is possible to determine, at 
> runtime, the service dependencies between the bundles, but not the package dependencies.
> 
> 
> My current solution for this problem is: remove all bundles with only service interface packages. 
> The framework will continue to make those packages available to all bundles importing those service 
> interface packages until the framework is restarted or until the 
> org.osgi.service.packageadmin.PackageAdmin.refreshPackages method is called.
> 
> 
> In my first tests, this solution seems to work. But, isn't there a better (cleaner) solution then 
> uninstalling them all and counting on the framework to keep them available?
> 
> 
> Thanks for your time,
> 
> Bart
> 
> ---------------------------------------------------------------------
> 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 determine if a bundle with only service interfaces is still used?

Posted by Karl Pauls <ka...@gmail.com>.
On 9/28/07, Bart Elen <Ba...@cs.kuleuven.be> wrote:
> Hello Karl,
>
>
> There is an alternative for the PackageAdmin.getExportedPackages(Bundle) method to determine if a
> bundle is still exporting packages?
>
> I have to start searching for an alternative solution since the "DynamicImport-Package: *" of my
> remoting bundle (to support the usage of remote service calls) will probably make the framework
> believe that these service API packages are always used. Also when all bundles offering and using
> these services are removed.

That would only be the case if your bundle actually touched classes
out of those packages. DynamicImports are only resolved when needed
hence, the PackageAdmin will give you the right result.

regards,

Karl

> Greetings,
> Bart
>
>
>
> Karl Pauls wrote:
> > Hi Bart,
> >
> > On 9/28/07, Bart Elen <Ba...@cs.kuleuven.be> wrote:
> >> First of all,
> >>
> >> Thanks for the help :-)
> >>
> >>
> >> The problem with this solution is that it requires PackageAdmin.refreshPackages(Bundle[] bundles) to
> >> be called first. This may restart the complete framework. A lot of context information will be lost
> >> this way.
> >
> > Maybe I'm missing something but you can use the other methods of the
> > PackageAdmin service to determine whether a bunde is used or not.
> >
> > regards,
> >
> > Karl
> >
> >> Greetings,
> >>
> >> Bart
> >>
> >>
> >> Felix Meschberger wrote:
> >>> As Richard said, checkout the PackageAdmin.getExportedPackages(Bundle)
> >>> method for the service interface bundles. For each ExportedPackage you
> >>> will have the wired imports. If you do not see any wirings, the bundle
> >>> is probably not used.
> >>>
> >>> You do not need to uninstall the bundles and check whether the system
> >>> still resolves and thus potentially taking down the system.
> >>>
> >>> Regards
> >>> Felix
> >>>
> >>> Am Mittwoch, den 26.09.2007, 13:32 +0200 schrieb Bart Elen:
> >>>> Hallo,
> >>>>
> >>>>
> >>>> I use a lot of service dependencies between my bundles with the service interfaces in separate bundles.
> >>>>
> >>>>
> >>>> There is a large issue with this approach:
> >>>> When a lot of bundles have been installed and removed, it is difficult to determine which bundles
> >>>> with only service interfaces are still used. This is because it is possible to determine, at
> >>>> runtime, the service dependencies between the bundles, but not the package dependencies.
> >>>>
> >>>>
> >>>> My current solution for this problem is: remove all bundles with only service interface packages.
> >>>> The framework will continue to make those packages available to all bundles importing those service
> >>>> interface packages until the framework is restarted or until the
> >>>> org.osgi.service.packageadmin.PackageAdmin.refreshPackages method is called.
> >>>>
> >>>>
> >>>> In my first tests, this solution seems to work. But, isn't there a better (cleaner) solution then
> >>>> uninstalling them all and counting on the framework to keep them available?
> >>>>
> >>>>
> >>>> Thanks for your time,
> >>>>
> >>>> Bart
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> 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
>
>


-- 
Karl Pauls
karlpauls@gmail.com

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


Re: How to determine if a bundle with only service interfaces is still used?

Posted by Bart Elen <Ba...@cs.kuleuven.be>.
Hello Karl,


There is an alternative for the PackageAdmin.getExportedPackages(Bundle) method to determine if a 
bundle is still exporting packages?

I have to start searching for an alternative solution since the "DynamicImport-Package: *" of my 
remoting bundle (to support the usage of remote service calls) will probably make the framework 
believe that these service API packages are always used. Also when all bundles offering and using 
these services are removed.



Greetings,
Bart



Karl Pauls wrote:
> Hi Bart,
> 
> On 9/28/07, Bart Elen <Ba...@cs.kuleuven.be> wrote:
>> First of all,
>>
>> Thanks for the help :-)
>>
>>
>> The problem with this solution is that it requires PackageAdmin.refreshPackages(Bundle[] bundles) to
>> be called first. This may restart the complete framework. A lot of context information will be lost
>> this way.
> 
> Maybe I'm missing something but you can use the other methods of the
> PackageAdmin service to determine whether a bunde is used or not.
> 
> regards,
> 
> Karl
> 
>> Greetings,
>>
>> Bart
>>
>>
>> Felix Meschberger wrote:
>>> As Richard said, checkout the PackageAdmin.getExportedPackages(Bundle)
>>> method for the service interface bundles. For each ExportedPackage you
>>> will have the wired imports. If you do not see any wirings, the bundle
>>> is probably not used.
>>>
>>> You do not need to uninstall the bundles and check whether the system
>>> still resolves and thus potentially taking down the system.
>>>
>>> Regards
>>> Felix
>>>
>>> Am Mittwoch, den 26.09.2007, 13:32 +0200 schrieb Bart Elen:
>>>> Hallo,
>>>>
>>>>
>>>> I use a lot of service dependencies between my bundles with the service interfaces in separate bundles.
>>>>
>>>>
>>>> There is a large issue with this approach:
>>>> When a lot of bundles have been installed and removed, it is difficult to determine which bundles
>>>> with only service interfaces are still used. This is because it is possible to determine, at
>>>> runtime, the service dependencies between the bundles, but not the package dependencies.
>>>>
>>>>
>>>> My current solution for this problem is: remove all bundles with only service interface packages.
>>>> The framework will continue to make those packages available to all bundles importing those service
>>>> interface packages until the framework is restarted or until the
>>>> org.osgi.service.packageadmin.PackageAdmin.refreshPackages method is called.
>>>>
>>>>
>>>> In my first tests, this solution seems to work. But, isn't there a better (cleaner) solution then
>>>> uninstalling them all and counting on the framework to keep them available?
>>>>
>>>>
>>>> Thanks for your time,
>>>>
>>>> Bart
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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: How to determine if a bundle with only service interfaces is still used?

Posted by Karl Pauls <ka...@gmail.com>.
Hi Bart,

On 9/28/07, Bart Elen <Ba...@cs.kuleuven.be> wrote:
> First of all,
>
> Thanks for the help :-)
>
>
> The problem with this solution is that it requires PackageAdmin.refreshPackages(Bundle[] bundles) to
> be called first. This may restart the complete framework. A lot of context information will be lost
> this way.

Maybe I'm missing something but you can use the other methods of the
PackageAdmin service to determine whether a bunde is used or not.

regards,

Karl

> Greetings,
>
> Bart
>
>
> Felix Meschberger wrote:
> > As Richard said, checkout the PackageAdmin.getExportedPackages(Bundle)
> > method for the service interface bundles. For each ExportedPackage you
> > will have the wired imports. If you do not see any wirings, the bundle
> > is probably not used.
> >
> > You do not need to uninstall the bundles and check whether the system
> > still resolves and thus potentially taking down the system.
> >
> > Regards
> > Felix
> >
> > Am Mittwoch, den 26.09.2007, 13:32 +0200 schrieb Bart Elen:
> >> Hallo,
> >>
> >>
> >> I use a lot of service dependencies between my bundles with the service interfaces in separate bundles.
> >>
> >>
> >> There is a large issue with this approach:
> >> When a lot of bundles have been installed and removed, it is difficult to determine which bundles
> >> with only service interfaces are still used. This is because it is possible to determine, at
> >> runtime, the service dependencies between the bundles, but not the package dependencies.
> >>
> >>
> >> My current solution for this problem is: remove all bundles with only service interface packages.
> >> The framework will continue to make those packages available to all bundles importing those service
> >> interface packages until the framework is restarted or until the
> >> org.osgi.service.packageadmin.PackageAdmin.refreshPackages method is called.
> >>
> >>
> >> In my first tests, this solution seems to work. But, isn't there a better (cleaner) solution then
> >> uninstalling them all and counting on the framework to keep them available?
> >>
> >>
> >> Thanks for your time,
> >>
> >> Bart
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>


-- 
Karl Pauls
karlpauls@gmail.com

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


Re: How to determine if a bundle with only service interfaces is still used?

Posted by Bart Elen <Ba...@cs.kuleuven.be>.
Thanks for the example.

It helped a lot!


Greetings,

Bart


Felix Meschberger wrote:
> Am Freitag, den 28.09.2007, 09:53 -0400 schrieb Richard S. Hall:
>> PackageAdmin.getImportingBundles() without calling refresh.
> 
> I assume you mean ExportedPackage.getImportingBundles() ?
> 
> To clarify with some code, what we mean: Assume you want to check Bundle
> "bundle" for any used exports:
> 
> public boolean isUsed(Bundle bundle) {
>     ExportedPackages[] ep = packageAdmin.getExportedPackages(bundle);
>     if (ep == null || ep.length == 0) {
>         // no exports, done
>         return false;
>     } else {
>         for (int i=0; i < ep.length; i++) {
>             if (ep[i].getImportingBundles() != null) {
>                 // we found a used export ...
>                 return true;
>             }
>         }
> 
>         // exhausted all exports and had no imports
>         return false;
>     }
> }
> 
> This returns all used exports, regardless of why the exports are used
> (as per Import-Package, Require-Bundle or DynamicImport-Package).
> 
> Hope this helps.
> 
> Regards
> Felix
> 
> 
> ---------------------------------------------------------------------
> 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 determine if a bundle with only service interfaces is still used?

Posted by Felix Meschberger <fm...@gmail.com>.
Am Freitag, den 28.09.2007, 09:53 -0400 schrieb Richard S. Hall:
> PackageAdmin.getImportingBundles() without calling refresh.

I assume you mean ExportedPackage.getImportingBundles() ?

To clarify with some code, what we mean: Assume you want to check Bundle
"bundle" for any used exports:

public boolean isUsed(Bundle bundle) {
    ExportedPackages[] ep = packageAdmin.getExportedPackages(bundle);
    if (ep == null || ep.length == 0) {
        // no exports, done
        return false;
    } else {
        for (int i=0; i < ep.length; i++) {
            if (ep[i].getImportingBundles() != null) {
                // we found a used export ...
                return true;
            }
        }

        // exhausted all exports and had no imports
        return false;
    }
}

This returns all used exports, regardless of why the exports are used
(as per Import-Package, Require-Bundle or DynamicImport-Package).

Hope this helps.

Regards
Felix


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


Re: How to determine if a bundle with only service interfaces is still used?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Bart Elen wrote:
> First of all,
>
> Thanks for the help :-)
>
>
> The problem with this solution is that it requires 
> PackageAdmin.refreshPackages(Bundle[] bundles) to be called first. 
> This may restart the complete framework. A lot of context information 
> will be lost this way.

I am not sure what you mean.

You can use PackageAdmin.getExportedPackage() and 
PackageAdmin.getImportingBundles() without calling refresh.

The whole point is that you said you want to see if a package is in use 
so you can get rid of the exporting bundle, right? So, use PA to see if 
anyone is using the package. If not, then you can uninstall and refresh 
the bundle.

-> richard

>
>
> Greetings,
>
> Bart
>
>
> Felix Meschberger wrote:
>> As Richard said, checkout the PackageAdmin.getExportedPackages(Bundle)
>> method for the service interface bundles. For each ExportedPackage you
>> will have the wired imports. If you do not see any wirings, the bundle
>> is probably not used.
>>
>> You do not need to uninstall the bundles and check whether the system
>> still resolves and thus potentially taking down the system.
>>
>> Regards
>> Felix
>>
>> Am Mittwoch, den 26.09.2007, 13:32 +0200 schrieb Bart Elen:
>>> Hallo,
>>>
>>>
>>> I use a lot of service dependencies between my bundles with the 
>>> service interfaces in separate bundles.
>>>
>>>
>>> There is a large issue with this approach:
>>> When a lot of bundles have been installed and removed, it is 
>>> difficult to determine which bundles with only service interfaces 
>>> are still used. This is because it is possible to determine, at 
>>> runtime, the service dependencies between the bundles, but not the 
>>> package dependencies.
>>>
>>>
>>> My current solution for this problem is: remove all bundles with 
>>> only service interface packages. The framework will continue to make 
>>> those packages available to all bundles importing those service 
>>> interface packages until the framework is restarted or until the 
>>> org.osgi.service.packageadmin.PackageAdmin.refreshPackages method is 
>>> called.
>>>
>>>
>>> In my first tests, this solution seems to work. But, isn't there a 
>>> better (cleaner) solution then uninstalling them all and counting on 
>>> the framework to keep them available?
>>>
>>>
>>> Thanks for your time,
>>>
>>> Bart
>>>
>>> ---------------------------------------------------------------------
>>> 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: How to determine if a bundle with only service interfaces is still used?

Posted by Bart Elen <Ba...@cs.kuleuven.be>.
First of all,

Thanks for the help :-)


The problem with this solution is that it requires PackageAdmin.refreshPackages(Bundle[] bundles) to 
be called first. This may restart the complete framework. A lot of context information will be lost 
this way.


Greetings,

Bart


Felix Meschberger wrote:
> As Richard said, checkout the PackageAdmin.getExportedPackages(Bundle)
> method for the service interface bundles. For each ExportedPackage you
> will have the wired imports. If you do not see any wirings, the bundle
> is probably not used.
> 
> You do not need to uninstall the bundles and check whether the system
> still resolves and thus potentially taking down the system.
> 
> Regards
> Felix
> 
> Am Mittwoch, den 26.09.2007, 13:32 +0200 schrieb Bart Elen:
>> Hallo,
>>
>>
>> I use a lot of service dependencies between my bundles with the service interfaces in separate bundles.
>>
>>
>> There is a large issue with this approach:
>> When a lot of bundles have been installed and removed, it is difficult to determine which bundles 
>> with only service interfaces are still used. This is because it is possible to determine, at 
>> runtime, the service dependencies between the bundles, but not the package dependencies.
>>
>>
>> My current solution for this problem is: remove all bundles with only service interface packages. 
>> The framework will continue to make those packages available to all bundles importing those service 
>> interface packages until the framework is restarted or until the 
>> org.osgi.service.packageadmin.PackageAdmin.refreshPackages method is called.
>>
>>
>> In my first tests, this solution seems to work. But, isn't there a better (cleaner) solution then 
>> uninstalling them all and counting on the framework to keep them available?
>>
>>
>> Thanks for your time,
>>
>> Bart
>>
>> ---------------------------------------------------------------------
>> 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