Updated Branches: refs/heads/develop 25f18e98e -> aa4de7ac8
fixed issues with the version used for the http requests by the java client Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/d8147015 Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/d8147015 Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/d8147015 Branch: refs/heads/develop Commit: d81470155b61cb985710d6811c684f02ea82ed54 Parents: 2137810 Author: Sergio Fernández <[email protected]> Authored: Fri May 17 10:55:01 2013 +0200 Committer: Sergio Fernández <[email protected]> Committed: Fri May 17 10:55:01 2013 +0200 ---------------------------------------------------------------------- client/marmotta-client-java/pom.xml | 14 +++ .../org/apache/marmotta/client/util/HTTPUtil.java | 7 +- .../org/apache/marmotta/client/util/MetaUtil.java | 65 +++++++++++++++ 3 files changed, 82 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d8147015/client/marmotta-client-java/pom.xml ---------------------------------------------------------------------- diff --git a/client/marmotta-client-java/pom.xml b/client/marmotta-client-java/pom.xml index 4737e5e..bd588dd 100644 --- a/client/marmotta-client-java/pom.xml +++ b/client/marmotta-client-java/pom.xml @@ -37,6 +37,20 @@ <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <inherited>true</inherited> + <configuration> + <archive> + <manifest> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d8147015/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/HTTPUtil.java ---------------------------------------------------------------------- diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/HTTPUtil.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/HTTPUtil.java index f2b5f12..9043623 100644 --- a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/HTTPUtil.java +++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/HTTPUtil.java @@ -17,6 +17,8 @@ */ package org.apache.marmotta.client.util; +import java.io.IOException; + import org.apache.commons.lang.StringUtils; import org.apache.http.Header; import org.apache.http.HttpRequest; @@ -37,9 +39,6 @@ import org.apache.http.params.CoreProtocolPNames; import org.apache.http.params.HttpParams; import org.apache.http.protocol.HttpContext; import org.apache.marmotta.client.ClientConfiguration; -import org.apache.marmotta.client.MarmottaClient; - -import java.io.IOException; /** * HTTP Utilities @@ -54,7 +53,7 @@ public class HTTPUtil { public static HttpClient createClient(ClientConfiguration config) { HttpParams httpParams = new BasicHttpParams(); - httpParams.setParameter(CoreProtocolPNames.USER_AGENT, "Marmotta Client Library/"+ MarmottaClient.VERSION); + httpParams.setParameter(CoreProtocolPNames.USER_AGENT, "Marmotta Client Library/"+ MetaUtil.getVersion()); httpParams.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, config.getSoTimeout()); httpParams.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, config.getConnectionTimeout()); http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d8147015/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/MetaUtil.java ---------------------------------------------------------------------- diff --git a/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/MetaUtil.java b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/MetaUtil.java new file mode 100644 index 0000000..9150f49 --- /dev/null +++ b/client/marmotta-client-java/src/main/java/org/apache/marmotta/client/util/MetaUtil.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.marmotta.client.util; + +import java.io.InputStream; +import java.util.Properties; + +/** + * Meta utilities + * + * @author Sergio Fernández + * + */ +public class MetaUtil { + + public static String getVersion() { + String version = null; + + // try to load from maven properties first + try { + Properties p = new Properties(); + InputStream is = MetaUtil.class.getResourceAsStream("/META-INF/maven/org.apache.marmotta/marmotta-client-java/pom.properties"); + if (is != null) { + p.load(is); + version = p.getProperty("version", ""); + } + } catch (Exception e) { + // ignore + } + + // fallback to using Java API + if (version == null) { + Package aPackage = MetaUtil.class.getPackage(); + if (aPackage != null) { + version = aPackage.getImplementationVersion(); + if (version == null) { + version = aPackage.getSpecificationVersion(); + } + } + } + + if (version == null) { + // we could not compute the version so use a blank + version = ""; + } + + return version; + } + +}
