felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Chemouil <schemo...@gmail.com>
Subject Re: XMLParserActivator
Date Sat, 12 Feb 2011 20:01:16 GMT
On Sat, Feb 12, 2011 at 4:37 PM, Per-Erik Svensson
<pererik.svensson@gmail.com> wrote:
> Hi all,
> I was wondering how to use the XMLParserActivator. I cant seem to find any
> information about how it works. First of all, we bundle felix into our own
> application and supply some "base/core" bundles to the framework (starting
> together with the framework). One such base bundle would be an xml parser
> factory so that our bundles can get a hold of an xml parser (factory).

If you have a bundle that provides a parser factory, you should use
the Service Loader mechanism (
) and the XMLParserActivator might find it and use it. But if it's
*your* implementation it would be better if you registered your own
factory as an OSGi service directly.

>   1. So, is the XMLParserActivator supplied by the felix framework somehow?
>   I cant see it when listing all currently registered services (and my guess
>   is that it isnt a service at all).

The XMLParserActivator is in fact a part of the OSGi spec, and its
package is supplied in the OSGi compendium 4.2 so it's the same for
all frameworks. Its goal is to scan for bundles (or JRE) providing
SAX/DOM factories (hopefully, StAX soon as well!) using the Java
ServiceLoader mechanism and export those factories as OSGi services.
The Javadoc for this class says pretty much everything:

>   3. Once it is set up, how is it supposed to be used? It doesn't look like
>   a service so when I ask the service registry, what interface should I be
>   asking for?
> In short: bundleContext.getServiceReferences("What to type here?", "any
> required filters?");

You don't use this directly activator. It's a bridge provided by OSGi
util to give you those XML parser factories as OSGi services.

You can get the services it exports by their name:




If you can avoid referencing the XMLParserActivator class it would be
nicer (e.g, first lines are better). The only real usage is if you
want to get the name of the implementation you're using (DOMCLASSFILE

(Common sense, as usual, is that you should probably consume services
using a framework above the basic OSGi API, like DS, iPOJO, Peaberry
or Blueprint).

> The only thing I get when searching the web is either about Equinox or
> JavaDoc for the XMLParserActivator.

The JavaDoc is pretty much all you need once you get why it's there :).



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

View raw message