You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Cristiano Gavião <cv...@gmail.com> on 2011/05/06 15:05:48 UTC

how to list all classes from exported packages of a bundle?

Hi,

I have a no-osgi api that I'm trying to port to osgi. In this api I have 
a method that searchs for all classes in classpath that contain one 
determinated annotation. So I want to do the same on OSGi.

I've started this challenge by creating one service bundle and I've 
create fragments where is the searchable classes. I can find the 
properties resources from the fragment nicely... but I can't find a 
solution for classes investigation. :-s

I've found one service (org.osgi.service.packageadmin.PackageAdmin) that 
gives me the exported packages and fragments (despite the fact it is 
deprecated and is not part of OSGi 4.3 anymore) of a bundle. But the 
problem is that the ExportedPackages don't gives me any option to list 
the classes contained by it.

How could I do that ?

thanks for any help.

regards,

Cristiano

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


Re: how to list all classes from exported packages of a bundle?

Posted by Angelo van der Sijpt <an...@luminis.eu>.
Yes, I should have mentioned that 4.2 does not support this. In 4.2, you can find out the exported packages using PackageAdmin, but the only way to find out the classes is to inspect the actual bundle using getEntryPaths, as Peter has commented on the stackoverflow question. He also notes that you will have to do the Bundle-ClassPath checking yourself, to find out where all the classes can come from.

In short, there (currently) is no fool-proof way that gets you the classes in all cases, without doing a whole lot of work yourself. You might have some chance if you can tightly control the bundles you want to search, e.g. by mandating that only . can be on the bundle classpath.

Angelo


On May 6, 2011, at 7:25 PM, Cristiano Gavião wrote:

> Hi,
> well, this mean that in R4.2 version I can't do what I want or could I have
> some alternative?
> 
> cheers
> 
> 
> 2011/5/6 Richard S. Hall <he...@ungoverned.org>
> 
>> Note that Felix does not yet implement the R4.3 spec, so the mentioned
>> BundleWiring approach is not possible yet...we're working on it though...
>> 
>> -> richard
>> 
>> 
>> On 5/6/11 9:17, Angelo van der Sijpt wrote:
>> 
>>> You could take a look at this Stackoverflow question:
>>> http://stackoverflow.com/questions/5856096/osgi-get-list-of-classes-in-package
>>> 
>>> The question assumes you know what package you're talking about, and you
>>> can find the exported packages by using
>>> BundleWiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE).
>>> 
>>> Angelo
>>> 
>>> On May 6, 2011, at 3:05 PM, Cristiano Gavião wrote:
>>> 
>>> Hi,
>>>> 
>>>> I have a no-osgi api that I'm trying to port to osgi. In this api I have
>>>> a method that searchs for all classes in classpath that contain one
>>>> determinated annotation. So I want to do the same on OSGi.
>>>> 
>>>> I've started this challenge by creating one service bundle and I've
>>>> create fragments where is the searchable classes. I can find the properties
>>>> resources from the fragment nicely... but I can't find a solution for
>>>> classes investigation. :-s
>>>> 
>>>> I've found one service (org.osgi.service.packageadmin.PackageAdmin) that
>>>> gives me the exported packages and fragments (despite the fact it is
>>>> deprecated and is not part of OSGi 4.3 anymore) of a bundle. But the problem
>>>> is that the ExportedPackages don't gives me any option to list the classes
>>>> contained by it.
>>>> 
>>>> How could I do that ?
>>>> 
>>>> thanks for any help.
>>>> 
>>>> regards,
>>>> 
>>>> Cristiano
>>>> 
>>>> ---------------------------------------------------------------------
>>>> 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
>> 
>> 
> 
> 
> -- 
> "Tudo vale a pena se a alma não é pequena..."


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


Re: how to list all classes from exported packages of a bundle?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 5/6/11 13:25, Cristiano Gavião wrote:
> Hi,
> well, this mean that in R4.2 version I can't do what I want or could I have
> some alternative?

As Peter Kriens mentions on the referenced web page, it is possible just 
a little more difficult since you have to reconstruct the bundle class 
path manually.

-> richard

> cheers
>
>
> 2011/5/6 Richard S. Hall<he...@ungoverned.org>
>
>> Note that Felix does not yet implement the R4.3 spec, so the mentioned
>> BundleWiring approach is not possible yet...we're working on it though...
>>
>> ->  richard
>>
>>
>> On 5/6/11 9:17, Angelo van der Sijpt wrote:
>>
>>> You could take a look at this Stackoverflow question:
>>> http://stackoverflow.com/questions/5856096/osgi-get-list-of-classes-in-package
>>>
>>> The question assumes you know what package you're talking about, and you
>>> can find the exported packages by using
>>> BundleWiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE).
>>>
>>> Angelo
>>>
>>> On May 6, 2011, at 3:05 PM, Cristiano Gavião wrote:
>>>
>>>   Hi,
>>>> I have a no-osgi api that I'm trying to port to osgi. In this api I have
>>>> a method that searchs for all classes in classpath that contain one
>>>> determinated annotation. So I want to do the same on OSGi.
>>>>
>>>> I've started this challenge by creating one service bundle and I've
>>>> create fragments where is the searchable classes. I can find the properties
>>>> resources from the fragment nicely... but I can't find a solution for
>>>> classes investigation. :-s
>>>>
>>>> I've found one service (org.osgi.service.packageadmin.PackageAdmin) that
>>>> gives me the exported packages and fragments (despite the fact it is
>>>> deprecated and is not part of OSGi 4.3 anymore) of a bundle. But the problem
>>>> is that the ExportedPackages don't gives me any option to list the classes
>>>> contained by it.
>>>>
>>>> How could I do that ?
>>>>
>>>> thanks for any help.
>>>>
>>>> regards,
>>>>
>>>> Cristiano
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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 list all classes from exported packages of a bundle?

