You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2012/05/18 05:04:40 UTC

svn commit: r1339960 - in /geronimo/bundles/trunk/axis2: pom.xml src/main/java/org/apache/axis2/description/Version.java

Author: xuhaihong
Date: Fri May 18 03:04:39 2012
New Revision: 1339960

URL: http://svn.apache.org/viewvc?rev=1339960&view=rev
Log:
GERONIMO-6349 Follow Axis2 version convention in Geronimo Axis2 bundle

Added:
    geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java   (with props)
Modified:
    geronimo/bundles/trunk/axis2/pom.xml

Modified: geronimo/bundles/trunk/axis2/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/axis2/pom.xml?rev=1339960&r1=1339959&r2=1339960&view=diff
==============================================================================
--- geronimo/bundles/trunk/axis2/pom.xml (original)
+++ geronimo/bundles/trunk/axis2/pom.xml Fri May 18 03:04:39 2012
@@ -310,11 +310,16 @@
                            org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl$5.class=target/classes/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl$5.class,
                            org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl$6.class=target/classes/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl$6.class,
                            org/apache/axis2/transport/http/AbstractHTTPSender.class=target/classes/org/apache/axis2/transport/http/AbstractHTTPSender.class,
+                           
+                           <!--Axis2-5062-->
                            org/apache/axis2/transport/http/HTTPSender.class=target/classes/org/apache/axis2/transport/http/HTTPSender.class,
+                           
+                           <!--Axis2-5039-->
                            org/apache/axis2/client/OperationClient.class=target/classes/org/apache/axis2/client/OperationClient.class,
                            org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.class=target/classes/org/apache/axis2/jaxws/description/impl/PostRI216MethodRetrieverImpl.class,
                            org/apache/axis2/jaxws/client/dispatch/BaseDispatch.class=target/classes/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.class,
                            
+                           <!--Axis2-5023-->
                            org/apache/axis2/jaxws/message/Block.class=target/classes/org/apache/axis2/jaxws/message/Block.class,
                            org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.class=target/classes/org/apache/axis2/jaxws/message/databinding/impl/XMLStringBlockImpl.class,
                            org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.class=target/classes/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.class,
@@ -329,6 +334,7 @@
                            org/apache/axis2/jaxws/message/impl/XMLSpineImpl.class=target/classes/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.class,                           
                            org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.class=target/classes/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.class,
                            
+                           <!--Axis2-5115-->
                            org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.class=target/classes/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl.class,
                            org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl$1.class=target/classes/org/apache/axis2/jaxws/description/impl/EndpointInterfaceDescriptionImpl$1.class,
                            org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.class=target/classes/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.class,
@@ -336,7 +342,10 @@
                            
                            <!--Axis2-5323-->
                            org/apache/axis2/jaxws/marshaller/impl/alt/LegacyExceptionUtil.class=target/classes/org/apache/axis2/jaxws/marshaller/impl/alt/LegacyExceptionUtil.class,
-                           org/apache/axis2/jaxws/i18n/resource.properties=target/classes/org/apache/axis2/jaxws/i18n/resource.properties
+                           org/apache/axis2/jaxws/i18n/resource.properties=target/classes/org/apache/axis2/jaxws/i18n/resource.properties,
+                           
+                           <!--GERONIMO-6349-->
+                           org/apache/axis2/description/Version.class=target/classes/org/apache/axis2/description/Version.class
                         </Include-Resource>
                         <SPI-Provider>true</SPI-Provider>
                     </instructions>

