You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ad...@apache.org on 2005/12/02 08:59:10 UTC

svn commit: r351623 [2/4] - in /geronimo/trunk/sandbox/freeorb/geronimo-orb: ./ src/main/java/org/apache/geronimo/corba/ src/main/java/org/apache/geronimo/corba/channel/ src/main/java/org/apache/geronimo/corba/channel/nio/ src/main/java/org/apache/gero...

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/nio/ParticipationExecutor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/nio/ParticipationExecutor.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/nio/ParticipationExecutor.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/channel/nio/ParticipationExecutor.java Thu Dec  1 23:58:55 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.corba.channel.nio;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -26,100 +27,156 @@
 import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
 import EDU.oswego.cs.dl.util.concurrent.Semaphore;
 import EDU.oswego.cs.dl.util.concurrent.Sync;
+import EDU.oswego.cs.dl.util.concurrent.SyncList;
 import EDU.oswego.cs.dl.util.concurrent.SyncMap;
 
-
 public class ParticipationExecutor implements Executor {
 
-    private SyncMap map = new SyncMap(new HashMap(), new Mutex(),
-                                      new ReentrantLock());
-
-    private final Executor backing;
-
-    public ParticipationExecutor(Executor backing) {
-        this.backing = backing;
-    }
-
-    public void execute(Runnable arg0) throws InterruptedException {
-
-        Participation p = null;
-        if (!map.isEmpty()) {
-            Sync lock = map.writerSync();
-            lock.acquire();
-            try {
-                Set set = map.entrySet();
-                Iterator iter = set.iterator();
-                if (iter.hasNext()) {
-                    Map.Entry ent = (Map.Entry) iter.next();
-                    p = (Participation) ent.getValue();
-                    iter.remove();
-                }
-            }
-            finally {
-                lock.release();
-            }
-        }
-
-        if (p == null) {
-            backing.execute(arg0);
-        } else {
-            p.task = arg0;
-            p.release();
-        }
-
-    }
-
-    static class Participation extends Semaphore {
-
-        Thread participant = Thread.currentThread();
-
-        public Participation() {
-            super(0);
-        }
-
-        Runnable task;
-        public Object value;
-    }
-
-    public Object participate(Object key) {
-
-        Participation p = new Participation();
-        map.put(key, p);
-
-        while (true) {
-            try {
-                p.acquire();
-            }
-            catch (InterruptedException e) {
-                continue;
-            }
-
-            if (p.task == null) {
-                return p.value;
-            } else {
-                try {
-                    p.task.run();
-                }
-                catch (RuntimeException ex) {
-                    ex.printStackTrace();
-                }
-                catch (Error ex) {
-                    ex.printStackTrace();
-                }
-                finally {
-                    p.task = null;
-                    map.put(key, p);
-                }
-            }
-        }
-    }
-
-    public void release(Object key, Object value) {
-        Participation p = (Participation) map.remove(key);
-        if (p != null) {
-            p.value = value;
-            p.release();
-        }
-    }
-
+	static void assertTrue(boolean x) {
+		if (x == false) {
+			throw new Error("assertion failed");
+		}
+	}
+
+	private SyncMap map = new SyncMap(new HashMap(), new Mutex(),
+			new ReentrantLock());
+
+	private SyncList available = new SyncList(new ArrayList(), new Mutex(),
+			new Mutex());
+
+	private final Executor backing;
+
+	public ParticipationExecutor(Executor backing) {
+		this.backing = backing;
+	}
+
+	class Participation {
+
+		Semaphore sem = new Semaphore(0);
+
+		Thread participant = null;
+
+		private final Object key;
+
+		Participation(Object key) {
+			this.key = key;
+		}
+
+		private boolean isReleased;
+
+		private Runnable task;
+
+		private Object value;
+
+		public Object run() throws InterruptedException {
+			
+			
+			
+			try {
+				if (isReleased) {
+					return value;
+				}
+				
+				participant = Thread.currentThread();				
+				available.add(this);
+
+				while (true) {
+					sem.acquire();
+
+					assertTrue(!available.contains(this));
+
+					if (task != null) {
+						task.run();
+						task = null;
+						available.add(this);
+					}
+
+					if (isReleased) {
+						break;
+					}
+				}
+
+			} finally {
+				participant = null;
+				map.remove(key);
+			}
+
+			return value;
+		}
+
+		void executeTask(Runnable task) {
+
+			assertTrue(!available.contains(this));
+
+			this.task = task;
+			sem.release();
+		}
+
+		void releaseWithValue(Object value) {
+			this.value = value;
+			this.isReleased = true;
+
+			if (available.remove(this)) {
+				// ok.  the participant is not active, and so it
+				// will wake up immediately				
+			} else {
+				// possible race?  the participant is currently activ
+			}
+
+			sem.release();
+		}
+	}
+
+	public void execute(Runnable task) throws InterruptedException {
+
+		Participation p = null;
+		/*
+		available.writerSync().acquire();
+		try {
+			if (!available.isEmpty()) {
+				p = (Participation) available.remove(available.size() - 1);
+			}
+		} finally {
+			available.writerSync().release();
+		}
+*/
+		
+		if (p == null) {
+			backing.execute(task);
+		} else {
+			p.executeTask(task);
+		}
+
+	}
+
+	public Participation create(Object key) {
+		Participation result = new Participation(key);
+		map.put(key, result);
+		return result;
+	}
+
+	/**
+	 * @throws InterruptedException
+	 * @deprecated
+	 */
+	public Object participate(Object key) throws InterruptedException {
+
+		Participation p = (Participation) map.get(key);
+		if (p == null) {
+			p = create(key);
+		}
+
+		return p.run();
+	}
+
+	public void release(Object key, Object value) {
+		Participation p = (Participation) map.get(key);
+
+		if (p != null) {
+			p.releaseWithValue(value);
+		} else {
+			System.out.println("NO PARTICIPANT WAITING FOR " + key + " in "
+					+ this);
+		}
+	}
 }

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/CharConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/CharConverter.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/CharConverter.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/CharConverter.java Thu Dec  1 23:58:55 2005
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.geronimo.corba.codeset;
+
+import org.apache.geronimo.corba.io.InputStreamBase;
+import org.apache.geronimo.corba.io.OutputStreamBase;
+
+
+public interface CharConverter {
+
+    /**
+     * write a char with this converter
+     */
+    void write_char(OutputStreamBase out, char value);
+
+    /**
+     * write a string with this converter
+     */
+    void write_string(OutputStreamBase out, String value);
+
+    /**
+     * read a single char
+     */
+    char read_char(InputStreamBase base);
+
+    /**
+     * read a string.  Parameter first_long is the first 4bytes of the read representation.
+     */
+    String read_string(InputStreamBase stream, int first_long);
+
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultCharConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultCharConverter.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultCharConverter.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultCharConverter.java Thu Dec  1 23:58:55 2005
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.geronimo.corba.codeset;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.corba.io.GIOPVersion;
+import org.apache.geronimo.corba.io.InputStreamBase;
+import org.apache.geronimo.corba.io.OutputStreamBase;
+
+
+public class DefaultCharConverter
+    implements CharConverter
+{
+	static final Log log = LogFactory.getLog(DefaultCharConverter.class);
+	
+	
+	public boolean equals(Object other) {
+		if (other instanceof DefaultCharConverter) {
+			return ((DefaultCharConverter)other).giop_minor == giop_minor;
+		}
+		
+		return false;
+	}
+	
+	public int hashCode() {
+		return giop_minor;
+	}
+	
+    int giop_minor;
+    DefaultCharConverter (int major, int minor)
+    {
+        if (major != 1) 
+            throw new org.omg.CORBA.NO_IMPLEMENT ("GIOP "+major+"."+minor);
+
+        giop_minor = minor;
+    }
+
+    public void write_char (OutputStreamBase out, char c)
+    {
+        out.write_octet ((byte) c);
+    }
+
+    public void write_string (OutputStreamBase out, String value)
+    {
+        final char[] arr = value.toCharArray();
+        final int len = arr.length + 1;
+
+        out.write_ulong(len);
+        out.write_char_array (arr, 0, arr.length);
+
+        out.write_char ((char)0);
+    }
+
+
+    public char read_char (InputStreamBase in)
+    {
+        char value = (char)in.read_octet();
+        if (value == (char) 0)
+            throw new org.omg.CORBA.MARSHAL ("null character in string");
+        return value;
+    }
+
+    public String read_string (InputStreamBase in, int length)
+    {
+        int before = in.__stream_position()-4;
+        if (length == 0)
+            throw new org.omg.CORBA.MARSHAL ("zero-length string data");
+
+        if (length == -1) {
+            throw new org.omg.CORBA.MARSHAL ("negative string length");
+        }
+
+        char[] data = new char[length-1];
+        in.read_char_array (data, 0, data.length);
+
+        if (in.read_octet() != 0)
+            throw new org.omg.CORBA.MARSHAL ("missing null-terminator");
+
+        String value = new String (data, 0, data.length);
+
+        if (log.isDebugEnabled ()) {
+            log.debug ("read_string @ "+before+"-"+in.__stream_position()
+                       +" "+(in.__stream_position()-before)+"bytes"
+                       +" value="+value);
+        }
+
+        return value;
+    }
+
+	public static CharConverter getInstance(GIOPVersion version) {
+		return new DefaultCharConverter(version.major, version.minor);
+	}
+
+
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultWCharConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultWCharConverter.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultWCharConverter.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/codeset/DefaultWCharConverter.java Thu Dec  1 23:58:55 2005
@@ -0,0 +1,201 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.geronimo.corba.codeset;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.corba.io.GIOPVersion;
+import org.apache.geronimo.corba.io.InputStreamBase;
+import org.apache.geronimo.corba.io.OutputStreamBase;
+
+public class DefaultWCharConverter implements CharConverter {
+
+	static final Log log = LogFactory.getLog(DefaultWCharConverter.class);
+	
+	private GIOPVersion version;
+
+	DefaultWCharConverter(GIOPVersion version)
+	{
+		this.version = version;
+	}
+	
+	
+	public void write_char(OutputStreamBase out, char c) {
+        if (version.minor == 2) {
+
+            //
+            // \ufffd15.3.1.6: ... For GIOP 1.2, a wchar is encoded as an
+            // unsigned binary octet value, followed by the elements
+            // of the octet sequence representing the encoded value of
+            // the wchar.
+            //
+            out.write_octet ((byte) 2);
+            int pos = out.__stream_position() -1;
+            out.write_octet ((byte) (((int)c) >> 8));
+            out.write_octet ((byte) (((int)c) & 0xff));
+
+            if (log.isDebugEnabled ()) {
+                log.debug ("write_wchar[1.2]@"+pos
+                           +" ("+Integer.toHexString (0xffff & ((int)c))+")");
+            }
+
+        } else if (version.minor == 0 || version.minor == 1) {
+            out.write_ushort ((short)c);
+            int pos = out.__stream_position() -2;
+
+            if (log.isDebugEnabled ()) {
+                log.debug ("write_wchar[1.0]@"+pos
+                           +" ("+Integer.toHexString (0xffff & ((int)c))+")");
+            }
+        } else {
+            throw new org.omg.CORBA.MARSHAL ("GIOP 1."+version.minor);
+        }
+	}
+	
+    void write_wstring (OutputStreamBase out, String value)
+    {
+        if (version.minor == 0 || version.minor == 1)
+            {
+                final char[] arr = value.toCharArray();
+                final int len = arr.length + 1;
+                
+                out.write_ulong (len);
+                int start = out.__stream_position()-4;
+                out.write_wchar_array (arr, 0, arr.length);
+                out.write_wchar ((char)0);
+                
+                if (log.isDebugEnabled ()) {
+                    log.debug ("write_wstring[1.0] @ "+start+"-"+out.__stream_position()
+                               +" "+(out.__stream_position()-start)+"bytes"
+                               +" value="+value);
+                }
+            }
+        else if (version.minor == 2)
+            {
+                final int len = value.length ();
+                
+                out.write_ulong (len*2);
+                int start = out.__stream_position()-4;
+                for (int i = 0; i < len; i++) {
+                    out.write_short ((short)value.charAt (i));
+                }
+                
+                if (log.isDebugEnabled ()) {
+                    log.debug ("write_wstring[1.2] @ "+start+"-"+out.__stream_position()
+                               +" "+(out.__stream_position()-start)+"bytes"
+                               +" value="+value);
+                }
+            }
+        else
+            {
+                throw new org.omg.CORBA.MARSHAL ("GIOP 1."+version.minor);
+            }
+
+    }
+
+
+	public void write_string(OutputStreamBase out, String value) {
+		write_wstring(out, value);
+	}
+
+	public char read_char(InputStreamBase base) {
+		return read_wchar(base);
+	}
+
+	public String read_string(InputStreamBase stream, int first_long) {
+		return read_wstring(stream, first_long);
+	}
+	
+    String read_wstring (InputStreamBase in, int first_long) 
+    {
+        if (version.minor == 0 || version.minor == 1) {
+            int length = first_long;
+            int before = in.__stream_position()-4;
+            if (length == 0)
+                return "";
+            
+            char[] data = new char[length];
+            in.read_wchar_array (data, 0, length);
+            String value = new String (data, 0, length-1);
+            
+            if (log.isDebugEnabled ()) {
+                log.debug ("read_wstring[1.0] @ "+before+"-"+in.__stream_position()
+                           +" "+(in.__stream_position()-before)+"bytes"
+                           +" value="+value);
+            }
+            
+            return value;
+
+        } else if (version.minor == 2) {
+
+            int length = first_long/2;
+            int before = in.__stream_position()-4;
+            if (length == 0)
+                return "";
+            
+            char[] data = new char[length];
+            for (int i = 0; i < length; i++) {
+                data[i] = (char)in.read_ushort ();
+            }
+
+            String value = new String (data, 0, length);
+            
+            if (log.isDebugEnabled ()) {
+                log.debug ("read_wstring[1.2] @ "+before+"-"+in.__stream_position()
+                           +" "+(in.__stream_position()-before)+"bytes"
+                           +" value="+value);
+            }
+            
+            return value;
+
+        } else {
+            throw new org.omg.CORBA.MARSHAL ("GIOP 1."+version.minor);
+        }
+
+    }
+
+    char read_wchar (InputStreamBase in)
+    {
+        if (version.minor == 2) {
+            int len = in.read_octet ();
+            if (len != 2) {
+                throw new org.omg.CORBA.MARSHAL("wchar len != 2");
+            }
+            int high = (int) in.read_octet ();
+            int low  = (int) in.read_octet ();
+
+            if (in.__isLittleEndian ()) {
+                return (char) ((low << 8) | high);
+            } else {
+                return (char) ((high << 8) | low);
+            }
+
+        } else if (version.minor == 1 || version.minor == 0) {
+            char value = (char) in.read_ushort ();
+            return value;
+        } else {
+            throw new org.omg.CORBA.MARSHAL ("GIOP 1."+version.minor);
+        }
+    }
+
+
+	public static CharConverter getInstance(GIOPVersion version2) {
+		return new DefaultWCharConverter(version2);
+	}
+
+
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPHelper.java Thu Dec  1 23:58:55 2005
@@ -0,0 +1,232 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.geronimo.corba.giop;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.corba.ior.InternalExceptionDetailMessage;
+import org.apache.geronimo.corba.ior.InternalServiceContextList;
+import org.apache.geronimo.corba.util.StringUtil;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+public class GIOPHelper {
+
+	static Log log = LogFactory.getLog(GIOPHelper.class);
+
+	static SystemException unmarshalSystemException(
+			InternalServiceContextList scl, InputStream in) {
+
+		InternalExceptionDetailMessage msg = InternalExceptionDetailMessage
+				.get(scl);
+
+		String id = in.read_string();
+		int minor = in.read_ulong();
+		org.omg.CORBA.CompletionStatus status = org.omg.CORBA.CompletionStatusHelper
+				.read(in);
+
+		String className = idToClass(id);
+		try {
+			Class c = classForName(className);
+
+			Constructor cons = null;
+			try {
+				cons = c.getConstructor(new Class[] { String.class, int.class,
+						CompletionStatus.class });
+			} catch (NoSuchMethodException e) {
+			}
+			SystemException ex = null;
+
+			if (cons == null) {
+				ex = (SystemException) c.newInstance();
+			} else {
+				ex = (SystemException) cons.newInstance(new Object[] {
+						msg == null ? "" : msg.getMessage(),
+						new Integer(minor), status });
+			}
+
+			ex.minor = minor;
+			ex.completed = status;
+
+			return ex;
+		} catch (ClassNotFoundException ex) {
+			// ignore //
+		} catch (InstantiationException ex) {
+			// ignore //
+		} catch (IllegalAccessException ex) {
+			// ignore //
+		} catch (IllegalArgumentException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (InvocationTargetException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return new org.omg.CORBA.UNKNOWN(id, minor, status);
+	}
+
+	public static Class classForName(String name) throws ClassNotFoundException {
+		return Class.forName(name, true, getContextClassLoader());
+	}
+
+	static ClassLoader getContextClassLoader() {
+		if (System.getSecurityManager() == null) {
+			return Thread.currentThread().getContextClassLoader();
+		} else {
+			return (ClassLoader) AccessController
+					.doPrivileged(new PrivilegedAction() {
+						public Object run() {
+							return Thread.currentThread()
+									.getContextClassLoader();
+						}
+					});
+		}
+	}
+
+	public static String idToClass(String repid) {
+		// debug
+		if (log.isDebugEnabled())
+			log.debug("idToClass " + repid);
+
+		if (repid.startsWith("IDL:")) {
+
+			String id = repid;
+
+			try {
+				int end = id.lastIndexOf(':');
+				String s = end < 0 ? id.substring(4) : id.substring(4, end);
+
+				StringBuffer bb = new StringBuffer();
+
+				//
+				// reverse order of dot-separated name components up
+				// till the first slash.
+				//
+				int firstSlash = s.indexOf('/');
+				if (firstSlash > 0) {
+					String prefix = s.substring(0, firstSlash);
+					String[] elems = StringUtil.split(prefix, '.');
+
+					for (int i = elems.length - 1; i >= 0; i--) {
+						bb.append(fixName(elems[i]));
+						bb.append('.');
+					}
+
+					s = s.substring(firstSlash + 1);
+				}
+
+				//
+				// Append slash-separated name components ...
+				//
+				String[] elems = StringUtil.split(s, '/');
+				for (int i = 0; i < elems.length; i++) {
+					bb.append(fixName(elems[i]));
+					if (i != elems.length - 1)
+						bb.append('.');
+				}
+
+				String result = bb.toString();
+
+				if (log.isDebugEnabled()) {
+					log.debug("idToClassName " + repid + " => " + result);
+				}
+
+				return result;
+			} catch (IndexOutOfBoundsException ex) {
+				log.error("idToClass", ex);
+				return null;
+			}
+
+		} else if (repid.startsWith("RMI:")) {
+			int end = repid.indexOf(':', 4);
+			return end < 0 ? repid.substring(4) : repid.substring(4, end);
+		}
+
+		return null;
+	}
+
+	static String fixName(String name) {
+		if (keyWords.contains(name)) {
+			StringBuffer buf = new StringBuffer();
+			buf.append('_');
+			buf.append(name);
+			return buf.toString();
+		}
+
+		String result = name;
+		String current = name;
+
+		boolean match = true;
+		while (match) {
+
+			int len = current.length();
+			match = false;
+
+			for (int i = 0; i < reservedPostfixes.length; i++) {
+				if (current.endsWith(reservedPostfixes[i])) {
+					StringBuffer buf = new StringBuffer();
+					buf.append('_');
+					buf.append(result);
+					result = buf.toString();
+
+					int resultLen = reservedPostfixes[i].length();
+					if (len > resultLen)
+						current = current.substring(0, len - resultLen);
+					else
+						current = new String("");
+
+					match = true;
+					break;
+				}
+			}
+
+		}
+
+		return name;
+	}
+
+	static final java.util.Set keyWords = new java.util.HashSet();
+
+	static final String[] reservedPostfixes = new String[] { "Helper",
+			"Holder", "Operations", "POA", "POATie", "Package", "ValueFactory" };
+
+	static {
+		String[] words = { "abstract", "boolean", "break", "byte", "case",
+				"catch", "char", "class", "clone", "const", "continue",
+				"default", "do", "double", "else", "equals", "extends",
+				"false", "final", "finalize", "finally", "float", "for",
+				"getClass", "goto", "hashCode", "if", "implements", "import",
+				"instanceof", "int", "interface", "long", "native", "new",
+				"notify", "notifyAll", "null", "package", "private",
+				"protected", "public", "return", "short", "static", "super",
+				"switch", "synchronized", "this", "throw", "throws",
+				"toString", "transient", "true", "try", "void", "volatile",
+				"wait", "while" };
+
+		for (int i = 0; i < words.length; i++) {
+			keyWords.add(words[i]);
+		}
+	}
+
+}

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPInputStream.java Thu Dec  1 23:58:55 2005
@@ -20,9 +20,11 @@
 import java.nio.ByteOrder;
 
 import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.ORB;
 import org.apache.geronimo.corba.channel.InputChannel;
 import org.apache.geronimo.corba.io.GIOPVersion;
 import org.apache.geronimo.corba.io.InputStreamBase;
+import org.omg.CORBA.INTERNAL;
 
 
 public class GIOPInputStream extends InputStreamBase {
@@ -41,7 +43,9 @@
     private GIOPVersion version;
     private int message_start;
 
-    protected GIOPInputStream(InputController controller, InputChannel ch) {
+    protected GIOPInputStream(ORB orb, GIOPVersion version, InputController controller, InputChannel ch) {
+    		this.orb = orb;
+    		this.version = version;
         this.controller = controller;
         this.ch = ch;
     }
@@ -199,13 +203,34 @@
         return size_of_previous_fragments + position - message_start;
     }
 
-    protected AbstractORB __orb() {
+    public AbstractORB __orb() {
         return orb;
     }
 
-    protected GIOPVersion getGIOPVersion() {
+    public GIOPVersion getGIOPVersion() {
         return version;
     }
+
+	public boolean __isLittleEndian() {
+		return ch.getOrder() == ByteOrder.LITTLE_ENDIAN;
+	}
+
+	public void finishGIOPMessage() {
+		// skip input at end of message, if any
+		if (limit > position()) {
+			try {
+				ch.skip(limit - position());
+			} catch (IOException e) {
+				e.printStackTrace();
+				throw new INTERNAL();
+			}
+		}
+		ch.relinquish();
+	}
+
+	public void setGIOPVersion(GIOPVersion version2) {
+		this.version = version2;
+	}
 
 
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPMessageTransport.java Thu Dec  1 23:58:55 2005
@@ -17,321 +17,413 @@
 package org.apache.geronimo.corba.giop;
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.nio.ByteOrder;
 
 import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
 import org.omg.GIOP.MsgType_1_1;
+import org.omg.GIOP.ReplyStatusType_1_2;
+import org.omg.GIOP.ReplyStatusType_1_2Helper;
 
+import org.apache.geronimo.corba.ClientInvocation;
 import org.apache.geronimo.corba.ORB;
 import org.apache.geronimo.corba.channel.InputHandler;
+import org.apache.geronimo.corba.channel.OutputChannel;
 import org.apache.geronimo.corba.channel.Transport;
+import org.apache.geronimo.corba.channel.TransportManager;
 import org.apache.geronimo.corba.io.GIOPVersion;
 import org.apache.geronimo.corba.ior.InternalServiceContextList;
 import org.apache.geronimo.corba.ior.InternalTargetAddress;
 
-
 public class GIOPMessageTransport implements InputHandler {
 
-    static final byte SYNC_NONE = 0;
-    static final byte SYNC_WITH_TRANSPORT = 1;
-    static final byte SYNC_WITH_SERVER = 2;
-    static final byte SYNC_WITH_TARGET = 3;
-
-
-    public boolean isAssignedHere(RequestID id) {
-        return id.isAssignedHere(isClient);
-    }
-
-    static final int GIOP_MAGIC = ('G' << 24) | ('I' << 16) | ('O' << 8) | 'P';
-
-    static final int POIG_MAGIC = ('P' << 24) | ('O' << 16) | ('I' << 8) | 'G';
-
-    int next_request_id = 2;
-
-    RequestID giop_1_1_request_id = new RequestID(0);
-
-    public class MessageHeader implements InputController {
-
-        GIOPInputStream in;
-
-        private byte major;
-
-        private byte minor;
-
-        private byte flags;
-
-        private byte type;
-
-        private int size;
-
-        private boolean hasMoreFragments;
-
-        private RequestID requestID;
-
-        private int message_start;
-
-        public MessageHeader() {
-        }
-
-        public void process(Transport transport) {
-            in = new GIOPInputStream(this, transport.getInputChannel());
-
-            try {
-                in.position(0); // reset alignment
-                int magic = in.read_long();
-                switch (magic) {
-                    case GIOP_MAGIC:
-                    case POIG_MAGIC:
-                        // THAT's OK!
-                        break;
-
-                    default:
-                        sendErrorAndClose();
-                        return;
-                }
-
-                this.major = in.read_octet();
-                this.minor = in.read_octet();
-
-                this.flags = in.read_octet();
-                this.type = in.read_octet();
-
-                boolean littleEndian = ((flags & 1) == 1);
-                in.setOrder(littleEndian ? ByteOrder.LITTLE_ENDIAN
-                            : ByteOrder.BIG_ENDIAN);
-
-                this.size = in.read_long();
-                in.limit(size + 12);
-
-                this.hasMoreFragments = false;
-                if (minor > 0) {
-                    hasMoreFragments = ((flags & 2) == 2);
-                }
-
-                switch (type) {
-                    case MsgType_1_1._Fragment:
-
-                        if (minor == 2) {
-                            this.requestID = new RequestID(in.read_long());
-
-                            // this position counts as the start of this
-                            // message with respect to calculation of the
-                            // stream position
-                            this.message_start = in.position();
-                            transport.signalResponse(requestID, this);
-
-                        } else if (minor == 1) {
-
-                            this.message_start = in.position();
-
-                            // in GIOP 1.1 the there is no FragmentHeader, so
-                            // we need to "guess", that the incoming fragment
-                            // is the same as that read by a previosus message
-                            this.requestID = giop_1_1_request_id;
-
-                            // reset the guess
-                            if (!hasMoreFragments) {
-                                giop_1_1_request_id = new RequestID(0);
-                            }
-
-                            transport.signalResponse(this.requestID, this);
-
-                        } else {
-                            // todo: send message error
-                            throw new INTERNAL();
-                        }
-                        return;
-
-                    case MsgType_1_1._Reply:
-                        if (minor == 2) {
-                            this.requestID = new RequestID(in.read_long());
-                            transport.signalResponse(requestID, this);
-
-                        } else if (minor == 1) {
-                            // here we can have a problem, because the requestID may
-                            // not be there
-                            in.mark(in.available());
-                            try {
-                                int count = in.read_long();
-                                for (int i = 0; i < count; i++) {
-                                    int len = in.read_long();
-                                    in.skip(len);
-                                }
-                                this.requestID = new RequestID(in.read_long());
-                            }
-                            finally {
-                                in.reset();
-                            }
-
-                        } else if (minor == 0) {
-
-                        }
-                        return;
-
-                    case MsgType_1_1._Request:
-
-                        this.requestID = new RequestID(in.read_long());
-                        transport.signalResponse(requestID, this);
-                        return;
-
-                }
-
-            }
-            catch (IOException e) {
-                sendErrorAndClose();
-            }
-
-        }
-
-        private void sendErrorAndClose() {
-            // TODO Auto-generated method stub
-
-        }
-
-        public void getNextFragment(GIOPInputStream channel) {
-
-            if (!hasMoreFragments) {
-                // big problem //
-
-            }
-
-            MessageHeader handler = (MessageHeader) transport
-                    .waitForResponse(requestID);
-
-            channel.position(handler.message_start);
-            channel.setMessageStart(handler.message_start);
-            channel.limit(handler.size + 12);
-            channel.controller(handler);
-        }
-
-    }
-
-    private Transport transport;
-
-    private boolean isClient;
-
-    private final ORB orb;
-
-    GIOPMessageTransport(ORB orb, Transport transport, boolean isClient)
-            throws IOException
-    {
-        this.orb = orb;
-        this.transport = transport;
-        this.isClient = isClient;
-
-        if (isClient) {
-            next_request_id = 2;
-        } else {
-            next_request_id = 1;
-        }
-
-        transport.setInputHandler(this);
-    }
-
-    public void inputAvailable(Transport transport) {
-
-        // there is a new message available //
-        new MessageHeader().process(transport);
-
-    }
-
-    /**
-     * this will write
-     */
-    GIOPOutputStream startRequest(GIOPVersion version,
-                                  InternalTargetAddress targetAddress,
-                                  InternalServiceContextList contextList, byte response_flags,
-                                  String operation, byte[] principal) throws IOException
-    {
-
-        RequestID requestID = getNextRequestID();
-        GIOPOutputStream out = new GIOPOutputStream(orb, transport
-                .getOutputChannel(), version);
-
-        // this will write a GIOP message header
-        out.beginGIOPStream(MsgType_1_1._Request, requestID);
-
-        // add stuff like character encoding, and
-        // sending context rumtine service contexts...
-        add_outgoing_system_contexts(contextList);
-
-        // now write the request
-
-        switch (version.minor) {
-            case 0:
-            case 1:
-                // Write RequestHeader_1_1
-            {
-                contextList.write(out);
-                out.write_long(requestID.value());
-                switch (response_flags) {
-                    case SYNC_NONE:
-                    case SYNC_WITH_TRANSPORT:
-                        out.write_boolean(false);
-                        break;
-                    case SYNC_WITH_SERVER:
-                    case SYNC_WITH_TARGET:
-                        out.write_boolean(true);
-                        break;
-                }
-                out.skip(3);
-                targetAddress.writeObjectKey(out);
-                if (principal == null) {
-                    out.write_long(0);
-                } else {
-                    out.write_long(principal.length);
-                    out.write_octet_array(principal, 0, principal.length);
-                }
-            }
-
-            case 2:
-                // Write RequestHeader_1_2
-            {
-                out.write_long(requestID.value());
-                out.write_octet(response_flags);
-                out.skip(3); // can be dropped, target address aligns anyway
-                targetAddress.write(out);
-                out.write_string(operation);
-                contextList.write(out);
-                break;
-            }
-        }
-
-        return out;
-    }
-
-    // add stuff like character encoding, and
-    // sending context rumtine service contexts...
-    private void add_outgoing_system_contexts(InternalServiceContextList contextList) {
-        // TODO Auto-generated method stub
-
-    }
-
-    private RequestID getNextRequestID() {
-        int id;
-        synchronized (this) {
-            id = next_request_id;
-            next_request_id += 1;
-        }
-        RequestID result = new RequestID(id);
-        return result;
-    }
-
-    GIOPInputStream waitForResponse(RequestID requestID) {
-
-        MessageHeader header = (MessageHeader) transport
-                .waitForResponse(requestID);
+	static public final byte SYNC_NONE = 0;
 
-        GIOPInputStream result = new GIOPInputStream(header, transport
-                .getInputChannel());
+	static final byte SYNC_WITH_TRANSPORT = 1;
 
-        result.limit(header.size + 12);
-        result.position(header.message_start);
-        result.setMessageStart(header.message_start);
+	static public final byte SYNC_WITH_SERVER = 2;
 
-        // now read rest of response header //
+	static public final byte SYNC_WITH_TARGET = 3;
 
-        return result;
-    }
+	public boolean isAssignedHere(RequestID id) {
+		return id.isAssignedHere(isClient);
+	}
+
+	static final int GIOP_MAGIC = ('G' << 24) | ('I' << 16) | ('O' << 8) | 'P';
+
+	static final int POIG_MAGIC = ('P' << 24) | ('O' << 16) | ('I' << 8) | 'G';
+
+	int next_request_id = 2;
+
+	RequestID giop_1_1_request_id = new RequestID(0);
+
+	public class MessageHeader implements InputController {
+
+		GIOPInputStream in;
+
+		private byte major;
+
+		private byte minor;
+
+		private byte flags;
+
+		private byte type;
+
+		private int size;
+
+		private boolean hasMoreFragments;
+
+		private RequestID requestID;
+
+		private int message_start;
+
+		private int position;
+
+		public MessageHeader() {
+		}
+
+		public void process(Transport transport) {
+			in = new GIOPInputStream(orb, GIOPVersion.V1_0, this, transport.getInputChannel());
+
+			try {
+				in.position(0); // reset alignment
+				in.limit(12); //
+				int magic = in.read_long();
+				switch (magic) {
+				case GIOP_MAGIC:
+				case POIG_MAGIC:
+					// THAT's OK!
+					break;
+
+				default:
+					sendErrorAndClose();
+					return;
+				}
+
+				this.major = in.read_octet();
+				this.minor = in.read_octet();
+
+				in.setGIOPVersion(GIOPVersion.get(major, minor));
+				
+				this.flags = in.read_octet();
+				this.type = in.read_octet();
+
+				boolean littleEndian = ((flags & 1) == 1);
+				in.setOrder(littleEndian ? ByteOrder.LITTLE_ENDIAN
+						: ByteOrder.BIG_ENDIAN);
+
+				this.size = in.read_long();
+				in.limit(size + 12);
+
+				this.hasMoreFragments = false;
+				if (minor > 0) {
+					hasMoreFragments = ((flags & 2) == 2);
+				}
+
+				this.message_start = in.position();
+
+				switch (type) {
+				case MsgType_1_1._Fragment:
+
+					if (minor == 2) {
+						this.requestID = new RequestID(in.read_long());
+
+						// this position counts as the start of this
+						// message with respect to calculation of the
+						// stream position
+						this.message_start = in.position();
+						transport.signalResponse(requestID, this);
+
+					} else if (minor == 1) {
+
+						this.message_start = in.position();
+
+						// in GIOP 1.1 the there is no FragmentHeader, so
+						// we need to "guess", that the incoming fragment
+						// is the same as that read by a previosus message
+						this.requestID = giop_1_1_request_id;
+
+						// reset the guess
+						if (!hasMoreFragments) {
+							giop_1_1_request_id = new RequestID(0);
+						}
+
+						transport.signalResponse(this.requestID, this);
+
+					} else {
+						// todo: send message error
+						throw new INTERNAL();
+					}
+					return;
+
+				case MsgType_1_1._Reply:
+					if (minor == 2) {
+						this.requestID = new RequestID(in.read_long());
+						this.position = in.position();
+						transport.signalResponse(requestID, this);
+
+					} else if (minor == 1) {
+						// here we can have a problem, because the requestID may
+						// not be there
+						in.mark(in.available());
+						try {
+							int count = in.read_long();
+							for (int i = 0; i < count; i++) {
+								int len = in.read_long();
+								in.skip(len);
+							}
+							this.requestID = new RequestID(in.read_long());
+						} finally {
+							in.reset();
+						}
+						transport.signalResponse(requestID, this);
+
+					} else if (minor == 0) {
+
+					}
+					return;
+
+				case MsgType_1_1._Request:
+
+					this.requestID = new RequestID(in.read_long());
+					transport.signalResponse(requestID, this);
+					return;
+
+				}
+
+			} catch (IOException e) {
+				sendErrorAndClose();
+			}
+
+		}
+
+		private void sendErrorAndClose() {
+			// TODO Auto-generated method stub
+
+		}
+
+		public void getNextFragment(GIOPInputStream channel) {
+
+			if (!hasMoreFragments) {
+				// big problem //
+				// TODO: handle
+			}
+
+			MessageHeader handler = (MessageHeader) transport
+					.waitForResponse(requestID);
+
+			channel.position(handler.message_start);
+			channel.setMessageStart(handler.message_start);
+			channel.limit(handler.size + 12);
+			channel.controller(handler);
+		}
+
+		public GIOPVersion getGIOPVersion() {
+			return GIOPVersion.get(major, minor);
+		}
+
+	}
+
+	private Transport transport;
+
+	private boolean isClient;
+
+	private final ORB orb;
+
+	public GIOPMessageTransport(ORB orb, Transport transport, boolean isClient)
+			throws IOException {
+		this.orb = orb;
+		this.transport = transport;
+		this.isClient = isClient;
+
+		if (isClient) {
+			next_request_id = 2;
+		} else {
+			next_request_id = 1;
+		}
+
+		transport.setInputHandler(this);
+	}
+
+	public GIOPMessageTransport(ORB orb, TransportManager tm,
+			InetSocketAddress socketAddress, boolean isClient)
+			throws IOException {
+
+		this.orb = orb;
+		this.isClient = isClient;
+
+		if (isClient) {
+			next_request_id = 2;
+		} else {
+			next_request_id = 1;
+		}
+
+		transport = tm.createTransport(socketAddress, this);
+	}
+
+	public void inputAvailable(Transport transport) {
+
+		// there is a new message available //
+		new MessageHeader().process(transport);
+
+	}
+
+	/**
+	 * this will write
+	 */
+	public GIOPOutputStream startRequest(GIOPVersion version,
+			InternalTargetAddress targetAddress, ClientInvocation inv,
+			byte[] principal) throws IOException {
+		InternalServiceContextList contextList = inv
+				.getRequestServiceContextList();
+		byte response_flags = inv.getResponseFlags();
+		String operation = inv.getOperation();
+
+		RequestID requestID = getNextRequestID();
+
+		inv.setRequestID(requestID);
+
+		// acquire output channel token
+		OutputChannel outputChannel = transport.getOutputChannel();
+		GIOPOutputStream out = new GIOPOutputStream(orb, outputChannel, version);
+
+		// this will write a GIOP message header
+		out.beginGIOPStream(MsgType_1_1._Request, requestID);
+
+		// add stuff like character encoding, and
+		// sending context rumtine service contexts...
+		add_outgoing_system_contexts(contextList);
+
+		// now write the request
+
+		switch (version.minor) {
+		case 0:
+		case 1:
+		// Write RequestHeader_1_1
+		{
+			contextList.write(out);
+			out.write_long(requestID.value());
+			switch (response_flags) {
+			case SYNC_NONE:
+			case SYNC_WITH_TRANSPORT:
+				out.write_boolean(false);
+				break;
+			case SYNC_WITH_SERVER:
+			case SYNC_WITH_TARGET:
+				out.write_boolean(true);
+				break;
+			}
+			out.skip(3);
+			targetAddress.writeObjectKey(out);
+			if (principal == null) {
+				out.write_long(0);
+			} else {
+				out.write_long(principal.length);
+				out.write_octet_array(principal, 0, principal.length);
+			}
+		}
+
+		case 2:
+		// Write RequestHeader_1_2
+		{
+			out.write_long(requestID.value());
+			out.write_octet(response_flags);
+			out.skip(3); // can be dropped, target address aligns anyway
+			targetAddress.write(out);
+			out.write_string(operation);
+			contextList.write(out);
+			
+			out.setInsertHeaderPadding(true);
+			
+			break;
+		}
+		}
+
+		return out;
+	}
+
+	// add stuff like character encoding, and
+	// sending context rumtine service contexts...
+	private void add_outgoing_system_contexts(
+			InternalServiceContextList contextList) {
+		// TODO Auto-generated method stub
+
+	}
+
+	private RequestID getNextRequestID() {
+		int id;
+		synchronized (this) {
+			id = next_request_id;
+			next_request_id += 1;
+		}
+		RequestID result = new RequestID(id);
+		return result;
+	}
+
+	public GIOPInputStream waitForResponse(ClientInvocation inv) {
+
+		MessageHeader header = (MessageHeader) transport.waitForResponse(inv
+				.getRequestID());
+
+		GIOPInputStream in = new GIOPInputStream(orb, header.getGIOPVersion(), header, transport
+				.getInputChannel());
+
+		in.limit(header.size + 12);
+		in.position(header.position);
+		in.setMessageStart(header.message_start);
+
+		// now read rest of response header //
+
+		switch (header.minor) {
+		case 2:
+
+			// read reply (for GIOP 1.2 we have already read the request id)
+			int request_id = inv.getRequestID().id;
+
+			ReplyStatusType_1_2 reply_status = ReplyStatusType_1_2Helper
+					.read(in);
+			inv.setReplyStatus(reply_status);
+
+			InternalServiceContextList scl = new InternalServiceContextList();
+			scl.read(in);
+
+			inv.setResposeServiceContextList(scl);
+
+			break;
+		default:
+			throw new NO_IMPLEMENT();
+		}
+
+		ApplicationException aex;
+		SystemException sex;
+		switch (inv.getReplyStatus().value()) {
+		case ReplyStatusType_1_2._NO_EXCEPTION:
+			return in;
+			
+		case ReplyStatusType_1_2._USER_EXCEPTION:
+			String id = in.read_string();
+			aex = new org.omg.CORBA.portable.ApplicationException(id, new UserExceptionInputStream (in, id));
+			inv.setUserException(aex);
+			return null;
+			
+		case ReplyStatusType_1_2._SYSTEM_EXCEPTION:
+			sex = GIOPHelper.unmarshalSystemException(inv.getReplyServiceContextList(), in);
+			inv.setSystemException(sex);
+			return null;
+
+		default:
+			// todo: make sure we handle all cases here
+			throw new NO_IMPLEMENT();
+		}
+
+	}
+
+	public void registerResponse(RequestID requestID) {
+		// TODO: HANDLE RACE
+		transport.registerResponse((Object) requestID);
+	}
 
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPOutputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPOutputStream.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPOutputStream.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/GIOPOutputStream.java Thu Dec  1 23:58:55 2005
@@ -22,318 +22,315 @@
 import org.omg.GIOP.MsgType_1_1;
 
 import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.ClientInvocation;
 import org.apache.geronimo.corba.channel.MarkHandler;
 import org.apache.geronimo.corba.channel.OutputChannel;
 import org.apache.geronimo.corba.channel.OutputChannelMarker;
 import org.apache.geronimo.corba.io.GIOPVersion;
 import org.apache.geronimo.corba.io.OutputStreamBase;
 
-
 public class GIOPOutputStream extends OutputStreamBase {
 
-    final OutputChannel ch;
+	final OutputChannel ch;
 
-    private int pos_in_giop_message;
+	private int pos_in_giop_message;
 
-    private final GIOPVersion version;
+	private final GIOPVersion version;
 
-    private final AbstractORB orb;
+	private final AbstractORB orb;
 
-    boolean message_finished;
-
-    private OutputChannelMarker mark;
-
-    private RequestID requestID;
-
-    private int fragment_start;
-
-    private int bytes_in_previous_fragments;
-
-    protected GIOPOutputStream(AbstractORB orb, OutputChannel ch,
-                               GIOPVersion version)
-    {
-        this.orb = orb;
-        this.ch = ch;
-        this.version = version;
-    }
-
-    class FragmentHandler implements MarkHandler {
-
-        public void bufferFull(OutputChannelMarker state) throws IOException {
-            complete_message(state);
-            if (!message_finished) {
-                begin_fragment();
-            }
-        }
-
-        void begin_fragment() throws IOException {
-
-            // reset position and mark
-            pos_in_giop_message = 0;
-
-            // mark this as the beginning og a GIOP message
-            // so that we can rewrite the size info later
-            ch.mark(this);
-
-            if (version.minor == 2) {
-
-                // write new header
-                ch.writeInt(GIOPMessageTransport.GIOP_MAGIC);
-                ch.writeInt(0x01020000 | MsgType_1_1._Fragment);
-
-                // write empty size
-                ch.writeInt(0);
-
-                // write requestID (FragmentHeader)
-                ch.writeInt(requestID.value());
-
-                pos_in_giop_message = 16;
-                fragment_start = 16;
-
-            } else if (version.minor == 1) {
-
-                // write new header
-                ch.writeInt(GIOPMessageTransport.GIOP_MAGIC);
-                ch.writeInt(0x01010000 | MsgType_1_1._Fragment);
-
-                // write empty size
-                ch.writeInt(0);
-
-                // GIOP 1.1 fragments have no fragment header
-                // TODO: make sure we let noone else send fragments
-                // until this fragment is finished
-
-                pos_in_giop_message = 12;
-                fragment_start = 12;
-
-            } else {
-                //
-                // we cannot send fragments in GIOP 1.0
-
-                throw new org.omg.CORBA.INTERNAL();
-            }
-
-        }
-
-    }
-
-    //
-    public void beginGIOPStream(int message_type, RequestID requestID) {
-
-        this.requestID = requestID;
-        this.pos_in_giop_message = 0;
-        this.message_finished = false;
-        this.mark = ch.mark(new FragmentHandler());
-
-        byte flags = 0;
-
-        write_long(GIOPMessageTransport.GIOP_MAGIC);
-        write_octet((byte) version.major);
-        write_octet((byte) version.minor);
-        write_octet(flags);
-        write_octet((byte) message_type);
-
-        // message size
-        write_long(0);
-    }
-
-    public void finishGIOPStream() {
-        if (message_finished) {
-            throw new IllegalStateException();
-        }
-
-        message_finished = true;
-        try {
-            complete_message(mark);
-
-            // push message through transport layer
-            ch.flush();
-
-        }
-        catch (IOException e) {
-            throw translate_exception(e);
-        }
-
-        // relinquish the right to write to the underlying transport;
-        // this will let other threads write a message
-        ch.relinquish();
-    }
-
-    public void close() {
-        if (message_finished) {
-            return;
-        }
-        finishGIOPStream();
-    }
-
-    /**
-     * rewrite the message header to reflect message size and the hasMoreFragments bit
-     */
-    private void complete_message(OutputChannelMarker state) throws IOException {
-
-        boolean lastFragment = message_finished;
-
-        // write "has_more_fragments"
-        if (!lastFragment) {
-            state.putByte(6, (byte) 2);
-        } else {
-            state.putByte(6, (byte) 0);
-        }
-
-        // write size
-        int padding = 0;
-        int minor = version.minor;
-
-        switch (minor) {
-            case 0:
-                // big trouple! What do we do?
-                // the buffer has run full, but in GIOP 1.0
-                // messages cannot be fragmented. We're out
-                // of luck here, really.
-
-                // convert pending message into a close request, and
-                // thrown an error condition. In a future version,
-                // we might consider adding a dynamic buffer in this
-                // case to swallow the rest of the input stream...
-                state.putByte(7, (byte) MsgType_1_1._CloseConnection);
-                state.putInt(8, 0); // size zero
-                ch.close();
-                state.release();
-
-                throw new NO_RESOURCES();
-
-            case 1:
-                // GIOP 1.1 fragments are not padded in the end.
-                padding = 0;
-                break;
-
-            case 2:
-                // GIOP 1.2
-                if (!lastFragment) {
-                    padding = computeAlignment(pos_in_giop_message, 8);
-                }
-        }
-
-        // actually write the size into the GIOP header
-        state.putInt(8, pos_in_giop_message + padding - 12);
-
-        // let the underlying buffer flush contents (makes space for more
-        // fragments)
-        state.release();
-
-        // now that the output stream has been released, we can
-        // write the padding needed for framented messages in GIOP 1.2
-        if (padding != 0) {
-            ch.skip(padding);
-            pos_in_giop_message += padding;
-        }
-
-        bytes_in_previous_fragments += (pos_in_giop_message - fragment_start);
-        pos_in_giop_message = 0;
-        fragment_start = 0;
-    }
-
-    public int computeAlignment(int pos, int align) {
-        if (align > 1) {
-            int incr = pos & (align - 1);
-            if (incr != 0) {
-                return align - incr;
-            }
-        }
-        return 0;
-    }
-
-    public void align(int align) {
-
-        try {
-            int skip = computeAlignment(pos_in_giop_message, align);
-            if (skip != 0) {
-                skip(skip);
-            }
-        }
-        catch (IOException e) {
-            throw translate_exception(e);
-        }
-
-    }
-
-    public void write(byte[] data, int off, int len) throws IOException {
-        ch.write(data, off, len);
-        pos_in_giop_message += len;
-    }
-
-    public void skip(int count) throws IOException {
-        ch.skip(count);
-        pos_in_giop_message += count;
-    }
-
-    public OutputChannelMarker mark(MarkHandler handler) {
-        return ch.mark(handler);
-    }
-
-    public void flush() throws IOException {
-        ch.flush();
-    }
-
-    public GIOPVersion getGIOPVersion() {
-        return version;
-    }
-
-    public AbstractORB __orb() {
-        return orb;
-    }
-
-    public void write(int value) throws IOException {
-        ch.write(value);
-        pos_in_giop_message += 1;
-    }
-
-    public void write_octet(byte value) {
-        try {
-            ch.write(value);
-        }
-        catch (IOException e) {
-            throw translate_exception(e);
-        }
-        pos_in_giop_message += 1;
-    }
-
-    public void write_short(short value) {
-        align(2);
-        try {
-            ch.writeShort(value);
-        }
-        catch (IOException e) {
-            throw translate_exception(e);
-        }
-        pos_in_giop_message += 2;
-    }
-
-    public void write_long(int value) {
-        align(4);
-        try {
-            ch.writeInt(value);
-        }
-        catch (IOException e) {
-            throw translate_exception(e);
-        }
-        pos_in_giop_message += 4;
-    }
-
-    public void write_longlong(long value) {
-        align(8);
-        try {
-            ch.writeLong(value);
-        }
-        catch (IOException e) {
-            throw translate_exception(e);
-        }
-        pos_in_giop_message += 8;
-    }
-
-    public int __stream_position() {
-        return bytes_in_previous_fragments + (pos_in_giop_message
-                                              - fragment_start);
-    }
+	boolean message_finished;
+
+	private OutputChannelMarker mark;
+
+	private RequestID requestID;
+
+	private int fragment_start;
+
+	private int bytes_in_previous_fragments;
+
+	private boolean insertHeaderPadding;
+
+	protected GIOPOutputStream(AbstractORB orb, OutputChannel ch,
+			GIOPVersion version) {
+		this.orb = orb;
+		this.ch = ch;
+		this.version = version;
+	}
+
+	class FragmentHandler implements MarkHandler {
+
+		public void bufferFull(OutputChannelMarker state) throws IOException {
+			complete_message(state);
+			if (!message_finished) {
+				begin_fragment();
+			}
+		}
+
+		void begin_fragment() throws IOException {
+
+			// reset position and mark
+			pos_in_giop_message = 0;
+
+			// mark this as the beginning og a GIOP message
+			// so that we can rewrite the size info later
+			ch.mark(this);
+
+			if (version.minor == 2) {
+
+				// write new header
+				ch.writeInt(GIOPMessageTransport.GIOP_MAGIC);
+				ch.writeInt(0x01020000 | MsgType_1_1._Fragment);
+
+				// write empty size
+				ch.writeInt(0);
+
+				// write requestID (FragmentHeader)
+				ch.writeInt(requestID.value());
+
+				pos_in_giop_message = 16;
+				fragment_start = 16;
+
+			} else if (version.minor == 1) {
+
+				// write new header
+				ch.writeInt(GIOPMessageTransport.GIOP_MAGIC);
+				ch.writeInt(0x01010000 | MsgType_1_1._Fragment);
+
+				// write empty size
+				ch.writeInt(0);
+
+				// GIOP 1.1 fragments have no fragment header
+				// TODO: make sure we let noone else send fragments
+				// until this fragment is finished
+
+				pos_in_giop_message = 12;
+				fragment_start = 12;
+
+			} else {
+				//
+				// we cannot send fragments in GIOP 1.0
+
+				throw new org.omg.CORBA.INTERNAL();
+			}
+
+		}
+
+	}
+
+	//
+	public void beginGIOPStream(int message_type, RequestID requestID) {
+
+		this.requestID = requestID;
+		this.pos_in_giop_message = 0;
+		this.message_finished = false;
+		this.mark = ch.mark(new FragmentHandler());
+
+		byte flags = 0;
+
+		write_long(GIOPMessageTransport.GIOP_MAGIC);
+		write_octet((byte) version.major);
+		write_octet((byte) version.minor);
+		write_octet(flags);
+		write_octet((byte) message_type);
+
+		// message size
+		write_long(0);
+	}
+
+	public void finishGIOPMessage() {
+		if (message_finished) {
+			throw new IllegalStateException();
+		}
+
+		message_finished = true;
+		try {
+			complete_message(mark);
+
+			// push message through transport layer
+			ch.flush();
+
+		} catch (IOException e) {
+			throw translate_exception(e);
+		}
+
+		// relinquish the right to write to the underlying transport;
+		// this will let other threads write a message
+		ch.relinquish();
+	}
+
+	public void close() {
+		if (message_finished) {
+			return;
+		}
+		finishGIOPMessage();
+	}
+
+	/**
+	 * rewrite the message header to reflect message size and the
+	 * hasMoreFragments bit
+	 */
+	private void complete_message(OutputChannelMarker state) throws IOException {
+
+		boolean lastFragment = message_finished;
+
+		// write "has_more_fragments"
+		if (!lastFragment) {
+			state.putByte(6, (byte) 2);
+		} else {
+			state.putByte(6, (byte) 0);
+		}
+
+		// write size
+		int padding = 0;
+		int minor = version.minor;
+
+		switch (minor) {
+		case 0:
+			// big trouple! What do we do?
+			// the buffer has run full, but in GIOP 1.0
+			// messages cannot be fragmented. We're out
+			// of luck here, really.
+
+			// convert pending message into a close request, and
+			// thrown an error condition. In a future version,
+			// we might consider adding a dynamic buffer in this
+			// case to swallow the rest of the input stream...
+			state.putByte(7, (byte) MsgType_1_1._CloseConnection);
+			state.putInt(8, 0); // size zero
+			ch.close();
+			state.release();
+
+			throw new NO_RESOURCES();
+
+		case 1:
+			// GIOP 1.1 fragments are not padded in the end.
+			padding = 0;
+			break;
+
+		case 2:
+			// GIOP 1.2
+			if (!lastFragment) {
+				padding = computeAlignment(pos_in_giop_message, 8);
+			}
+		}
+
+		// actually write the size into the GIOP header
+		state.putInt(8, pos_in_giop_message + padding - 12);
+
+		// let the underlying buffer flush contents (makes space for more
+		// fragments)
+		state.release();
+
+		// now that the output stream has been released, we can
+		// write the padding needed for framented messages in GIOP 1.2
+		if (padding != 0) {
+			ch.skip(padding);
+			pos_in_giop_message += padding;
+		}
+
+		bytes_in_previous_fragments += (pos_in_giop_message - fragment_start);
+		pos_in_giop_message = 0;
+		fragment_start = 0;
+	}
+
+	public void align(int align) {
+
+		if (insertHeaderPadding) {
+			insertHeaderPadding = false;
+			align = 8;
+		}
+		
+		try {
+			int skip = computeAlignment(pos_in_giop_message, align);
+			if (skip != 0) {
+				skip(skip);
+			}
+		} catch (IOException e) {
+			throw translate_exception(e);
+		}
+
+	}
+
+	public void write(byte[] data, int off, int len) throws IOException {
+		ch.write(data, off, len);
+		pos_in_giop_message += len;
+	}
+
+	public void skip(int count) throws IOException {
+		align(1);
+		ch.skip(count);
+		pos_in_giop_message += count;
+	}
+
+	public OutputChannelMarker mark(MarkHandler handler) {
+		return ch.mark(handler);
+	}
+
+	public void flush() throws IOException {
+		ch.flush();
+	}
+
+	public GIOPVersion getGIOPVersion() {
+		return version;
+	}
+
+	public AbstractORB __orb() {
+		return orb;
+	}
+
+	public void write(int value) throws IOException {
+		ch.write(value);
+		pos_in_giop_message += 1;
+	}
+
+	public void write_octet(byte value) {
+		align(1);
+		try {
+			ch.write(value);
+		} catch (IOException e) {
+			throw translate_exception(e);
+		}
+		pos_in_giop_message += 1;
+	}
+
+	public void write_short(short value) {
+		align(2);
+		try {
+			ch.writeShort(value);
+		} catch (IOException e) {
+			throw translate_exception(e);
+		}
+		pos_in_giop_message += 2;
+	}
+
+	public void write_long(int value) {
+		align(4);
+		try {
+			ch.writeInt(value);
+		} catch (IOException e) {
+			throw translate_exception(e);
+		}
+		pos_in_giop_message += 4;
+	}
+
+	public void write_longlong(long value) {
+		align(8);
+		try {
+			ch.writeLong(value);
+		} catch (IOException e) {
+			throw translate_exception(e);
+		}
+		pos_in_giop_message += 8;
+	}
+
+	public int __stream_position() {
+		return bytes_in_previous_fragments
+				+ (pos_in_giop_message - fragment_start);
+	}
+
+	public void setInsertHeaderPadding(boolean b) {
+		this.insertHeaderPadding = true;
+	}
 
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/RequestID.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/RequestID.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/RequestID.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/RequestID.java Thu Dec  1 23:58:55 2005
@@ -19,7 +19,7 @@
  */
 package org.apache.geronimo.corba.giop;
 
-class RequestID {
+public class RequestID {
 
     final int id;
 
@@ -27,6 +27,11 @@
         this.id = id;
     }
 
+    public String toString() {
+    		return "RequestID[" + id + "]";
+    }
+    
+    
     public boolean equals(Object other) {
         if (other == this) {
             return true;
@@ -50,4 +55,4 @@
         boolean is_even = ((id & 1) == 0);
         return hereIsClient & is_even;
     }
-}
\ No newline at end of file
+}

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/UserExceptionInputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/UserExceptionInputStream.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/UserExceptionInputStream.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/giop/UserExceptionInputStream.java Thu Dec  1 23:58:55 2005
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.geronimo.corba.giop;
+
+import org.apache.geronimo.corba.io.FilterInputStream;
+import org.apache.geronimo.corba.io.InputStreamBase;
+
+
+/** This is an inputstream specifically for reading the result of a user exception
+ * 
+ * The function is to return a predefined rep-id as the first result of a call
+ * to read_string.
+ *  */
+public class UserExceptionInputStream extends FilterInputStream {
+
+	private final String id;
+	private boolean did_read_string = false;
+	
+	/** the input stream */
+	UserExceptionInputStream(InputStreamBase base, String id) {
+		super(base);
+		this.id = id;
+	}
+	
+	public String read_string()
+	{
+		if (did_read_string) {
+			super.read_string();
+		}
+		
+		did_read_string = true;
+		return id;
+	}
+}

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/CharConverter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/CharConverter.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/CharConverter.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/CharConverter.java Thu Dec  1 23:58:55 2005
@@ -1,43 +0,0 @@
-/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  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.geronimo.corba.io;
-
-
-public interface CharConverter {
-
-    /**
-     * write a char with this converter
-     */
-    void write_char(OutputStreamBase out, char value);
-
-    /**
-     * write a string with this converter
-     */
-    void write_string(OutputStreamBase out, String value);
-
-    /**
-     * read a single char
-     */
-    char read_char(InputStreamBase base);
-
-    /**
-     * read a string.  Parameter first_long is the first 4bytes of the read representation.
-     */
-    String read_string(InputStreamBase stream, int first_long);
-
-
-}

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnection.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnection.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnection.java Thu Dec  1 23:58:55 2005
@@ -16,6 +16,12 @@
  */
 package org.apache.geronimo.corba.io;
 
+import java.io.IOException;
+
+import org.apache.geronimo.corba.giop.GIOPMessageTransport;
+
 public interface ClientConnection {
 
+	GIOPMessageTransport getGIOPMessageTransport() throws IOException;
+	
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnectionFactory.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnectionFactory.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/ClientConnectionFactory.java Thu Dec  1 23:58:55 2005
@@ -16,13 +16,17 @@
  */
 package org.apache.geronimo.corba.io;
 
+import org.apache.geronimo.corba.ORB;
 import org.apache.geronimo.corba.ior.IIOPTransportSpec;
 
-
+/** this is the "sharing point" for reuse of client connections */
 public interface ClientConnectionFactory {
 
     ClientConnection getConnection();
 
     IIOPTransportSpec getTransportSpec();
+
+    ORB getORB();
+
 
 }

Added: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultClientConnection.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultClientConnection.java?rev=351623&view=auto
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultClientConnection.java (added)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultClientConnection.java Thu Dec  1 23:58:55 2005
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.geronimo.corba.io;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import org.apache.geronimo.corba.channel.Transport;
+import org.apache.geronimo.corba.channel.TransportManager;
+import org.apache.geronimo.corba.giop.GIOPMessageTransport;
+import org.apache.geronimo.corba.ior.IIOPTransportSpec;
+
+public class DefaultClientConnection implements ClientConnection {
+
+	private ClientConnectionFactory owner;
+
+	private TransportManager tm;
+
+	private GIOPMessageTransport mt;
+
+	public DefaultClientConnection(ClientConnectionFactory factory,
+			TransportManager tm) {
+		this.owner = factory;
+		this.tm = tm;
+	}
+
+	public GIOPMessageTransport getGIOPMessageTransport() throws IOException {
+
+		if (mt == null) {
+
+			 InetSocketAddress socketAddress = owner
+					.getTransportSpec().getSocketAddress();
+			mt = new GIOPMessageTransport(owner.getORB(), tm, socketAddress,
+					true);
+
+		}
+
+		return mt;
+	}
+
+}

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultConnectionManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultConnectionManager.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultConnectionManager.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/DefaultConnectionManager.java Thu Dec  1 23:58:55 2005
@@ -16,6 +16,7 @@
  */
 package org.apache.geronimo.corba.io;
 
+import java.io.IOException;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -32,6 +33,8 @@
 import org.apache.geronimo.corba.ConnectionManager;
 import org.apache.geronimo.corba.InvocationProfile;
 import org.apache.geronimo.corba.ORB;
+import org.apache.geronimo.corba.channel.TransportManager;
+import org.apache.geronimo.corba.channel.nio.AsyncNIOTransportManager;
 import org.apache.geronimo.corba.ior.AlternateIIOPComponent;
 import org.apache.geronimo.corba.ior.CompoundSecurityMechanism;
 import org.apache.geronimo.corba.ior.IIOPProfile;
@@ -47,8 +50,22 @@
     SyncMap connectionFactories = new SyncMap(new HashMap(),
                                               new WriterPreferenceReadWriteLock());
 
-    public DefaultConnectionManager(ORB orb) {
+    TransportManager tcpTransportManager;
+    TransportManager sslTransportManager;
+    TransportManager tlsTransportManager;
+    
+    
+    public DefaultConnectionManager(ORB orb) throws IOException {
         this.orb = orb;
+        
+        tcpTransportManager = new AsyncNIOTransportManager(orb.getExecutor());
+        try {
+			tcpTransportManager.start();
+		} catch (InterruptedException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+        
     }
 
     public InvocationProfile[] getInvocationProfiles(InternalIOR ior) {
@@ -152,19 +169,19 @@
     }
 
     private ClientConnectionFactory getClientEndpoint(
-            IIOPTransportSpec transport)
+            IIOPTransportSpec transportSpec)
     {
         ClientConnectionFactory ccf = (ClientConnectionFactory) connectionFactories
-                .get(transport);
+                .get(transportSpec);
 
         if (ccf == null) {
-            String protocol = transport.protocol();
+            String protocol = transportSpec.protocol();
             if (IIOPTransportSpec.PROTO_TCP.equals(protocol)) {
-                ccf = new TCPClientConnectionFactory(transport);
+                ccf = new TCPClientConnectionFactory(orb, transportSpec, tcpTransportManager);
             } else if (IIOPTransportSpec.PROTO_SSL.equals(protocol)) {
-                ccf = new SSLClientConnectionFactory(transport);
+                ccf = new SSLClientConnectionFactory(orb, transportSpec, sslTransportManager);
             } else if (IIOPTransportSpec.PROTO_TLS.equals(protocol)) {
-                ccf = new TLSClientConnectionFactory(transport);
+                ccf = new TLSClientConnectionFactory(orb, transportSpec, tlsTransportManager);
             }
         }
 

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationInputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationInputStream.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationInputStream.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationInputStream.java Thu Dec  1 23:58:55 2005
@@ -19,6 +19,7 @@
 import org.omg.CORBA.MARSHAL;
 
 import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.codeset.CharConverter;
 
 
 public class EncapsulationInputStream extends InputStreamBase {
@@ -70,7 +71,7 @@
     }
 
     protected void __check(int size, int align) {
-        int padding = pos & (align - 1);
+        int padding = computeAlignment(pos, align);
         if (pos + padding + size > len) {
             throw new MARSHAL();
         }
@@ -81,7 +82,7 @@
         return pos - len;
     }
 
-    protected GIOPVersion getGIOPVersion() {
+    public GIOPVersion getGIOPVersion() {
         return version;
     }
 
@@ -150,5 +151,7 @@
         return new EncapsulationInputStream(__orb(), data, pos, encap_len);
     }
 
-
+    public boolean __isLittleEndian() {
+    	return little_endian;
+    }
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/EncapsulationOutputStream.java Thu Dec  1 23:58:55 2005
@@ -22,6 +22,9 @@
 import java.io.OutputStream;
 
 import org.apache.geronimo.corba.AbstractORB;
+import org.apache.geronimo.corba.channel.MarkHandler;
+import org.apache.geronimo.corba.channel.OutputChannelMarker;
+import org.omg.CORBA.NO_IMPLEMENT;
 
 
 public class EncapsulationOutputStream extends OutputStreamBase {
@@ -130,5 +133,13 @@
     public void writeTo(OutputStream out) throws IOException {
         barr.writeTo(out);
     }
+
+	protected OutputChannelMarker mark(MarkHandler handler) {
+		throw new NO_IMPLEMENT();
+	}
+
+	protected GIOPVersion getGIOPVersion() {
+		return GIOPVersion.V1_0;
+	}
 
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/FilterInputStream.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/FilterInputStream.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/FilterInputStream.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/FilterInputStream.java Thu Dec  1 23:58:55 2005
@@ -25,11 +25,11 @@
 
     private final InputStreamBase base;
 
-    FilterInputStream(InputStreamBase base) {
+    protected FilterInputStream(InputStreamBase base) {
         this.base = base;
     }
 
-    protected AbstractORB __orb() {
+    public AbstractORB __orb() {
         return base.__orb();
     }
 
@@ -41,7 +41,7 @@
         return base.__stream_position();
     }
 
-    protected GIOPVersion getGIOPVersion() {
+    public GIOPVersion getGIOPVersion() {
         return base.getGIOPVersion();
     }
 
@@ -60,6 +60,10 @@
     public long read_longlong() {
         return base.read_longlong();
     }
+
+	public boolean __isLittleEndian() {
+		return base.__isLittleEndian();
+	}
 
 
 }

Modified: geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/GIOPVersion.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/GIOPVersion.java?rev=351623&r1=351622&r2=351623&view=diff
==============================================================================
--- geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/GIOPVersion.java (original)
+++ geronimo/trunk/sandbox/freeorb/geronimo-orb/src/main/java/org/apache/geronimo/corba/io/GIOPVersion.java Thu Dec  1 23:58:55 2005
@@ -50,7 +50,7 @@
         return get(version.major, version.minor);
     }
 
-    private static GIOPVersion get(int major2, int minor2) {
+    public static GIOPVersion get(int major2, int minor2) {
         if (major2 == 1) {
             if (minor2 == 0) return V1_0;
             if (minor2 == 1) return V1_1;