You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by lk...@apache.org on 2006/06/20 19:52:16 UTC

svn commit: r415783 - in /incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb: OB/GIOPClient.java OB/GIOPConnection.java OB/IORDump.java OB/OB_Extras.java OB/Version.java OBCORBA/ORB_impl.java

Author: lkuehne
Date: Tue Jun 20 12:52:15 2006
New Revision: 415783

URL: http://svn.apache.org/viewvc?rev=415783&view=rev
Log:
YOKO-68:
- Print version number from Maven pom in Version and IORDump tools
- no longer send or expect version info in the service context

Modified:
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/OB_Extras.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/Version.java
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java?rev=415783&r1=415782&r2=415783&view=diff
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPClient.java Tue Jun 20 12:52:15 2006
@@ -27,11 +27,6 @@
     protected GIOPConnection connection_;
 
     //
-    // Yoko version SC
-    // 
-    protected org.omg.IOP.ServiceContext versionSC_;
-
-    //
     // Codesets SC
     // 
     protected org.omg.IOP.ServiceContext codeSetSC_;
@@ -279,19 +274,6 @@
         }
 
         //
-        // create the version SC?
-        //
-        if (versionSC_ == null) {
-            versionSC_ = new org.omg.IOP.ServiceContext();
-            versionSC_.context_id = org.apache.yoko.orb.OB.OB_Extras.Version_SC;
-            versionSC_.context_data = new byte[4];
-            versionSC_.context_data[0] = (byte) (org.apache.yoko.orb.OB.Version.integer_version & 0xff);
-            versionSC_.context_data[1] = (byte) ((org.apache.yoko.orb.OB.Version.integer_version >>> 8) & 0xff);
-            versionSC_.context_data[2] = (byte) ((org.apache.yoko.orb.OB.Version.integer_version >>> 16) & 0xff);
-            versionSC_.context_data[3] = (byte) ((org.apache.yoko.orb.OB.Version.integer_version >>> 24) & 0xff);
-        }
-
-        //
         // NOTE: We don't initialize the INVOCATION_POLICIES service context
         // here because the list of policies can change from one invocation to
         // the next. Instead, we need to get the policies and build the
@@ -383,9 +365,8 @@
         //
         initServiceContexts();
 
-        org.omg.IOP.ServiceContext[] scl = new org.omg.IOP.ServiceContext[2];
+        org.omg.IOP.ServiceContext[] scl = new org.omg.IOP.ServiceContext[1];
         scl[0] = codeSetSC_;
-        scl[1] = versionSC_;
 
         //
         // return the list
@@ -501,12 +482,6 @@
                 Assert._OB_assert(codeSetSC_ != null);
                 down.addToRequestSCL(codeSetSC_);
             }
-
-            //
-            // send the version if we haven't already
-            // 
-            if (!connection.requestSent())
-                down.addToRequestSCL(versionSC_);
 
             // 
             // I don't want to send BiDir related contexts if I'm not

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java?rev=415783&r1=415782&r2=415783&view=diff
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/GIOPConnection.java Tue Jun 20 12:52:15 2006
@@ -148,13 +148,6 @@
     protected CodeConverters codeConverters_ = null;
 
     //
-    // sent by clients to servers on the first message to indicate what
-    // version of Orbacus they are, and sent back from the server to the
-    // client on the first reply
-    //
-    protected int peerOrbacusVersion_ = 0;
-
-    //
     // maximum GIOP version encountered during message transactions
     //
     protected org.omg.GIOP.Version giopVersion_ = new org.omg.GIOP.Version(
@@ -266,39 +259,6 @@
     }
 
     //