Added: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java?rev=1339960&view=auto
==============================================================================
--- geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java (added)
+++ geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java Fri May 18 03:04:39 2012
@@ -0,0 +1,175 @@
+/*
+ * 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.axis2.description;
+
+import java.io.Serializable;
+import java.text.ParseException;
+import java.util.Arrays;
+
+/**
+ * Class representing a version number and implementing a comparison algorithm compatible
+ * with Maven. This class is primarily used for module versions.
+ */
+public class Version implements Serializable, Comparable<Version> {
+    private static final String S_SNAPSHOT = "SNAPSHOT";
+    
+    public static final Version SNAPSHOT = new Version(null, S_SNAPSHOT);
+    
+    private final int[] components;
+    private final String qualifier;
+    
+    /**
+     * Constructor.
+     * 
+     * @param components the numeric components of the version; may be null for SNAPSHOT version
+     * @param qualifier the qualifier
+     */
+    public Version(int[] components, String qualifier) {
+        this.components = components == null ? null : components.clone();
+        this.qualifier = qualifier;
+    }
+    
+    /**
+     * Constructor that parses the version from a string. The version must have the
+     * following format:
+     * <pre>
+     * integer ( "." integer )* ( "-" qualifier )?
+     * </pre>
+     * 
+     * @param versionString the string representation of the version
+     * @throws ParseException if the version is not in the correct format
+     */
+    public Version(String versionString) throws ParseException {
+        if (versionString.equals(S_SNAPSHOT)) {
+            components = null;
+            qualifier = S_SNAPSHOT;
+        } else {
+            //GERONIMO-6349 Geronimo re-bundle Axis2 modules, and use versions like '1.6.1_1', while Axis2 does not support
+            //this kind of version string, the basic idea is to convert _ to -, then treat the following string as qulifier.
+            int middlelineIndex = versionString.indexOf('-');
+            int underlineIndex = versionString.indexOf('_');
+            if(middlelineIndex < underlineIndex) {
+                versionString = versionString.replaceFirst("[_]", "-");
+            }
+            //
+            int dashIndex = versionString.indexOf('-');
+            if (dashIndex != -1) {
+                qualifier = versionString.substring(dashIndex + 1);
+                versionString = versionString.substring(0, dashIndex);
+            } else if (versionString.endsWith(".SNAPSHOT")){
+                qualifier = "SNAPSHOT";
+                versionString = versionString.substring(0,versionString.indexOf(".SNAPSHOT"));
+            } else {
+                qualifier = null;
+            }
+            String[] componentStrings = versionString.split("\\.");
+            int l = componentStrings.length;
+            components = new int[l];
+            for (int i=0; i<l; i++) {
+                components[i] = Integer.parseInt(componentStrings[i]);
+            }
+        }
+    }
+    
+    @Override
+    public int hashCode() {
+        return 31*Arrays.hashCode(components) + ((qualifier == null) ? 0 : qualifier.hashCode());
+    }
+    
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof Version) {
+            Version other = (Version)obj;
+            return Arrays.equals(components, other.components)
+                && (qualifier == other.qualifier ||
+                        qualifier != null && qualifier.equals(other.qualifier));
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder buffer = new StringBuilder();
+        if (components != null) {
+            for (int i=0; i<components.length; i++) {
+                if (i>0) {
+                    buffer.append('.');
+                }
+                buffer.append(components[i]);
+            }
+        }
+        if (qualifier != null) {
+            if (components != null) {
+                buffer.append('-');
+            }
+            buffer.append(qualifier);
+        }
+        return buffer.toString();
+    }
+
+    public int compareTo(Version o) {
+        // components == null means SNAPSHOT and SNAPSHOT is always
+        // assumed to be the most recent version
+        if (components == null && o.components != null) {
+            return 1;
+        } else if (components != null && o.components == null) {
+            return -1;
+        } else if (components == null && o.components == null) {
+            return 0;
+        }
+        // Now compare version components
+        int l = Math.min(components.length, o.components.length);
+        for (int i=0; i<l; i++) {
+            int c = components[i] - o.components[i];
+            if (c != 0) {
+                return c;
+            }
+        }
+        // x.y always comes before x.y.z
+        int c = components.length - o.components.length;
+        if (c != 0) {
+            return c;
+        }
+        // x.y always comes after x.y-qqqqqq
+        if (qualifier == null && o.qualifier != null) {
+            return 1;
+        } else if (qualifier != null && o.qualifier == null) {
+            return -1;
+        } else if (qualifier == null && o.qualifier == null) {
+            return 0;
+        }
+        // x.y-SNAPSHOT comes after any x.y-qqqqqq
+        boolean thisIsSnapshot = qualifier.equals(S_SNAPSHOT);
+        boolean otherIsSnapshot = o.qualifier.equals(S_SNAPSHOT);
+        if (thisIsSnapshot && !otherIsSnapshot) {
+            return 1;
+        } else if (!thisIsSnapshot && thisIsSnapshot) {
+            return -1;
+        } else if (thisIsSnapshot && otherIsSnapshot) {
+            return 0;
+        }
+        // Finally compare the qualifiers using case-insensitive string comparison.
+        return qualifier.compareToIgnoreCase(o.qualifier);
+    }
+}

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/Version.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain