[ 
https://issues.apache.org/jira/browse/COMMONSRDF-73?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marco Brandizi updated COMMONSRDF-73:
-------------------------------------
    Description: 
I'm trying to setup the RDF object one should use with Commons-RDF in a 
transparent way, using the SPI mechanism, ServiceLoader and 
META-INF/org.apache.commons.rdf.api.RDF. 

This is the code I'm using:

{{private synchronized static RDF getDefaultRdf () 
{
        if ( defaultRdf != null ) return defaultRdf;
        
        ServiceLoader<RDF> loader = ServiceLoader.load ( RDF.class );
        Iterator<RDF> itr = loader.iterator();
        
        if ( !itr.hasNext () ) throw new RdfException (
                "No implementation found for Commons RDF, please, review your 
dependencies/classpath"
        );
        defaultRdf = itr.next();
        if ( itr.hasNext () ) log.warn ( 
                "More than one RDF instance available for Commons RDF, taking 
the first one ({})", 
                itr.next ().getClass ().getName () 
        );      
        
        return defaultRdf;
}
}}

I've done a first test with the Jena module (commons-rdf-jena). SPI is broken 
by the fact this module also declares commons-rdf-simple as one of its 
dependencies. At least in Maven, the META-INF in commons-rdf-simple is the 
first that is met in the classpath and the simple implementation is the one 
that is picked by the code above, as reported by the warning. I expect the Jena 
implementation to be pulled up when I link the jena module as the only 
dependency.

Such dependency should be removed. I've given a look at the source files and it 
seem the simple module is only used for testing purposes (but physically is in 
the main code folders).


  was:
I'm trying to setup the RDF object one should use with Commons-RDF in a 
transparent way, using the SPI mechanism, ServiceLoader and 
META-INF/org.apache.commons.rdf.api.RDF. 

This is the code I'm using:

{{
private synchronized static RDF getDefaultRdf () 
{
        if ( defaultRdf != null ) return defaultRdf;
        
        ServiceLoader<RDF> loader = ServiceLoader.load ( RDF.class );
        Iterator<RDF> itr = loader.iterator();
        
        if ( !itr.hasNext () ) throw new RdfException (
                "No implementation found for Commons RDF, please, review your 
dependencies/classpath"
        );
        defaultRdf = itr.next();
        if ( itr.hasNext () ) log.warn ( 
                "More than one RDF instance available for Commons RDF, taking 
the first one ({})", 
                itr.next ().getClass ().getName () 
        );      
        
        return defaultRdf;
}
}}

I've done a first test with the Jena module (commons-rdf-jena). SPI is broken 
by the fact this module also declares commons-rdf-simple as one of its 
dependencies. At least in Maven, the META-INF in commons-rdf-simple is the 
first that is met in the classpath and the simple implementation is the one 
that is picked by the code above, as reported by the warning. I expect the Jena 
implementation to be pulled up when I link the jena module as the only 
dependency.

Such dependency should be removed. I've given a look at the source files and it 
seem the simple module is only used for testing purposes (but physically is in 
the main code folders).



> Jena module has Simple dependency, SPI will never work
> ------------------------------------------------------
>
>                 Key: COMMONSRDF-73
>                 URL: https://issues.apache.org/jira/browse/COMMONSRDF-73
>             Project: Apache Commons RDF
>          Issue Type: Bug
>          Components: jena
>    Affects Versions: 0.3.0
>            Reporter: Marco Brandizi
>
> I'm trying to setup the RDF object one should use with Commons-RDF in a 
> transparent way, using the SPI mechanism, ServiceLoader and 
> META-INF/org.apache.commons.rdf.api.RDF. 
> This is the code I'm using:
> {{private synchronized static RDF getDefaultRdf () 
> {
>       if ( defaultRdf != null ) return defaultRdf;
>       
>       ServiceLoader<RDF> loader = ServiceLoader.load ( RDF.class );
>       Iterator<RDF> itr = loader.iterator();
>       
>       if ( !itr.hasNext () ) throw new RdfException (
>               "No implementation found for Commons RDF, please, review your 
> dependencies/classpath"
>       );
>       defaultRdf = itr.next();
>       if ( itr.hasNext () ) log.warn ( 
>               "More than one RDF instance available for Commons RDF, taking 
> the first one ({})", 
>               itr.next ().getClass ().getName () 
>       );      
>       
>       return defaultRdf;
> }
> }}
> I've done a first test with the Jena module (commons-rdf-jena). SPI is broken 
> by the fact this module also declares commons-rdf-simple as one of its 
> dependencies. At least in Maven, the META-INF in commons-rdf-simple is the 
> first that is met in the classpath and the simple implementation is the one 
> that is picked by the code above, as reported by the warning. I expect the 
> Jena implementation to be pulled up when I link the jena module as the only 
> dependency.
> Such dependency should be removed. I've given a look at the source files and 
> it seem the simple module is only used for testing purposes (but physically 
> is in the main code folders).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to