geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject [23/51] [abbrv] geronimo-yoko git commit: Use YASF negotiation to maintain stream compatibility when talking Enums to unfixed yoko
Date Sun, 19 Feb 2017 01:49:40 GMT
Use YASF negotiation to maintain stream compatibility when talking Enums to unfixed yoko


Project: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/repo
Commit: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/commit/55b7d4f1
Tree: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/tree/55b7d4f1
Diff: http://git-wip-us.apache.org/repos/asf/geronimo-yoko/diff/55b7d4f1

Branch: refs/heads/master
Commit: 55b7d4f1abd50b0d446759c71f4a249245982905
Parents: 02829e8
Author: Neil GM Richards <neil_richards@uk.ibm.com>
Authored: Thu Mar 24 01:42:06 2016 +0000
Committer: Neil GM Richards <neil_richards@uk.ibm.com>
Committed: Thu Mar 24 01:42:06 2016 +0000

----------------------------------------------------------------------
 .../org/apache/yoko/orb/OBCORBA/ORB_impl.java   |  2 +-
 .../ClientRequestInfo_impl.java                 |  8 +-
 .../ServerRequestInfo_impl.java                 | 17 ++--
 .../java/org/apache/yoko/orb/yasf/Yasf.java     | 71 ----------------
 .../yoko/orb/yasf/YasfClientInterceptor.java    | 11 ++-
 .../org/apache/yoko/orb/yasf/YasfHelper.java    | 87 ++++++++++++++++++++
 .../yoko/orb/yasf/YasfIORInterceptor.java       |  3 +-
 .../yoko/orb/yasf/YasfServerInterceptor.java    | 23 +++++-
 .../apache/yoko/rmi/impl/EnumDescriptor.java    | 35 ++++++--
 .../yoko/rmi/impl/EnumSubclassDescriptor.java   |  5 +-
 .../org/apache/yoko/rmi/impl/ModelElement.java  |  2 +-
 .../org/apache/yoko/rmi/impl/ObjectWriter.java  | 27 +++---
 .../apache/yoko/rmi/impl/ValueDescriptor.java   |  2 +-
 .../java/org/apache/yoko/util/yasf/Yasf.java    | 43 ++++++++++
 .../apache/yoko/util/yasf/YasfThreadLocal.java  | 87 ++++++++++++++++++++
 15 files changed, 315 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java b/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
