Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2A573200D56 for ; Mon, 27 Nov 2017 19:56:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 29066160BFA; Mon, 27 Nov 2017 18:56:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7B1EC160C16 for ; Mon, 27 Nov 2017 19:56:05 +0100 (CET) Received: (qmail 63754 invoked by uid 500); 27 Nov 2017 18:56:04 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 63603 invoked by uid 99); 27 Nov 2017 18:56:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Nov 2017 18:56:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AD182C4DE9 for ; Mon, 27 Nov 2017 18:56:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.011 X-Spam-Level: X-Spam-Status: No, score=-99.011 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KB_WAM_FROM_NAME_SINGLEWORD=0.2, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id zioFuuvy1bMJ for ; Mon, 27 Nov 2017 18:56:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 9AD105F201 for ; Mon, 27 Nov 2017 18:56:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D4BA9E0732 for ; Mon, 27 Nov 2017 18:56:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 9C190241B8 for ; Mon, 27 Nov 2017 18:56:00 +0000 (UTC) Date: Mon, 27 Nov 2017 18:56:00 +0000 (UTC) From: "Marco Brandizi (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (COMMONSRDF-73) Jena module has Simple dependency, SPI will never work MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 27 Nov 2017 18:56:06 -0000 [ https://issues.apache.org/jira/browse/COMMONSRDF-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16267248#comment-16267248 ] Marco Brandizi edited comment on COMMONSRDF-73 at 11/27/17 6:55 PM: -------------------------------------------------------------------- Hi Aaron, I might be wrong on the SPI part, but look at {{getDefaultRdf()}} [here|https://github.com/marco-brandizi/rdfutils/blob/master/rdfutils-commonsrdf/src/main/java/info/marcobrandizi/rdfutils/commonsrdf/CommonsRDFUtils.java]. That is a utilities library that is based on CommonsRDF with the purpose of being independent on Jena/RDF4J. The client of that library is expected to setup things so that one of such specific implementations is picked up, and this usually happens by definining your desired implementing class in {{META-INF/services/org.apache.commons.rdf.api.RDF}}. That works well as long as there is only one of such SPI definitions in the final application. If I include the current Jena-based implementation of CommonsRDF, this drags the SimpleRDF' SPI definition with it, at that point the ServiceLoader will see two available services and it's quite unpredictable which one comes first. As you can see in my code, I've just excluded SimpleRDF by the SPI magic, but that's not ideal. was (Author: zakmck): Hi Aaron, I might be wrong on the SPI part, but look at {{getDefaultRdf()}} [here!https://github.com/marco-brandizi/rdfutils/blob/master/rdfutils-commonsrdf/src/main/java/info/marcobrandizi/rdfutils/commonsrdf/CommonsRDFUtils.java]. That is a utilities library that is based on CommonsRDF with the purpose of being independent on Jena/RDF4J. The client of that library is expected to setup things so that one of such specific implementations is picked up, and this usually happens by definining your desired implementing class in {{META-INF/services/org.apache.commons.rdf.api.RDF}}. That works well as long as there is only one of such SPI definitions in the final application. If I include the current Jena-based implementation of CommonsRDF, this drags the SimpleRDF' SPI definition with it, at that point the ServiceLoader will see two available services and it's quite unpredictable which one comes first. As you can see in my code, I've just excluded SimpleRDF by the SPI magic, but that's not ideal. > 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: > {code:java} > private synchronized static RDF getDefaultRdf () > { > if ( defaultRdf != null ) return defaultRdf; > > ServiceLoader loader = ServiceLoader.load ( RDF.class ); > Iterator 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; > } > {code} > 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, and not just because of this problem (different commons implementations should be independent of each other). I've given a look at the source files and it seem the rdf-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)