Posted by Cristiano Gavião <cv...@gmail.com>.
Hi,
well, this mean that in R4.2 version I can't do what I want or could I have
some alternative?

cheers


2011/5/6 Richard S. Hall <he...@ungoverned.org>

> Note that Felix does not yet implement the R4.3 spec, so the mentioned
> BundleWiring approach is not possible yet...we're working on it though...
>
> -> richard
>
>
> On 5/6/11 9:17, Angelo van der Sijpt wrote:
>
>> You could take a look at this Stackoverflow question:
>> http://stackoverflow.com/questions/5856096/osgi-get-list-of-classes-in-package
>>
>> The question assumes you know what package you're talking about, and you
>> can find the exported packages by using
>> BundleWiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE).
>>
>> Angelo
>>
>> On May 6, 2011, at 3:05 PM, Cristiano Gavião wrote:
>>
>>  Hi,
>>>
>>> I have a no-osgi api that I'm trying to port to osgi. In this api I have
>>> a method that searchs for all classes in classpath that contain one
>>> determinated annotation. So I want to do the same on OSGi.
>>>
>>> I've started this challenge by creating one service bundle and I've
>>> create fragments where is the searchable classes. I can find the properties
>>> resources from the fragment nicely... but I can't find a solution for
>>> classes investigation. :-s
>>>
>>> I've found one service (org.osgi.service.packageadmin.PackageAdmin) that
>>> gives me the exported packages and fragments (despite the fact it is
>>> deprecated and is not part of OSGi 4.3 anymore) of a bundle. But the problem
>>> is that the ExportedPackages don't gives me any option to list the classes
>>> contained by it.
>>>
>>> How could I do that ?
>>>
>>> thanks for any help.
>>>
>>> regards,
>>>
>>> Cristiano
>>>
>>> ---------------------------------------------------------------------
>>> 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
>
>


-- 
"Tudo vale a pena se a alma não é pequena..."

Re: how to list all classes from exported packages of a bundle?

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Note that Felix does not yet implement the R4.3 spec, so the mentioned 
BundleWiring approach is not possible yet...we're working on it though...

-> richard

On 5/6/11 9:17, Angelo van der Sijpt wrote:
> You could take a look at this Stackoverflow question: http://stackoverflow.com/questions/5856096/osgi-get-list-of-classes-in-package
>
> The question assumes you know what package you're talking about, and you can find the exported packages by using BundleWiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE).
>
> Angelo
>
> On May 6, 2011, at 3:05 PM, Cristiano Gavião wrote:
>
>> Hi,
>>
>> I have a no-osgi api that I'm trying to port to osgi. In this api I have a method that searchs for all classes in classpath that contain one determinated annotation. So I want to do the same on OSGi.
>>
>> I've started this challenge by creating one service bundle and I've create fragments where is the searchable classes. I can find the properties resources from the fragment nicely... but I can't find a solution for classes investigation. :-s
>>
>> I've found one service (org.osgi.service.packageadmin.PackageAdmin) that gives me the exported packages and fragments (despite the fact it is deprecated and is not part of OSGi 4.3 anymore) of a bundle. But the problem is that the ExportedPackages don't gives me any option to list the classes contained by it.
>>
>> How could I do that ?
>>
>> thanks for any help.
>>
>> regards,
>>
>> Cristiano
>>
>> ---------------------------------------------------------------------
>> 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 list all classes from exported packages of a bundle?

Posted by Angelo van der Sijpt <an...@luminis.eu>.
You could take a look at this Stackoverflow question: http://stackoverflow.com/questions/5856096/osgi-get-list-of-classes-in-package

The question assumes you know what package you're talking about, and you can find the exported packages by using BundleWiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE).

Angelo

On May 6, 2011, at 3:05 PM, Cristiano Gavião wrote:

> Hi,
> 
> I have a no-osgi api that I'm trying to port to osgi. In this api I have a method that searchs for all classes in classpath that contain one determinated annotation. So I want to do the same on OSGi.
> 
> I've started this challenge by creating one service bundle and I've create fragments where is the searchable classes. I can find the properties resources from the fragment nicely... but I can't find a solution for classes investigation. :-s
> 
> I've found one service (org.osgi.service.packageadmin.PackageAdmin) that gives me the exported packages and fragments (despite the fact it is deprecated and is not part of OSGi 4.3 anymore) of a bundle. But the problem is that the ExportedPackages don't gives me any option to list the classes contained by it.
> 
> How could I do that ?
> 
> thanks for any help.
> 
> regards,
> 
> Cristiano
> 
> ---------------------------------------------------------------------
> 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