-    // read the Orbacus peer version from the SCL
-    //
-    protected void readOBPeerVersion(org.omg.IOP.ServiceContext[] scl) {
-        for (int i = 0; i < scl.length; i++) {
-            if (scl[i].context_id == org.apache.yoko.orb.OB.OB_Extras.Version_SC) {
-                byte[] data = scl[i].context_data;
-
-                //
-                // version is always stored in little endian format
-                // 
-                peerOrbacusVersion_ = data[0];
-                peerOrbacusVersion_ |= data[1] << 8;
-                peerOrbacusVersion_ |= data[2] << 16;
-                peerOrbacusVersion_ |= data[3] << 24;
-
-                CoreTraceLevels coreTraceLevels = orbInstance_
-                        .getCoreTraceLevels();
-                if (coreTraceLevels.traceConnections() >= 2) {
-                    String msg = "Orbacus Peer Version ";
-                    msg += java.lang.String.valueOf(peerOrbacusVersion_);
-                    orbInstance_.getLogger().trace("incoming", msg);
-                }
-
-                //
-                // we should only have 1 version_SC and we skip any
-                // others just in case
-                // 
-                break;
-            }
-        }
-    }
-
-    //
     // set the OAInterface used by BiDir clients to handle requests
     // Returns true if an OAInterface is found; false otherwise
     //
@@ -515,11 +475,6 @@
                     | version.minor);
 
         //
-        // get the version from the SCL if present
-        //
-        readOBPeerVersion(scl.value);
-
-        //
         // New upcall will be started
         //
         if (response.value)
@@ -570,11 +525,6 @@
         down.setReplySCL(scl.value);
         org.apache.yoko.orb.CORBA.InputStream in = msg.input();
 
-        //
-        // read in the peer orbacus version from the SCL if exists
-        //
-        readOBPeerVersion(scl.value);
-        
         // 
         // read in the peer's sendig context runtime object
         //
