You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by Alan Keane <al...@gmail.com> on 2010/01/08 22:16:24 UTC

Standard way to inspect wiring [JMX Core]?

I'm looking for a standard way through the Framework API to inspect a
bundle's resolved bundle dependencies and imported packages.
The BundleStateMBean defines a #getImportedPackages(long bundleId) &
#getRequiredBundles(long) method.

The processing used for getImportedPackages
(FrameworkUtils#getBundleImportedPackages)
in particular will iterate through all bundles in the framework, query for
ExportedPackages on each one and check for a match on the importing bundles.

Any ideas on a more efficient (standard) way of doing this?

Cheers,
Alan

Re: Standard way to inspect wiring [JMX Core]?

Posted by Alan Keane <al...@gmail.com>.
Thanks for the replies..
Will add some additional checks for the manifest headers first.

Alan

On Fri, Jan 8, 2010 at 11:44 PM, Alasdair Nottingham <no...@apache.org> wrote:

> It wasn't, but I like your thinking. You could look to see if the
> Import-Package has optional imports or check for DynamicImport-Package and
> if so do it the expensive way, but if they are not there use the method I
> suggested. You'll have to check the fragments too, but that might be
> possible.
>
> Alasdair
>
>
> On 8 Jan 2010, at 23:26, Jarek Gawor <jg...@gmail.com> wrote:
>
>  I don't know if that's what Alasdair meant but you could parse the
>> Import-Package header and using PackageAdmin check if one of the
>> bundles that exports a given import package is actually wired to the
>> importing bundle. That should be more efficient than going through all
>> bundles and all exports. However, if bundle has DynamicImport-Package
>> might as well do the full scan.
>>
>> Jarek
>>
>> On Fri, Jan 8, 2010 at 4:40 PM, Alan Keane <al...@gmail.com> wrote:
>>
>>> This would be somewhat static and would not give any indication of the
>>> runtime
>>> resolution of optional imports etc.
>>> The bundle headers are available through another method on the
>>> BundleStateMBean.
>>>
>>> Alan
>>>
>>> On Fri, Jan 8, 2010 at 9:26 PM, Alasdair Nottingham <no...@apache.org>
>>> wrote:
>>>
>>>  Can you not call Bundle.getHeaders().get("Import-Package")?
>>>>
>>>> That will return a them all as a single string, but we have code in
>>>> the application component that can correctly split this up in the
>>>> individual packages. We could move this into the util package so it
>>>> can be shared.
>>>>
>>>> Alasdair
>>>>
>>>> 2010/1/8 Alan Keane <al...@gmail.com>:
>>>>
>>>>> I'm looking for a standard way through the Framework API to inspect a
>>>>> bundle's resolved bundle dependencies and imported packages.
>>>>> The BundleStateMBean defines a #getImportedPackages(long bundleId) &
>>>>> #getRequiredBundles(long) method.
>>>>>
>>>>> The processing used for getImportedPackages
>>>>> (FrameworkUtils#getBundleImportedPackages)
>>>>> in particular will iterate through all bundles in the framework, query
>>>>>
>>>> for
>>>>
>>>>> ExportedPackages on each one and check for a match on the importing
>>>>>
>>>> bundles.
>>>>
>>>>>
>>>>> Any ideas on a more efficient (standard) way of doing this?
>>>>>
>>>>> Cheers,
>>>>> Alan
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Alasdair Nottingham
>>>> not@apache.org
>>>>
>>>>
>>>

Re: Standard way to inspect wiring [JMX Core]?

Posted by Alasdair Nottingham <no...@apache.org>.
It wasn't, but I like your thinking. You could look to see if the  
Import-Package has optional imports or check for DynamicImport-Package  
and if so do it the expensive way, but if they are not there use the  
method I suggested. You'll have to check the fragments too, but that  
might be possible.

Alasdair

On 8 Jan 2010, at 23:26, Jarek Gawor <jg...@gmail.com> wrote:

> I don't know if that's what Alasdair meant but you could parse the
> Import-Package header and using PackageAdmin check if one of the
> bundles that exports a given import package is actually wired to the
> importing bundle. That should be more efficient than going through all
> bundles and all exports. However, if bundle has DynamicImport-Package
> might as well do the full scan.
>
> Jarek
>
> On Fri, Jan 8, 2010 at 4:40 PM, Alan Keane <al...@gmail.com>  
> wrote:
>> This would be somewhat static and would not give any indication of  
>> the
>> runtime
>> resolution of optional imports etc.
>> The bundle headers are available through another method on the
>> BundleStateMBean.
>>
>> Alan
>>
>> On Fri, Jan 8, 2010 at 9:26 PM, Alasdair Nottingham  
>> <no...@apache.org> wrote:
>>
>>> Can you not call Bundle.getHeaders().get("Import-Package")?
>>>
>>> That will return a them all as a single string, but we have code in
>>> the application component that can correctly split this up in the
>>> individual packages. We could move this into the util package so it
>>> can be shared.
>>>
>>> Alasdair
>>>
>>> 2010/1/8 Alan Keane <al...@gmail.com>:
>>>> I'm looking for a standard way through the Framework API to  
>>>> inspect a
>>>> bundle's resolved bundle dependencies and imported packages.
>>>> The BundleStateMBean defines a #getImportedPackages(long  
>>>> bundleId) &
>>>> #getRequiredBundles(long) method.
>>>>
>>>> The processing used for getImportedPackages
>>>> (FrameworkUtils#getBundleImportedPackages)
>>>> in particular will iterate through all bundles in the framework,  
>>>> query
>>> for
>>>> ExportedPackages on each one and check for a match on the importing
>>> bundles.
>>>>
>>>> Any ideas on a more efficient (standard) way of doing this?
>>>>
>>>> Cheers,
>>>> Alan
>>>>
>>>
>>>
>>>
>>> --
>>> Alasdair Nottingham
>>> not@apache.org
>>>
>>

Re: Standard way to inspect wiring [JMX Core]?

Posted by Jarek Gawor <jg...@gmail.com>.
I don't know if that's what Alasdair meant but you could parse the
Import-Package header and using PackageAdmin check if one of the
bundles that exports a given import package is actually wired to the
importing bundle. That should be more efficient than going through all
bundles and all exports. However, if bundle has DynamicImport-Package
might as well do the full scan.

Jarek

On Fri, Jan 8, 2010 at 4:40 PM, Alan Keane <al...@gmail.com> wrote:
> This would be somewhat static and would not give any indication of the
> runtime
> resolution of optional imports etc.
> The bundle headers are available through another method on the
> BundleStateMBean.
>
> Alan
>
> On Fri, Jan 8, 2010 at 9:26 PM, Alasdair Nottingham <no...@apache.org> wrote:
>
>> Can you not call Bundle.getHeaders().get("Import-Package")?
>>
>> That will return a them all as a single string, but we have code in
>> the application component that can correctly split this up in the
>> individual packages. We could move this into the util package so it
>> can be shared.
>>
>> Alasdair
>>
>> 2010/1/8 Alan Keane <al...@gmail.com>:
>> > I'm looking for a standard way through the Framework API to inspect a
>> > bundle's resolved bundle dependencies and imported packages.
>> > The BundleStateMBean defines a #getImportedPackages(long bundleId) &
>> > #getRequiredBundles(long) method.
>> >
>> > The processing used for getImportedPackages
>> > (FrameworkUtils#getBundleImportedPackages)
>> > in particular will iterate through all bundles in the framework, query
>> for
>> > ExportedPackages on each one and check for a match on the importing
>> bundles.
>> >
>> > Any ideas on a more efficient (standard) way of doing this?
>> >
>> > Cheers,
>> > Alan
>> >
>>
>>
>>
>> --
>> Alasdair Nottingham
>> not@apache.org
>>
>

Re: Standard way to inspect wiring [JMX Core]?

Posted by Alasdair Nottingham <no...@apache.org>.
In that case as Valentin says there is no other way to get to this.

I have to admit I always thought it was odd that OSGi didn't make it
easier to get the packages imported from a bundle. The framework must
hold this information for class loading to work efficiently. There
might be API's in specific implementations that allow for this more
efficiently, but that isn't ideal.

On the subject of the MBeans looking at the PackageStateMBean the
getExportingBundle allows you to specify a package name and version
and returns the id of the exporting bundle. Do you know what should
happen if the package is exported by multiple bundles?

Alasdair

2010/1/8 Alan Keane <al...@gmail.com>:
> This would be somewhat static and would not give any indication of the
> runtime
> resolution of optional imports etc.
> The bundle headers are available through another method on the
> BundleStateMBean.
>
> Alan
>
> On Fri, Jan 8, 2010 at 9:26 PM, Alasdair Nottingham <no...@apache.org> wrote:
>
>> Can you not call Bundle.getHeaders().get("Import-Package")?
>>
>> That will return a them all as a single string, but we have code in
>> the application component that can correctly split this up in the
>> individual packages. We could move this into the util package so it
>> can be shared.
>>
>> Alasdair
>>
>> 2010/1/8 Alan Keane <al...@gmail.com>:
>> > I'm looking for a standard way through the Framework API to inspect a
>> > bundle's resolved bundle dependencies and imported packages.
>> > The BundleStateMBean defines a #getImportedPackages(long bundleId) &
>> > #getRequiredBundles(long) method.
>> >
>> > The processing used for getImportedPackages
>> > (FrameworkUtils#getBundleImportedPackages)
>> > in particular will iterate through all bundles in the framework, query
>> for
>> > ExportedPackages on each one and check for a match on the importing
>> bundles.
>> >
>> > Any ideas on a more efficient (standard) way of doing this?
>> >
>> > Cheers,
>> > Alan
>> >
>>
>>
>>
>> --
>> Alasdair Nottingham
>> not@apache.org
>>
>



-- 
Alasdair Nottingham
not@apache.org

Re: Standard way to inspect wiring [JMX Core]?

Posted by Alan Keane <al...@gmail.com>.
This would be somewhat static and would not give any indication of the
runtime
resolution of optional imports etc.
The bundle headers are available through another method on the
BundleStateMBean.

Alan

On Fri, Jan 8, 2010 at 9:26 PM, Alasdair Nottingham <no...@apache.org> wrote:

> Can you not call Bundle.getHeaders().get("Import-Package")?
>
> That will return a them all as a single string, but we have code in
> the application component that can correctly split this up in the
> individual packages. We could move this into the util package so it
> can be shared.
>
> Alasdair
>
> 2010/1/8 Alan Keane <al...@gmail.com>:
> > I'm looking for a standard way through the Framework API to inspect a
> > bundle's resolved bundle dependencies and imported packages.
> > The BundleStateMBean defines a #getImportedPackages(long bundleId) &
> > #getRequiredBundles(long) method.
> >
> > The processing used for getImportedPackages
> > (FrameworkUtils#getBundleImportedPackages)
> > in particular will iterate through all bundles in the framework, query
> for
> > ExportedPackages on each one and check for a match on the importing
> bundles.
> >
> > Any ideas on a more efficient (standard) way of doing this?
> >
> > Cheers,
> > Alan
> >
>
>
>
> --
> Alasdair Nottingham
> not@apache.org
>

Re: Standard way to inspect wiring [JMX Core]?

Posted by Valentin Mahrwald <vm...@googlemail.com>.
Parsing the Import-Package header would however not show the exact  
runtime imports since optional packages could be either present or not.

As far as I know using the clunky PackageAdmin API is the only way to  
query the actual runtime wiring. If performance is key, maybe some  
level of caching together with a BundleListener could be used.

Regards,

Valentin

On 8 Jan 2010, at 21:26, Alasdair Nottingham wrote:

> Can you not call Bundle.getHeaders().get("Import-Package")?
>
> That will return a them all as a single string, but we have code in
> the application component that can correctly split this up in the
> individual packages. We could move this into the util package so it
> can be shared.
>
> Alasdair
>
> 2010/1/8 Alan Keane <al...@gmail.com>:
>> I'm looking for a standard way through the Framework API to inspect a
>> bundle's resolved bundle dependencies and imported packages.
>> The BundleStateMBean defines a #getImportedPackages(long bundleId) &
>> #getRequiredBundles(long) method.
>>
>> The processing used for getImportedPackages
>> (FrameworkUtils#getBundleImportedPackages)
>> in particular will iterate through all bundles in the framework,  
>> query for
>> ExportedPackages on each one and check for a match on the importing  
>> bundles.
>>
>> Any ideas on a more efficient (standard) way of doing this?
>>
>> Cheers,
>> Alan
>>
>
>
>
> -- 
> Alasdair Nottingham
> not@apache.org


Re: Standard way to inspect wiring [JMX Core]?

Posted by Alasdair Nottingham <no...@apache.org>.
Can you not call Bundle.getHeaders().get("Import-Package")?

That will return a them all as a single string, but we have code in
the application component that can correctly split this up in the
individual packages. We could move this into the util package so it
can be shared.

Alasdair

2010/1/8 Alan Keane <al...@gmail.com>:
> I'm looking for a standard way through the Framework API to inspect a
> bundle's resolved bundle dependencies and imported packages.
> The BundleStateMBean defines a #getImportedPackages(long bundleId) &
> #getRequiredBundles(long) method.
>
> The processing used for getImportedPackages
> (FrameworkUtils#getBundleImportedPackages)
> in particular will iterate through all bundles in the framework, query for
> ExportedPackages on each one and check for a match on the importing bundles.
>
> Any ideas on a more efficient (standard) way of doing this?
>
> Cheers,
> Alan
>



-- 
Alasdair Nottingham
not@apache.org