Author: kstam
Date: Tue Apr 9 17:15:00 2013
New Revision: 1466138
URL: http://svn.apache.org/r1466138
Log:
JUDDI-572, reading release version from manifest
Added:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/Release.java
Modified:
juddi/trunk/juddi-core/pom.xml
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Release.java
Added:
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/Release.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/Release.java?rev=1466138&view=auto
==============================================================================
---
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/Release.java
(added)
+++
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/Release.java
Tue Apr 9 17:15:00 2013
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.juddi.v3.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+/**
+ *
+ */
+public class Release {
+
+ private static final String UDDI_VERSION = "3.0";
+ private static final String JAR_NAME = "juddi-client";
+ private static String registryVersion = null;
+
+ private Release () {
+ }
+
+ public static String getRegistryVersion() {
+ if (registryVersion == null) {
+ registryVersion = getVersionFromManifest(JAR_NAME);
+ }
+ return registryVersion;
+
+ }
+
+ public static String getUDDIVersion() {
+ return UDDI_VERSION;
+ }
+
+ public static String getVersionFromManifest(String jarName) {
+ Enumeration<URL> resEnum;
+ try {
+ resEnum =
Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME);
+ while (resEnum.hasMoreElements()) {
+ try {
+ URL url = (URL) resEnum.nextElement();
+ if (url.toString().toLowerCase().contains(jarName)) {
+ InputStream is = url.openStream();
+ if (is != null) {
+ Manifest manifest = new Manifest(is);
+ Attributes mainAttribs =
manifest.getMainAttributes();
+ String version =
mainAttribs.getValue("Bundle-Version");
+ if (version != null) {
+ return (version);
+ }
+ }
+ }
+ } catch (Exception e) {
+ // Silently ignore wrong manifests on classpath?
+ }
+ }
+ } catch (IOException e1) {
+ // Silently ignore wrong manifests on classpath?
+ }
+ return "unknown";
+ }
+}
Modified: juddi/trunk/juddi-core/pom.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-core/pom.xml?rev=1466138&r1=1466137&r2=1466138&view=diff
==============================================================================
--- juddi/trunk/juddi-core/pom.xml (original)
+++ juddi/trunk/juddi-core/pom.xml Tue Apr 9 17:15:00 2013
@@ -22,22 +22,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.3</version>
- <!--
- <configuration>
- <excludes>
-
<exclude>**/persistence</exclude>
-
<exclude>**/persistence.xml</exclude>
-
<exclude>**/hibernate-persistence.xml</exclude>
-
<exclude>**/openjpa-persistence.xml</exclude>
-
<exclude>**/juddi-orm.xml</exclude>
- </excludes>
- </configuration>
- -->
- </plugin>
- <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
@@ -55,7 +39,6 @@
org.apache.juddi.v3.error</Export-Package>
<Include-Resource>juddi_install_data=src/main/resources/juddi_install_data,
src/main/resources/messages.properties</Include-Resource>
-
</instructions>
</configuration>
</plugin>
@@ -68,13 +51,6 @@
<phase>generate-resources</phase>
<configuration>
<tasks>
- <copy
file="src/main/resources/version/Release.java.template"
-
tofile="src/main/java/org/apache/juddi/config/Release.java"
-
overwrite="true">
-
<filterset>
-
<filter token="juddi.version" value="${project.version}" />
-
</filterset>
- </copy>
<delete
dir="juddi-derby-test-db" />
</tasks>
</configuration>
@@ -110,7 +86,6 @@
</plugins>
</build>
<dependencies>
-
<dependency>
<groupId>org.apache.juddi</groupId>
<artifactId>uddi-ws</artifactId>
Modified:
juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Release.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Release.java?rev=1466138&r1=1466137&r2=1466138&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Release.java
(original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/config/Release.java
Tue Apr 9 17:15:00 2013
@@ -15,22 +15,28 @@
package org.apache.juddi.config;
/**
- * WARNING:
- * Do not modify this class as it is generated. Rather update the
Release.java.template
- * in main/java/resources/version
+ *
*/
public class Release {
- private static final String REGISTRY_VERSION = "3.1.5-SNAPSHOT";
+
private static final String UDDI_VERSION = "3.0";
+ private static final String JAR_NAME = "juddi-core";
+ private static String registryVersion = null;
private Release () {
}
public static String getRegistryVersion() {
- return REGISTRY_VERSION;
+ if (registryVersion == null) {
+ registryVersion =
org.apache.juddi.v3.client.Release.getVersionFromManifest(JAR_NAME);
+ }
+ return registryVersion;
+
}
public static String getUDDIVersion() {
return UDDI_VERSION;
}
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]