@@ -1179,33 +1129,8 @@
 
         try {
             synchronized (this) {
-                //
-                // add the version SC to the first reply
-                //
-                if ((properties_ & Property.ReplySent) == 0) {
-                    properties_ |= Property.ReplySent;
-
-                    org.omg.IOP.ServiceContext versionSC = new org.omg.IOP.ServiceContext();
-                    versionSC.context_id = org.apache.yoko.orb.OB.OB_Extras.Version_SC;
-                    versionSC.context_data = new byte[4];
-                    versionSC.context_data[0] = (byte) (org.apache.yoko.orb.OB.Version.integer_version & 0xff);
-                    versionSC.context_data[1] = (byte) ((org.apache.yoko.orb.OB.Version.integer_version >>> 8) & 0xff);
-                    versionSC.context_data[2] = (byte) ((org.apache.yoko.orb.OB.Version.integer_version >>> 16) & 0xff);
-                    versionSC.context_data[3] = (byte) ((org.apache.yoko.orb.OB.Version.integer_version >>> 24) & 0xff);
-
-                    org.omg.IOP.ServiceContext[] mscl = new org.omg.IOP.ServiceContext[scl.length + 1];
-                    System.arraycopy(scl, 0, mscl, 0, scl.length);
-                    mscl[scl.length] = versionSC;
-
-                    outgoing
-                            .writeReplyHeader(
-                                    reqId,
-                                    org.omg.GIOP.ReplyStatusType_1_2.NO_EXCEPTION,
-                                    mscl);
-                } else {
-                    outgoing.writeReplyHeader(reqId,
-                            org.omg.GIOP.ReplyStatusType_1_2.NO_EXCEPTION, scl);
-                }
+                outgoing.writeReplyHeader(reqId,
+                        org.omg.GIOP.ReplyStatusType_1_2.NO_EXCEPTION, scl);
             }
         } catch (org.omg.CORBA.SystemException ex) {
             //

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java?rev=415783&r1=415782&r2=415783&view=diff
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORDump.java Tue Jun 20 12:52:15 2006
@@ -129,7 +129,7 @@
                 usage();
                 return 0;
             } else if (args[i].equals("--version") || args[i].equals("-v")) {
-                System.out.println("Yoko " + Version.version);
+                System.out.println("Yoko " + Version.getVersion());
                 return 0;
             } else if (args[i].equals("-f")) {
                 files = true;

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/OB_Extras.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/OB_Extras.java?rev=415783&r1=415782&r2=415783&view=diff
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/OB_Extras.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/OB_Extras.java Tue Jun 20 12:52:15 2006
@@ -13,11 +13,6 @@
 
 public interface OB_Extras {
     //
-    // Special Service Context Identifier for version
-    // 
-    public final int Version_SC = 0x0B0B0B01;
-
-    //
     // Whether or not we are building a server capable of the
     // legacy compatible wide-char marshaling/unmarshaling
     // 

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/Version.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/Version.java?rev=415783&r1=415782&r2=415783&view=diff
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/Version.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/Version.java Tue Jun 20 12:52:15 2006
@@ -11,40 +11,59 @@
 
 package org.apache.yoko.orb.OB;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Holds Yoko version information.
+ */
 public final class Version {
-    //
-    // The Yoko version, as string and as integer
-    //
-    // Format of integer_version: ABBCCDD
-    //
-    // For regular releases (that is non-beta and non-alpha), A is the
-    // major version, BB the minor version, CC the patchlevel version, and
-    // DD is 00. Examples:
-    //
-    // ABBCCDD
-    // Version 3.2 3020000L
-    // Version 3.2.4 3020400L
-    // Version 4.0 4000000L
-    // Version 4.0.1 4000100L
-    //
-    // For alpha and beta releases, 1 must be substracted from ABBCC. For
-    // alpha releases, DD is then the alpha release number. For beta
-    // releases, DD is the beta release number plus 50. Examples:
-    //
-    // ABBCCDD
-    // Version 3.2a1 3019901L
-    // Version 3.2.4b2 3020352L
-    // Version 4.0b1 3999951L
-    // Version 4.0.1a1 4000001L
-    //
-    static public final String version = "4.3.1";
 
-    static public final int integer_version = 4030100;
+    private static final String VERSION = readVersionFromMavenPom(
+            "org.apache.yoko", "yoko-core");
+
+    private static final String UNKNOWN = "[version unknown]";
+
+    public static String getVersion() {
+        return VERSION;
+    }
+
+    /**
+     * Reads the version from the pom.properties that Maven2 puts in the
+     * META-INF of the generated jar.
+     * 
+     * @param groupId
+     *            the Maven groupId of yoko
+     * @param artifactId
+     *            the Maven artifact id
+     * @return the version string from the POM, or
+     *         <code>"[version unknown]"</code> if the pom.properties cannot
+     *         be loaded by the current thread's classloader
+     */
+    private static String readVersionFromMavenPom(String groupId,
+            String artifactId) {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        Properties props = new Properties();
 
-    static public final String special_version_tag = "GA Release";
+        String propFileName = "META-INF/maven/" + groupId + "/" + artifactId
+                + "/pom.properties";
+        InputStream a = cl.getResourceAsStream(propFileName);
+        if (a == null)
+            return UNKNOWN;
+        try {
+            props.load(a);
+        } catch (IOException e) {
+            return UNKNOWN;
+        }
+        final String version = props.getProperty("version");
+        if (version == null) {
+            return UNKNOWN;
+        }
+        return version;
+    }
 
     public static void main(String[] args) {
-        System.out.println("Yoko for Java " + version + " ["
-                + special_version_tag + "]");
+        System.out.println("Yoko " + getVersion());
     }
 }

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java?rev=415783&r1=415782&r2=415783&view=diff
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java Tue Jun 20 12:52:15 2006
@@ -11,9 +11,6 @@
 
 package org.apache.yoko.orb.OBCORBA;
 
-import org.apache.yoko.orb.OBPortableServer.*;
-import org.apache.yoko.orb.PortableServer.*;
-
 // This class must be public and not final
 public class ORB_impl extends org.apache.yoko.orb.CORBA.ORBSingleton {
     //
@@ -1702,7 +1699,7 @@
             } else if (name.equals("threaded")) {
                 properties.put("yoko.orb.conc_model", "threaded");
             } else if (name.equals("version")) {
-                logger.info(org.apache.yoko.orb.OB.Version.version);
+                logger.info(org.apache.yoko.orb.OB.Version.getVersion());
             } else if (name.equals("native_cs")) {
                 properties.put("yoko.orb.native_cs", value[0]);
             } else if (name.equals("native_wcs")) {