index 36e0044..4159e83 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/OBCORBA/ORB_impl.java
@@ -296,7 +296,7 @@ public class ORB_impl extends org.apache.yoko.orb.CORBA.ORBSingleton {
             try {
                 piManager.addIORInterceptor(new YasfIORInterceptor(), true);
                 piManager.addClientRequestInterceptor(new YasfClientInterceptor());
-                piManager.addServerRequestInterceptor(new YasfServerInterceptor());
+                piManager.addServerRequestInterceptor(new YasfServerInterceptor(piManager.allocateSlotId()));
             } catch (org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ex) {
                 org.apache.yoko.orb.OB.Assert._OB_assert(ex);
             }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ClientRequestInfo_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ClientRequestInfo_impl.java
b/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ClientRequestInfo_impl.java
index 53c938d..e2023e8 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ClientRequestInfo_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ClientRequestInfo_impl.java
@@ -19,6 +19,8 @@ package org.apache.yoko.orb.PortableInterceptor;
 
 import org.apache.yoko.util.cmsf.CmsfThreadLocal;
 import org.apache.yoko.util.cmsf.CmsfThreadLocal.CmsfOverride;
+import org.apache.yoko.util.yasf.YasfThreadLocal;
+import org.apache.yoko.util.yasf.YasfThreadLocal.YasfOverride;
 
 final public class ClientRequestInfo_impl extends RequestInfo_impl implements
         org.omg.PortableInterceptor.ClientRequestInfo {
@@ -364,7 +366,8 @@ final public class ClientRequestInfo_impl extends RequestInfo_impl implements
         argStrategy_.setArgsAvail(true);
         argStrategy_.setExceptAvail(true);
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             java.util.Enumeration e = interceptors.elements();
             while (e.hasMoreElements()) {
                 org.omg.PortableInterceptor.ClientRequestInterceptor interceptor = (org.omg.PortableInterceptor.ClientRequestInterceptor)
e
@@ -398,7 +401,8 @@ final public class ClientRequestInfo_impl extends RequestInfo_impl implements
             current_._OB_pushSlotData(currentSlots_);
         }
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             int curr = interceptors_.size() - 1;
             while (!interceptors_.isEmpty()) {
                 try {

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ServerRequestInfo_impl.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ServerRequestInfo_impl.java
b/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ServerRequestInfo_impl.java
index fb484e4..70e6fc5 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ServerRequestInfo_impl.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/PortableInterceptor/ServerRequestInfo_impl.java
@@ -19,6 +19,8 @@ package org.apache.yoko.orb.PortableInterceptor;
 
 import org.apache.yoko.util.cmsf.CmsfThreadLocal;
 import org.apache.yoko.util.cmsf.CmsfThreadLocal.CmsfOverride;
+import org.apache.yoko.util.yasf.YasfThreadLocal;
+import org.apache.yoko.util.yasf.YasfThreadLocal.YasfOverride;
 
 final public class ServerRequestInfo_impl extends RequestInfo_impl implements
         ServerRequestInfoExt {
@@ -380,7 +382,8 @@ final public class ServerRequestInfo_impl extends RequestInfo_impl implements
         argStrategy_.setArgsAvail(false);
         argStrategy_.setExceptAvail(false);
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             java.util.Enumeration e = interceptors.elements();
             while (e.hasMoreElements()) {
                 org.omg.PortableInterceptor.ServerRequestInterceptor i = (org.omg.PortableInterceptor.ServerRequestInterceptor)
e
@@ -408,7 +411,8 @@ final public class ServerRequestInfo_impl extends RequestInfo_impl implements
 
         status_ = NO_REPLY;
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             java.util.Enumeration e = interceptors_.elements();
             while (e.hasMoreElements()) {
                 ((org.omg.PortableInterceptor.ServerRequestInterceptor) (e
@@ -434,7 +438,8 @@ final public class ServerRequestInfo_impl extends RequestInfo_impl implements
         //
         servant_ = null;
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             int curr = interceptors_.size() - 1;
             while (!interceptors_.isEmpty()) {
                 org.omg.PortableInterceptor.ServerRequestInterceptor i = (org.omg.PortableInterceptor.ServerRequestInterceptor)
interceptors_
@@ -469,7 +474,8 @@ final public class ServerRequestInfo_impl extends RequestInfo_impl implements
         //
         servant_ = null;
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             org.apache.yoko.orb.OB.Assert
                     ._OB_assert(status_ == org.omg.PortableInterceptor.SYSTEM_EXCEPTION.value
                             || status_ == org.omg.PortableInterceptor.USER_EXCEPTION.value);
@@ -511,7 +517,8 @@ final public class ServerRequestInfo_impl extends RequestInfo_impl implements
         //
         servant_ = null;
 
-        try (CmsfOverride cmsfo = CmsfThreadLocal.override()) {
+        try (CmsfOverride cmsfo = CmsfThreadLocal.override();
+             YasfOverride yasfo = YasfThreadLocal.override()) {
             org.apache.yoko.orb.OB.Assert
                     ._OB_assert(status_ == org.omg.PortableInterceptor.LOCATION_FORWARD.value
                             || status_ == org.omg.PortableInterceptor.TRANSPORT_RETRY.value);

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/yasf/Yasf.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/Yasf.java b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/Yasf.java
deleted file mode 100644
index 98fdf34..0000000
--- a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/Yasf.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.apache.yoko.orb.yasf;
-
-import java.util.BitSet;
-
-import org.omg.IOP.ServiceContext;
-import org.omg.IOP.TaggedComponent;
-
-public enum Yasf {
-    ;
-
-    // TODO - Get ids from OMG assigned for these values
-    public static final int TAG_YOKO_AUXILLIARY_STREAM_FORMAT = 0xeeeeeeee;
-    public static final int YOKO_AUXIllIARY_STREAM_FORMAT_SC = 0xeeeeeeee;
-
-    public final int itemIndex;
-
-    private Yasf(int itemIndex) {
-        this.itemIndex = itemIndex;
-    }
-
-    public boolean isSet(BitSet items) {
-        return items.get(itemIndex);
-    }
-
-    public static Builder build() {
-        return new BuilderImpl();
-    }
-
-    public static BitSet readData(byte[] data) {
-        return BitSet.valueOf(data);
-    }
-
-    public interface Builder {
-        public Builder set(Yasf... items);
-        public Builder clear(Yasf... items);
-        public TaggedComponent tc();
-        public ServiceContext sc();
-    }
-
-    private static final class BuilderImpl implements Builder {
-        private final BitSet bits = new BitSet();
-
-        BuilderImpl() {}
-
-        @Override
-        public Builder set(Yasf... items) {
-            for (Yasf item: items) {
-                bits.set(item.itemIndex);
-            }
-            return this;
-        }
-
-        @Override
-        public Builder clear(Yasf... items) {
-            for (Yasf item: items) {
-                bits.clear(item.itemIndex);
-            }
-            return this;
-        }
-
-        @Override
-        public TaggedComponent tc() {
-            return new TaggedComponent(TAG_YOKO_AUXILLIARY_STREAM_FORMAT, bits.toByteArray());
-        }
-
-        @Override
-        public ServiceContext sc() {
-            return new ServiceContext(YOKO_AUXIllIARY_STREAM_FORMAT_SC, bits.toByteArray());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfClientInterceptor.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfClientInterceptor.java b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfClientInterceptor.java
index 8a56c92..dc434a0 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfClientInterceptor.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfClientInterceptor.java
@@ -5,6 +5,8 @@ import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.yoko.util.yasf.Yasf;
+import org.apache.yoko.util.yasf.YasfThreadLocal;
 import org.omg.CORBA.LocalObject;
 import org.omg.PortableInterceptor.ClientRequestInfo;
 import org.omg.PortableInterceptor.ClientRequestInterceptor;
@@ -15,7 +17,11 @@ public class YasfClientInterceptor extends LocalObject implements ClientRequestI
 
     @Override
     public void send_request(ClientRequestInfo ri) throws ForwardRequest {
-        ri.add_request_service_context(Yasf.build().sc(), false);
+        byte[] yasfData = YasfHelper.readData(ri);
+
+        YasfThreadLocal.push(Yasf.toSet(yasfData));
+
+        YasfHelper.addSc(ri, Yasf.supported());
     }
 
     @Override
@@ -24,14 +30,17 @@ public class YasfClientInterceptor extends LocalObject implements ClientRequestI
 
     @Override
     public void receive_reply(ClientRequestInfo ri) {
+        YasfThreadLocal.pop();
     }
 
     @Override
     public void receive_exception(ClientRequestInfo ri) throws ForwardRequest {
+        YasfThreadLocal.pop();
     }
 
     @Override
     public void receive_other(ClientRequestInfo ri) throws ForwardRequest {
+        YasfThreadLocal.pop();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfHelper.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfHelper.java b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfHelper.java
new file mode 100644
index 0000000..d652a2e
--- /dev/null
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfHelper.java
@@ -0,0 +1,87 @@
+package org.apache.yoko.orb.yasf;
+
+import org.apache.yoko.util.yasf.Yasf;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.ORB;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.TaggedComponent;
+import org.omg.PortableInterceptor.ClientRequestInfo;
+import org.omg.PortableInterceptor.IORInfo;
+import org.omg.PortableInterceptor.InvalidSlot;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+
+import java.util.Set;
+
+import static org.apache.yoko.orb.OB.MinorCodes.MinorInvalidComponentId;
+import static org.apache.yoko.orb.OB.MinorCodes.MinorInvalidServiceContextId;
+
+/**
+ * Created by nrichard on 23/03/16.
+ */
+public enum YasfHelper {
+    ;
+
+    public static void addTc(IORInfo info, Set<Yasf> set) {
+        TaggedComponent tc = new TaggedComponent(Yasf.TAG_YOKO_AUXILLIARY_STREAM_FORMAT,
Yasf.toData(set));
+        info.add_ior_component(tc);
+    }
+
+    private static ServiceContext sc(Set<Yasf> set) {
+        return new ServiceContext(Yasf.YOKO_AUXIllIARY_STREAM_FORMAT_SC, Yasf.toData(set));
+    }
+
+    public static void addSc(ClientRequestInfo ri, Set<Yasf> set) {
+        ServiceContext sc = sc(set);
+        ri.add_request_service_context(sc, false);
+    }
+
+    public static void addSc(ServerRequestInfo ri, Set<Yasf> set) {
+        ServiceContext sc = sc(set);
+        ri.add_reply_service_context(sc, false);
+    }
+
+    public static byte[] readData(ClientRequestInfo ri) {
+        try {
+            TaggedComponent tc = ri.get_effective_component(Yasf.TAG_YOKO_AUXILLIARY_STREAM_FORMAT);
+            return tc.component_data;
+        } catch (BAD_PARAM e) {
+            if (e.minor != MinorInvalidComponentId) {
+                throw e;
+            }
+        }
+        return null;
+    }
+
+    public static byte[] readData(ServerRequestInfo ri) {
+        try {
+            ServiceContext sc = ri.get_request_service_context(Yasf.YOKO_AUXIllIARY_STREAM_FORMAT_SC);
+            return sc.context_data;
+        } catch (BAD_PARAM e) {
+            if (e.minor != MinorInvalidServiceContextId) {
+                throw e;
+            }
+        }
+        return null;
+    }
+
+    public static void setSlot(int slotId, ServerRequestInfo ri, byte[] data) {
+        Any any = ORB.init().create_any();
+        any.insert_Value(data);
+        try {
+            ri.set_slot(slotId, any);
+        } catch (InvalidSlot e) {
+            throw (INTERNAL)(new INTERNAL(e.getMessage())).initCause(e);
+        }
+    }
+
+    public static byte[] getSlot(int slotId, ServerRequestInfo ri) {
+        try {
+            Any any = ri.get_slot(slotId);
+            return (byte[])any.extract_Value();
+        } catch (InvalidSlot e) {
+            throw (INTERNAL)(new INTERNAL(e.getMessage())).initCause(e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfIORInterceptor.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfIORInterceptor.java b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfIORInterceptor.java
index 68ef43e..ec3976a 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfIORInterceptor.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfIORInterceptor.java
@@ -5,6 +5,7 @@ import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.yoko.util.yasf.Yasf;
 import org.omg.CORBA.LocalObject;
 import org.omg.PortableInterceptor.IORInfo;
 import org.omg.PortableInterceptor.IORInterceptor;
@@ -14,7 +15,7 @@ public class YasfIORInterceptor extends LocalObject implements IORInterceptor
{
 
     @Override
     public void establish_components(IORInfo info) {
-        info.add_ior_component(Yasf.build().tc());
+        YasfHelper.addTc(info, Yasf.supported());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfServerInterceptor.java
----------------------------------------------------------------------
diff --git a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfServerInterceptor.java b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfServerInterceptor.java
index f5d5bd1..352d70e 100644
--- a/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfServerInterceptor.java
+++ b/yoko-core/src/main/java/org/apache/yoko/orb/yasf/YasfServerInterceptor.java
@@ -5,6 +5,8 @@ import java.io.NotSerializableException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.yoko.util.yasf.Yasf;
+import org.apache.yoko.util.yasf.YasfThreadLocal;
 import org.omg.CORBA.LocalObject;
 import org.omg.PortableInterceptor.ForwardRequest;
 import org.omg.PortableInterceptor.ServerRequestInfo;
@@ -13,8 +15,17 @@ import org.omg.PortableInterceptor.ServerRequestInterceptor;
 public class YasfServerInterceptor extends LocalObject implements ServerRequestInterceptor
{
     private static final String NAME = YasfServerInterceptor.class.getName();
 
+    private final int slotId;
+
+    public YasfServerInterceptor(int slotId) {
+        this.slotId = slotId;
+    }
+
     @Override
     public void receive_request_service_contexts(ServerRequestInfo ri) throws ForwardRequest
{
+        YasfThreadLocal.reset();
+        byte[] yasfData = YasfHelper.readData(ri);
+        YasfHelper.setSlot(slotId, ri, yasfData);
     }
 
     @Override
@@ -23,17 +34,23 @@ public class YasfServerInterceptor extends LocalObject implements ServerRequestI
 
     @Override
     public void send_reply(ServerRequestInfo ri) {
-        ri.add_reply_service_context(Yasf.build().sc(), false);
+        YasfThreadLocal.push(Yasf.toSet(YasfHelper.getSlot(slotId, ri)));
+        // Adding for diagnostic purposes
+        YasfHelper.addSc(ri, Yasf.supported());
     }
 
     @Override
     public void send_exception(ServerRequestInfo ri) throws ForwardRequest {
-        ri.add_reply_service_context(Yasf.build().sc(), false);
+        YasfThreadLocal.push(Yasf.toSet(YasfHelper.getSlot(slotId, ri)));
+        // Adding for diagnostic purposes
+        YasfHelper.addSc(ri, Yasf.supported());
     }
 
     @Override
     public void send_other(ServerRequestInfo ri) throws ForwardRequest {
-        ri.add_reply_service_context(Yasf.build().sc(), false);
+        YasfThreadLocal.push(Yasf.toSet(YasfHelper.getSlot(slotId, ri)));
+        // Adding for diagnostic purposes
+        YasfHelper.addSc(ri, Yasf.supported());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumDescriptor.java
----------------------------------------------------------------------
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumDescriptor.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumDescriptor.java
index 5c35933..44e692c 100644
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumDescriptor.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumDescriptor.java
@@ -18,13 +18,20 @@
 
 package org.apache.yoko.rmi.impl;
 
+import org.apache.yoko.util.yasf.Yasf;
+import org.apache.yoko.util.yasf.YasfThreadLocal;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Set;
+
 class EnumDescriptor extends ValueDescriptor {
     public EnumDescriptor(Class<?> type, TypeRepository repo) {
         super(type, repo);
     }
 
     @Override
-    final long getSerialVersionUID() {
+    protected final long getSerialVersionUID() {
         return 0L;
     }
 
@@ -33,15 +40,29 @@ class EnumDescriptor extends ValueDescriptor {
         return true;
     }
 
+    private FieldDescriptor nameField = null;
+    private FieldDescriptor ordinalField = null;
+
     @Override
     public final void init() {
         super.init();
-        FieldDescriptor[] newFields = new FieldDescriptor[1];
-        for (FieldDescriptor field: _fields) {
-            if (!!!field.java_name.equals("name")) continue;
-            newFields[0] = field;
-            break;
+        // Avoid doing anything that would cause the calculated classHash to change
+        for (FieldDescriptor f: _fields) {
+            if (f.java_name.equals("name")) {
+                nameField = f;
+            } else if (f.java_name.equals("ordinal")) {
+                ordinalField = f;
+            }
+        }
+    }
+
+    @Override
+    protected void defaultWriteValue(ObjectWriter writer, Serializable val) throws IOException
{
+        checkInit();
+        if ((writer.yasfSet != null) && !!!writer.yasfSet.contains(Yasf.ENUM_FIXED))
{
+            // talking to an old yoko that expects an ordinal field to be written;
+            ordinalField.write(writer, val);
         }
-        _fields = newFields;
+        nameField.write(writer, val);
     }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumSubclassDescriptor.java
----------------------------------------------------------------------
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumSubclassDescriptor.java
b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumSubclassDescriptor.java
index 4f5a67f..12c34c6 100644
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumSubclassDescriptor.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/EnumSubclassDescriptor.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.Serializable;
 import java.util.Map;
 
+import org.apache.yoko.rmi.util.StringUtil;
 import org.omg.CORBA.portable.IndirectionException;
 import org.omg.CORBA.portable.InputStream;
 
@@ -43,11 +44,11 @@ class EnumSubclassDescriptor extends ValueDescriptor {
     @Override
     public final void init() {
         super.init();
-        _fields = new FieldDescriptor[0];
+        // Avoid doing anything that would cause the calculated classHash to change
     }
 
     @Override
-    final long getSerialVersionUID() {
+    protected final long getSerialVersionUID() {
         return 0L;
     }
 

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ModelElement.java
----------------------------------------------------------------------
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ModelElement.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ModelElement.java
index 806028a..a3fd62e 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ModelElement.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ModelElement.java
@@ -37,7 +37,7 @@ abstract class ModelElement {
     protected abstract String genIDLName();
 
     final void checkInit() {
-        if (notInit) throw new IllegalStateException("Not initialized");
+        if (notInit) throw new IllegalStateException("Not initialized: " + java_name);
     }
     public String getIDLName() {
         checkInit();

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectWriter.java
----------------------------------------------------------------------
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectWriter.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectWriter.java
index 6a14da2..9d9a5f5 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectWriter.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ObjectWriter.java
@@ -28,8 +28,11 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.yoko.util.cmsf.CmsfThreadLocal;
+import org.apache.yoko.util.yasf.Yasf;
+import org.apache.yoko.util.yasf.YasfThreadLocal;
 
 abstract class ObjectWriter extends ObjectOutputStream {
     protected final Serializable object;
@@ -40,7 +43,8 @@ abstract class ObjectWriter extends ObjectOutputStream {
 
     private WriteObjectState state = WriteObjectState.NOT_IN_WRITE_OBJECT;
 
-    private byte streamFormatVersion = 1;
+    final byte cmsf;
+    final Set<Yasf> yasfSet;
 
     private enum WriteObjectState {
         NOT_IN_WRITE_OBJECT {
@@ -58,7 +62,7 @@ abstract class ObjectWriter extends ObjectOutputStream {
                 // If we're in stream format version 2, we must
                 // put the "null" marker to say that there isn't
                 // any optional data
-                if (writer.getStreamFormatVersion() == 2) {
+                if (writer.cmsf == 2) {
                     writer._nullValue();
                 }
             }
@@ -74,7 +78,7 @@ abstract class ObjectWriter extends ObjectOutputStream {
                 // writeDefaultObject was not invoked
                 writer.writeBoolean(false);
 
-                if (writer.getStreamFormatVersion() == 2) {
+                if (writer.cmsf == 2) {
                     writer._startValue(writer._desc.getCustomRepositoryID());
                 }
             }
@@ -92,7 +96,7 @@ abstract class ObjectWriter extends ObjectOutputStream {
 
                 // write a null-marker to identify that there is no custom
                 // state being marshalled...
-                if (writer.getStreamFormatVersion() == 2) {
+                if (writer.cmsf == 2) {
                     writer._nullValue();
                 }
             }
@@ -102,14 +106,14 @@ abstract class ObjectWriter extends ObjectOutputStream {
                 // been emitted in IN_WRITE_OBJECT.beforeWriteDefaultObject
                 writer.state = WROTE_CUSTOM_DATA;
 
-                if (writer.getStreamFormatVersion() == 2) {
+                if (writer.cmsf == 2) {
                     writer._startValue(writer._desc.getCustomRepositoryID());
                 }
             }
         },
         WROTE_CUSTOM_DATA {
             void afterWriteObject(ObjectWriter writer) throws IOException {
-                if (writer.getStreamFormatVersion() == 2) {
+                if (writer.cmsf == 2) {
                     writer._endValue();
                 }
 
@@ -144,11 +148,8 @@ abstract class ObjectWriter extends ObjectOutputStream {
 
     ObjectWriter(Serializable obj) throws IOException {
         object = obj;
-        streamFormatVersion = CmsfThreadLocal.get();
-    }
-
-    private byte getStreamFormatVersion() {
-        return streamFormatVersion;
+        cmsf = CmsfThreadLocal.get();
+        yasfSet = YasfThreadLocal.get();
     }
 
     abstract ObjectReader getObjectReader(Object newObject);
@@ -282,7 +283,7 @@ abstract class ObjectWriter extends ObjectOutputStream {
         state = WriteObjectState.NOT_IN_WRITE_OBJECT;
         try {
             setCurrentValueDescriptor(descriptor);
-            writeByte(getStreamFormatVersion());
+            writeByte(cmsf);
             state.beforeWriteObject(this);
             _write_object_method.invoke(val, this);
             state.afterWriteObject(this);
@@ -299,7 +300,7 @@ abstract class ObjectWriter extends ObjectOutputStream {
     protected abstract void _nullValue() throws IOException;
 
     void invokeWriteExternal(Externalizable externalizable) throws IOException {
-        writeByte(getStreamFormatVersion());
+        writeByte(cmsf);
         externalizable.writeExternal(this);
     }
 }

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
----------------------------------------------------------------------
diff --git a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
index a686f77..65e6465 100755
--- a/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
+++ b/yoko-rmi-impl/src/main/java/org/apache/yoko/rmi/impl/ValueDescriptor.java
@@ -127,7 +127,7 @@ class ValueDescriptor extends TypeDescriptor {
         return _custom_repid;
     }
 
-    long getSerialVersionUID() {
+    protected long getSerialVersionUID() {
         if (_serial_version_uid_field != null) {
 
             try {

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-util/src/main/java/org/apache/yoko/util/yasf/Yasf.java
----------------------------------------------------------------------
diff --git a/yoko-util/src/main/java/org/apache/yoko/util/yasf/Yasf.java b/yoko-util/src/main/java/org/apache/yoko/util/yasf/Yasf.java
new file mode 100644
index 0000000..616e27e
--- /dev/null
+++ b/yoko-util/src/main/java/org/apache/yoko/util/yasf/Yasf.java
@@ -0,0 +1,43 @@
+package org.apache.yoko.util.yasf;
+
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+
+public enum Yasf {
+    ENUM_FIXED(0);
+
+    // TODO - Get ids from OMG assigned for these values
+    public static final int TAG_YOKO_AUXILLIARY_STREAM_FORMAT = 0xeeeeeeee;
+    public static final int YOKO_AUXIllIARY_STREAM_FORMAT_SC = 0xeeeeeeee;
+
+    public final int itemIndex;
+
+    private Yasf(int itemIndex) {
+        this.itemIndex = itemIndex;
+    }
+
+    public static Set<Yasf> supported() {
+        return Collections.unmodifiableSet(EnumSet.of(ENUM_FIXED));
+    }
+
+    public static Set<Yasf> toSet(byte[] data) {
+        if (data == null) return null;
+        final EnumSet<Yasf> set = EnumSet.noneOf(Yasf.class);
+        BitSet items = BitSet.valueOf(data);
+        for (Yasf yasf : values()) {
+            if (items.get(yasf.itemIndex)) set.add(yasf);
+        }
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static byte[] toData(Set<Yasf> yasfSet) {
+        if (null == yasfSet) return null;
+        final BitSet bits = new BitSet();
+        for (Yasf yasf : yasfSet) {
+            bits.set(yasf.itemIndex);
+        }
+        return bits.toByteArray();
+    }
+}

http://git-wip-us.apache.org/repos/asf/geronimo-yoko/blob/55b7d4f1/yoko-util/src/main/java/org/apache/yoko/util/yasf/YasfThreadLocal.java
----------------------------------------------------------------------
diff --git a/yoko-util/src/main/java/org/apache/yoko/util/yasf/YasfThreadLocal.java b/yoko-util/src/main/java/org/apache/yoko/util/yasf/YasfThreadLocal.java
new file mode 100644
index 0000000..6cb897b
--- /dev/null
+++ b/yoko-util/src/main/java/org/apache/yoko/util/yasf/YasfThreadLocal.java
@@ -0,0 +1,87 @@
+package org.apache.yoko.util.yasf;
+
+import java.util.BitSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public final class YasfThreadLocal {
+    private static final Logger LOGGER = Logger.getLogger(YasfThreadLocal.class.getName());
+    private static final ThreadLocal<YasfInfo> yasfInfo = new ThreadLocal<YasfInfo>()
{
+        @Override protected YasfInfo initialValue() {
+            return new YasfInfo();
+        }
+    };
+
+    private YasfThreadLocal() {}
+
+    private static final class YasfInfo {
+        public Frame head = Frame.DEFAULT;
+        public boolean override = false;
+    }
+
+    private static final class Frame {
+        static final Frame DEFAULT = new Frame();
+        public final Set<Yasf> value;
+        public final Frame prev;
+
+        private Frame() {
+            this.value = null;
+            this.prev = this;
+        }
+
+        Frame(Set<Yasf> value, Frame prev) {
+            this.value = value;
+            this.prev = prev;
+        }
+    }
+
+    public static final class YasfOverride implements AutoCloseable {
+        private final YasfInfo info;
+
+        YasfOverride(YasfInfo info) {
+            this.info = info;
+            info.override = true;
+        }
+
+        @Override
+        public void close() {
+            info.override = false;
+        }
+    }
+
+    public static YasfOverride override() {
+        return new YasfOverride(yasfInfo.get());
+    }
+
+    public static void push(Set<Yasf> items) {
+        final YasfInfo info = yasfInfo.get();
+        if (LOGGER.isLoggable(Level.FINER))
+            LOGGER.finer(String.format("YASF thread local version pushed onto stack: %s",
items));
+        info.head = new Frame(items, info.head);
+    }
+
+    public static Set<Yasf> get() {
+        final YasfInfo info = yasfInfo.get();
+        final boolean override = info.override;
+        final Set<Yasf> items = (override) ? null : info.head.value;
+        if (LOGGER.isLoggable(Level.FINER))
+            LOGGER.finer(String.format("YASF thread local version retrieved: %s, override
is %b", items, override));
+        return items;
+    }
+
+    public static Set<Yasf> pop() {
+        final YasfInfo info = yasfInfo.get();
+        final Set<Yasf> items = info.head.value;
+        if (LOGGER.isLoggable(Level.FINER))
+            LOGGER.finer(String.format("YASF thread local version popped from stack: %s",
items));
+        info.head = info.head.prev;
+        return items;
+    }
+
+    public static void reset() {
+        if (LOGGER.isLoggable(Level.FINER))
+            LOGGER.finer("YASF thread local stack reset");
+        yasfInfo.remove();
+    }
+}


Mime
View raw message