I have used ServiceLoader together with OSGi. Basically you will have to duplicate the discovery with OSGi services as each OSGi classloader won't see the META-INF/services file. There is however no conflict with supporting both approaches.
What I did was to have a bean property set to null, and through OSGi inject the list of service instances in the setter, while the getter would fall back to a ServiceLoader if it was still null. But the relevance for Commons RDF is perhaps of importance here..I have used it where I wanted many services (e.g. multiple parsers for different formats), but in C-RDF the only candidate I can see is RDFTermFactory. I think we can easily let simple/ have the appropriate META-INF file for this, but not to instantiate our own service loader from api/, just document this as one possible discovery mechanism. Unlike say DOM API implementations I can imagine many scenarios where a single factory instance per code implementation is NOT the best route, e.g. Jena might want to have one factory per TDB storage. On 30 Apr 2015 07:35, "Sergio Fernández" <[email protected]> wrote: > Hi Benedikt > > so far we've been focused on the api, so we never discussed such aspects > about implementations, but now it's the perfect timing. > > We extensively use ServiceLoader in both Sesame and Marmotta, and I'd like > to use here too. I'm aware of some concerns from the OSGi gang. So I'm > happy to listen more opinions. > > I've just created COMMONSRDF-20 to handle this issue. > > Thanks Benedikt! > > Cheers, > > > > On Wed, Apr 29, 2015 at 9:28 AM, Benedikt Ritter <[email protected]> > wrote: > > > Hey, > > > > with the strict separation between RDF interfaces and implementations, I > > wonder if if would make sense to make it possible to look up > > implementations using the ServiceLoader [1]. As far as a know, all we > would > > have to do, is to add a file to the META-INF folder of the simple > > implementation package. > > > > br, > > Benedikt > > > > [1] > http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html > > > > -- > > http://people.apache.org/~britter/ > > http://www.systemoutprintln.de/ > > http://twitter.com/BenediktRitter > > http://github.com/britter > > > > > > -- > Sergio Fernández > Partner Technology Manager > Redlink GmbH > m: +43 6602747925 > e: [email protected] > w: http://redlink.co >
