Hi Tim,

just an update to this issue:
I've implemented the BundleTracker as indicated by you.
Now I just wanted to know, if that's the way you meant it to be or if there is a more elegant way to do this?

The implementation scanning all bundles for a specific import package that contains the annotation I'm looking for can be found here:
https://github.com/Sandared/flow-osgi/blob/master/flow.osgi.integration/src/main/java/io/jatoms/flow/osgi/integration/FlowOSGiTracker.java

Kind regards,
Thomas



------ Originalnachricht ------
Von: "Thomas Driessen" <thomas.driessen...@gmail.com>
An: "Tim Ward" <tim.w...@paremus.com>
Gesendet: 23.01.2019 17:56:49
Betreff: Re[2]: [osgi-dev] Scanning classes at runtime

Unfortunatly I don't have any control over the bundles that I have to inspect. However, I could offer a second scanning implementation that uses the req-cap strategy if a developer wants to use that.

Thanks again :)

------ Originalnachricht ------
Von: "Tim Ward" <tim.w...@paremus.com>
An: "Thomas Driessen" <thomas.driessen...@gmail.com>; "OSGi Developer Mail List" <osgi-dev@mail.osgi.org>
Gesendet: 23.01.2019 17:51:25
Betreff: Re: [osgi-dev] Scanning classes at runtime

Depending on how much control you have over the bundles providing the types you could also look at providing your own extender capabiltiy/requirement model which would further restrict your search space, and potentially allow further optimisations. You should take a look at the OSGi CDI specification from the enterprise R7 release (currently in draft) which does something very much like this.

Tim

On 23 Jan 2019, at 16:48, Tim Ward <tim.w...@paremus.com> wrote:

Hi,

You can optimise this pretty heavily by using the bundle wirings to look for bundles which are wired to the same API packages as you (the one(s) that contain the relevant interface/supertype/annotation). This way you can avoid scanning bundles which can’t possibly contain relevant types.

Best Regards,

Tim

On 23 Jan 2019, at 16:10, Thomas Driessen via osgi-dev <osgi-dev@mail.osgi.org> wrote:

Hi,

for a project of mine I need to mimic the behavior of a ServletContainerInitializer [1], but with the dynamism of OSGi in mind.

Therefore, I need to be able to find all classes that implement/extend a specific class or are annotated with a specific annotation at runtime.

Is there a better way to do so that I'm not aware of than to scan each class of every bundle? Are there maybe framework hooks that would help me accomplish this?

I'm thankful for every hint you can provide.

Kind regards,
Thomas

[1] https://docs.oracle.com/javaee/6/api/javax/servlet/ServletContainerInitializer.html
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to