Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CdrOutputStream.java Wed Mar 23 09:56:34 2005 @@ -17,49 +17,52 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import org.omg.CORBA.TCKind; - -import org.apache.geronimo.interop.GIOP.*; +import org.apache.geronimo.interop.rmi.*; +import org.apache.geronimo.interop.util.*; import org.apache.geronimo.interop.IOP.*; -import org.apache.geronimo.interop.rmi.RmiTrace; -import org.apache.geronimo.interop.util.ArrayUtil; -import org.apache.geronimo.interop.util.BigEndian; -import org.apache.geronimo.interop.util.ExceptionUtil; -import org.apache.geronimo.interop.util.JavaClass; -import org.apache.geronimo.interop.util.UTF8; - +import org.apache.geronimo.interop.GIOP.*; +import org.omg.CORBA.TCKind; /** - * * CORBA 2.3 / GIOP 1.2 CDR OutputStream. - */ -public class CdrOutputStream extends org.omg.CORBA_2_3.portable.OutputStream { - public static CdrOutputStream getInstance() { - CdrOutputStream output = new CdrOutputStream(); + ** CORBA 2.3 / GIOP 1.2 CDR OutputStream. + **/ +public class CdrOutputStream extends org.omg.CORBA_2_3.portable.OutputStream +{ + //public static final Component component = new Component(CdrOutputStream.class); + + public static CdrOutputStream getInstance() + { + CdrOutputStream output = new CdrOutputStream(); //(CdrOutputStream)component.getInstance(); output.init(new byte[DEFAULT_BUFFER_LENGTH], 0); return output; } - public static CdrOutputStream getInstance(byte[] buffer) { - CdrOutputStream output = new CdrOutputStream(); + public static CdrOutputStream getInstance(byte[] buffer) + { + CdrOutputStream output = new CdrOutputStream(); //(CdrOutputStream)component.getInstance(); output.init(buffer, 0); return output; } - public static CdrOutputStream getInstance(byte[] buffer, int offset) { - CdrOutputStream output = new CdrOutputStream(); + public static CdrOutputStream getInstance(byte[] buffer, int offset) + { + CdrOutputStream output = new CdrOutputStream(); //(CdrOutputStream)component.getInstance(); output.init(buffer, offset); return output; } - public static CdrOutputStream getInstanceForEncapsulation() { + public static CdrOutputStream getInstanceForEncapsulation() + { CdrOutputStream output = getInstance(); output.write_boolean(false); // byte order: big endian return output; } - public static CdrOutputStream getPooledInstance() { - CdrOutputStream output = null; //(CdrOutputStream)_pool.get(); - if (output == null) { + public static CdrOutputStream getPooledInstance() + { + CdrOutputStream output = null; // (CdrOutputStream)_pool.get(); + if (output == null) + { output = getInstance(); } return output; @@ -77,13 +80,13 @@ private static IOR NULL_IOR = new IOR("", new TaggedProfile[0]); - private static char[] GIOP_MAGIC = {'G', 'I', 'O', 'P'}; + private static char[] GIOP_MAGIC = { 'G', 'I', 'O', 'P' }; private static ServiceContext[] EMPTY_SERVICE_CONTEXT_LIST = {}; - private static Version GIOP_VERSION_1_0 = new Version((byte) 1, (byte) 0); - private static Version GIOP_VERSION_1_1 = new Version((byte) 1, (byte) 1); - private static Version GIOP_VERSION_1_2 = new Version((byte) 1, (byte) 2); + private static Version GIOP_VERSION_1_0 = new Version((byte)1, (byte)0); + private static Version GIOP_VERSION_1_1 = new Version((byte)1, (byte)1); + private static Version GIOP_VERSION_1_2 = new Version((byte)1, (byte)2); //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(CdrOutputStream.class.getName()); @@ -107,84 +110,101 @@ // public methods // ----------------------------------------------------------------------- - public void init(byte[] buffer, int offset) { + public void init(byte[] buffer, int offset) + { _buffer = buffer; _offset = offset; _length = _buffer.length; } - public void recycle() { + public void recycle() + { reset(); //_pool.put(this); } - public void reset() { + public void reset() + { _offset = 0; - if (_buffer.length > MAXIMUM_POOLED_BUFFER_LENGTH) { + if (_buffer.length > MAXIMUM_POOLED_BUFFER_LENGTH) + { _buffer = _pooledBuffer; _pooledBuffer = null; - if (_buffer == null) { + if (_buffer == null) + { _buffer = new byte[DEFAULT_BUFFER_LENGTH]; } } _length = _buffer.length; } - public void setUnaligned() { + public void setUnaligned() + { _unaligned = true; } - public byte[] getBytes() { + public byte[] getBytes() + { int n = _offset; byte[] bytes = new byte[n]; System.arraycopy(_buffer, 0, bytes, 0, n); return bytes; } - public byte[] getBuffer() { + public byte[] getBuffer() + { return _buffer; } - public int getOffset() { + public int getOffset() + { return _offset; } - public int getLength() { + public int getLength() + { return _length; } - public byte[] getEncapsulation() { + public byte[] getEncapsulation() + { byte[] data = new byte[_offset]; System.arraycopy(_buffer, 0, data, 0, _offset); return data; } - public void setGiopVersion(int version) { + public void setGiopVersion(int version) + { _giopVersion = version; } /** - * * Align the buffer offset so the next item is written at an offset - * * aligned according to <code>alignment</code>, which must be a - * * power of 2 (and at least = 1). - * * <p>The padding bytes are set to zero, to prevent the - * * security problems inherent in uninitialised padding bytes. - * * <p>Then we check if there is enough space left in the buffer for - * * an item of <code>size</code> bytes; if not, we expand the buffer - * * to make space. - */ - public final void write_align(int alignment, int size) { - if (_unaligned) { + ** Align the buffer offset so the next item is written at an offset + ** aligned according to <code>alignment</code>, which must be a + ** power of 2 (and at least = 1). + ** <p>The padding bytes are set to zero, to prevent the + ** security problems inherent in uninitialised padding bytes. + ** <p>Then we check if there is enough space left in the buffer for + ** an item of <code>size</code> bytes; if not, we expand the buffer + ** to make space. + **/ + public final void write_align(int alignment, int size) + { + if (_unaligned) + { alignment = 1; } int needLength = _offset + alignment + size; - if (needLength > _length) { + if (needLength > _length) + { // We need to increase the buffer size. We allow for a bit // of future expansion (if possible). int factor8 = 32; - for (int pass = 1; pass <= 7; pass++, factor8 /= 2) { + for (int pass = 1; pass <= 7; pass++, factor8 /= 2) + { // We try factors 5, 3, 2, 1.5, 1.25, 1.125, 1. - try { + try + { byte[] newBuffer = new byte[needLength + factor8 * needLength / 8]; // Copy old buffer contents into new buffer. System.arraycopy(_buffer, 0, newBuffer, 0, _offset); @@ -192,24 +212,30 @@ _buffer = newBuffer; _length = newBuffer.length; break; - } catch (OutOfMemoryError ignore) { - if (pass == 7) { + } + catch (OutOfMemoryError ignore) + { + if (pass == 7) + { throw new org.omg.CORBA.NO_MEMORY(needLength + " bytes"); } } } } int mask = alignment - 1; - for (int i = (alignment - (_offset & mask)) & mask; i > 0; i--) { + for (int i = (alignment - (_offset & mask)) & mask; i > 0; i--) + { _buffer[_offset++] = 0; } } /** - * * Convenience method needed in many places. - */ - public void write_octet_sequence(byte[] bytes) { - if (bytes == null) { + ** Convenience method needed in many places. + **/ + public void write_octet_sequence(byte[] bytes) + { + if (bytes == null) + { bytes = ArrayUtil.EMPTY_BYTE_ARRAY; } int n = bytes.length; @@ -217,30 +243,33 @@ write_octet_array(bytes, 0, n); } - public void write_message(int messageType) { + public void write_message(int messageType) + { MessageHeader_1_1 header = new MessageHeader_1_1(); header.magic = GIOP_MAGIC; - switch (_giopVersion) { - case GiopVersion.VERSION_1_0: - header.GIOP_version = GIOP_VERSION_1_2; - break; - case GiopVersion.VERSION_1_1: - header.GIOP_version = GIOP_VERSION_1_1; - break; - case GiopVersion.VERSION_1_2: - header.GIOP_version = GIOP_VERSION_1_2; - break; - default: - throw new IllegalStateException(); + switch (_giopVersion) + { + case GiopVersion.VERSION_1_0: + header.GIOP_version = GIOP_VERSION_1_2; + break; + case GiopVersion.VERSION_1_1: + header.GIOP_version = GIOP_VERSION_1_1; + break; + case GiopVersion.VERSION_1_2: + header.GIOP_version = GIOP_VERSION_1_2; + break; + default: + throw new IllegalStateException(); } header.flags = 0; - header.message_type = (byte) messageType; + header.message_type = (byte)messageType; header.message_size = 0; // header.message_size is rewritten later MessageHeader_1_1Helper.write(this, header); } - public void write_message_size() { + public void write_message_size() + { int messageSize = _offset - 12; int saveOffset = _offset; _offset = 8; @@ -248,43 +277,50 @@ _offset = saveOffset; } - public void write_request(RequestHeader_1_2 request, CdrOutputStream parameters) { - if (request.service_context == null) { + public void write_request(RequestHeader_1_2 request, CdrOutputStream parameters) + { + if (request.service_context == null) + { // Avoid allocation of empty array by Helper. request.service_context = EMPTY_SERVICE_CONTEXT_LIST; } write_message(MsgType_1_1._Request); - switch (_giopVersion) { - case GiopVersion.VERSION_1_0: - RequestHeader_1_0 req10 = new RequestHeader_1_0(); - req10.service_context = request.service_context; - req10.request_id = request.request_id; - req10.response_expected = (request.response_flags & 1) != 0; - req10.operation = request.operation; - req10.object_key = request.target.object_key(); - RequestHeader_1_0Helper.write(this, req10); - break; - case GiopVersion.VERSION_1_1: - RequestHeader_1_1 req11 = new RequestHeader_1_1(); - req11.service_context = request.service_context; - req11.request_id = request.request_id; - req11.response_expected = (request.response_flags & 1) != 0; - req11.operation = request.operation; - req11.object_key = request.target.object_key(); - RequestHeader_1_1Helper.write(this, req11); - break; - case GiopVersion.VERSION_1_2: - RequestHeader_1_2Helper.write(this, request); - break; - default: - throw new IllegalStateException(); + switch (_giopVersion) + { + case GiopVersion.VERSION_1_0: + RequestHeader_1_0 req10 = new RequestHeader_1_0(); + req10.service_context = request.service_context; + req10.request_id = request.request_id; + req10.response_expected = (request.response_flags & 1) != 0; + req10.operation = request.operation; + req10.object_key = request.target.object_key(); + RequestHeader_1_0Helper.write(this, req10); + break; + case GiopVersion.VERSION_1_1: + RequestHeader_1_1 req11 = new RequestHeader_1_1(); + req11.service_context = request.service_context; + req11.request_id = request.request_id; + req11.response_expected = (request.response_flags & 1) != 0; + req11.operation = request.operation; + req11.object_key = request.target.object_key(); + RequestHeader_1_1Helper.write(this, req11); + break; + case GiopVersion.VERSION_1_2: + RequestHeader_1_2Helper.write(this, request); + break; + default: + throw new IllegalStateException(); } byte[] parametersBuffer = parameters.getBuffer(); int parametersLength = parameters.getOffset(); - if (parametersLength > 0) { - if (_giopVersion >= GiopVersion.VERSION_1_2) { + if (parametersLength > 0) + { + if (_giopVersion >= GiopVersion.VERSION_1_2) + { write_align(8, 0); // parameters are 8-byte aligned - } else { + } + else + { // TODO: should have padded service context earlier } write_octet_array(parametersBuffer, 0, parametersLength); @@ -292,33 +328,40 @@ write_message_size(); } - public void write_reply(ReplyHeader_1_2 reply, CdrOutputStream results) { - if (reply.service_context == null) { + public void write_reply(ReplyHeader_1_2 reply, CdrOutputStream results) + { + if (reply.service_context == null) + { // Avoid allocation of empty array by Helper. reply.service_context = EMPTY_SERVICE_CONTEXT_LIST; } write_message(MsgType_1_1._Reply); - switch (_giopVersion) { - case GiopVersion.VERSION_1_0: - case GiopVersion.VERSION_1_1: - ReplyHeader_1_0 rep10 = new ReplyHeader_1_0(); - rep10.service_context = reply.service_context; - rep10.request_id = reply.request_id; - rep10.reply_status = reply.reply_status; - ReplyHeader_1_0Helper.write(this, rep10); - break; - case GiopVersion.VERSION_1_2: - ReplyHeader_1_2Helper.write(this, reply); - break; - default: - throw new IllegalStateException(); + switch (_giopVersion) + { + case GiopVersion.VERSION_1_0: + case GiopVersion.VERSION_1_1: + ReplyHeader_1_0 rep10 = new ReplyHeader_1_0(); + rep10.service_context = reply.service_context; + rep10.request_id = reply.request_id; + rep10.reply_status = reply.reply_status; + ReplyHeader_1_0Helper.write(this, rep10); + break; + case GiopVersion.VERSION_1_2: + ReplyHeader_1_2Helper.write(this, reply); + break; + default: + throw new IllegalStateException(); } byte[] resultsBuffer = results.getBuffer(); int resultsLength = results.getOffset(); - if (resultsLength > 0) { - if (_giopVersion >= GiopVersion.VERSION_1_2) { + if (resultsLength > 0) + { + if (_giopVersion >= GiopVersion.VERSION_1_2) + { write_align(8, 0); // results are 8-byte aligned - } else { + } + else + { // TODO: should have padded service context earlier } write_octet_array(resultsBuffer, 0, resultsLength); @@ -326,40 +369,61 @@ write_message_size(); } - public void write_reply(LocateReplyHeader_1_2 reply) { + public void write_reply(LocateReplyHeader_1_2 reply) + { write_message(MsgType_1_1._LocateReply); LocateReplyHeader_1_2Helper.write(this, reply); write_message_size(); } - public void write_SystemException(Exception ex, boolean withStackTrace) { + public void write_SystemException(Exception ex, boolean withStackTrace) + { String type = "UNKNOWN"; - if (ex instanceof org.omg.CORBA.SystemException) { + if (ex instanceof org.omg.CORBA.SystemException) + { type = JavaClass.getNameSuffix(ex.getClass().getName()); - } else if (ex instanceof SecurityException) { - type = "NO_PERMISSION"; - } else if (ex instanceof UnsupportedOperationException) { + } + else if (ex instanceof UnsupportedOperationException) + { type = "BAD_OPERATION"; } + else if (ex instanceof SecurityException) + { + type = "NO_PERMISSION"; + } + else if (ex instanceof java.rmi.NoSuchObjectException) + { + type = "OBJECT_NOT_EXIST"; + } + //else if (ex instanceof org.apache.geronimo.interop.transaction.TransactionRolledbackSystemException) + //{ + // type = "TRANSACTION_ROLLEDBACK"; + //} String id = "IDL:omg.org/CORBA/" + type + ":1.0"; write_string(id); write_long(0); // minor (TODO: other values?) write_long(0); // completed (TODO: other values?) - if (withStackTrace) { + if (withStackTrace) + { write_string(ExceptionUtil.getStackTrace(ex)); } } - public void send_message(java.io.OutputStream output, String host) { - if (RMI_TRACE) { + public void send_message(java.io.OutputStream output, String url) + { + if (RMI_TRACE) + { byte[] data = new byte[_offset]; System.arraycopy(_buffer, 0, data, 0, _offset); - RmiTrace.send(host, data); + RmiTrace.send(url, data); } - try { + try + { output.write(_buffer, 0, _offset); output.flush(); - } catch (java.io.IOException ex) { + } + catch (java.io.IOException ex) + { throw new org.omg.CORBA.COMM_FAILURE(ex.toString()); } } @@ -368,209 +432,267 @@ // public methods from org.omg.CORBA.portable.OutputStream // ----------------------------------------------------------------------- - public void write_boolean(boolean value) { + public void write_boolean(boolean value) + { write_align(1, 1); - if (value) { + if (value) + { _buffer[_offset++] = 1; - } else { + } + else + { _buffer[_offset++] = 0; } } - public void write_char(char value) { + public void write_char(char value) + { write_align(1, 1); - if ((int) value > 255) { + if ((int)value > 255) + { throw new org.omg.CORBA.MARSHAL("write_char: value = " + value); } - _buffer[_offset++] = (byte) value; + _buffer[_offset++] = (byte)value; } - public void write_wchar(char value) { - write_octet((byte) 2); // size of wchar is 2 bytes + public void write_wchar(char value) + { + write_octet((byte)2); // size of wchar is 2 bytes write_align(1, 2); - write_ushort_no_align_big_endian((int) value); + write_ushort_no_align_big_endian((int)value); } - public void write_octet(byte value) { + public void write_octet(byte value) + { write_align(1, 1); _buffer[_offset++] = value; } - public void write_short(short value) { + public void write_short(short value) + { write_align(2, 2); int oldOffset = _offset; _offset += 2; BigEndian.setShort(_buffer, oldOffset, value); } - public void write_ushort(short value) { + public void write_ushort(short value) + { write_short(value); } - public void write_long(int value) { + public void write_long(int value) + { write_align(4, 4); int oldOffset = _offset; _offset += 4; BigEndian.setInt(_buffer, oldOffset, value); } - public void write_ulong(int value) { + public void write_ulong(int value) + { write_long(value); } - public void write_longlong(long value) { + public void write_longlong(long value) + { write_align(8, 8); int oldOffset = _offset; _offset += 8; BigEndian.setLong(_buffer, oldOffset, value); } - public void write_ulonglong(long value) { + public void write_ulonglong(long value) + { write_longlong(value); } - public void write_float(float value) { + public void write_float(float value) + { write_long(Float.floatToIntBits(value)); } - public void write_double(double value) { + public void write_double(double value) + { write_longlong(Double.doubleToLongBits(value)); } - public void write_string(String value) { - if (value == null) { + public void write_string(String value) + { + if (value == null) + { value = ""; } write_align(4, 4); int size = UTF8.fromString(value, _buffer, _offset + 4, _length - 1); - if (size == -1) { + if (size == -1) + { // No room to convert in-place, ok to allocate new byte array. byte[] bytes = UTF8.fromString(value); size = bytes.length; write_ulong(size + 1); write_octet_array(bytes, 0, size); - } else { + } + else + { // Already converted already into _buffer. write_ulong(size + 1); _offset += size; } - write_octet((byte) 0); + write_octet((byte)0); } - public void write_wstring(String value) { - if (value == null) { + public void write_wstring(String value) + { + if (value == null) + { value = ""; } int size = value.length(); int numBytes = 2 * size; write_ulong(numBytes); // No terminating NUL write_align(1, numBytes); - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) + { char c = value.charAt(i); - BigEndian.setShort(_buffer, _offset, (short) c); + BigEndian.setShort(_buffer, _offset, (short)c); _offset += 2; } } - public void write_boolean_array(boolean[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_boolean_array(boolean[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_boolean(value[offset + i]); } } - public void write_char_array(char[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_char_array(char[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_char(value[offset + i]); } } - public void write_wchar_array(char[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_wchar_array(char[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_wchar(value[offset + i]); } } - public void write_octet_array(byte[] value, int offset, int length) { + public void write_octet_array(byte[] value, int offset, int length) + { write_align(1, length); System.arraycopy(value, offset, _buffer, _offset, length); _offset += length; } - public void write_short_array(short[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_short_array(short[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_short(value[offset + i]); } } - public void write_ushort_array(short[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_ushort_array(short[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_ushort(value[offset + i]); } } - public void write_long_array(int[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_long_array(int[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_long(value[offset + i]); } } - public void write_ulong_array(int[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_ulong_array(int[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_ulong(value[offset + i]); } } - public void write_longlong_array(long[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_longlong_array(long[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_longlong(value[offset + i]); } } - public void write_ulonglong_array(long[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_ulonglong_array(long[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_ulonglong(value[offset + i]); } } - public void write_float_array(float[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_float_array(float[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_float(value[offset + i]); } } - public void write_double_array(double[] value, int offset, int length) { - for (int i = 0; i < length; i++) { + public void write_double_array(double[] value, int offset, int length) + { + for (int i = 0; i < length; i++) + { write_double(value[offset + i]); } } - public void write_Object(org.omg.CORBA.Object value) { - if (value == null) { + public void write_Object(org.omg.CORBA.Object value) + { + if (value == null) + { write_IOR(null); - } else if (value instanceof ObjectRef) { - ObjectRef ref = (ObjectRef) value; + } + else if (value instanceof ObjectRef) + { + ObjectRef ref = (ObjectRef)value; IOR ior = ref.$getIOR(); write_IOR(ior); - } else { + } + else + { throw new org.omg.CORBA.MARSHAL(value.getClass().getName()); } } - public void write_TypeCode(org.omg.CORBA.TypeCode tc) { + public void write_TypeCode(org.omg.CORBA.TypeCode tc) + { write_TypeCode(tc, new java.util.HashMap()); } - public void write_Any(org.omg.CORBA.Any value) { + public void write_Any(org.omg.CORBA.Any value) + { org.omg.CORBA.TypeCode tc = value.type(); write_TypeCode(tc); write_Any(value.create_input_stream(), tc); } // Sybase-internal - public void write_Any(org.omg.CORBA.portable.InputStream is, org.omg.CORBA.TypeCode tc) { - try { + public void write_Any(org.omg.CORBA.portable.InputStream is, org.omg.CORBA.TypeCode tc) + { + try + { int tk = tc.kind().value(); - switch (tk) { + switch (tk) + { case TCKind._tk_null: case TCKind._tk_void: break; @@ -633,7 +755,8 @@ { int n = tc.length(); org.omg.CORBA.TypeCode c = tc.content_type(); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { write_Any(is, c); } } @@ -643,7 +766,8 @@ int n = is.read_ulong(); write_ulong(n); org.omg.CORBA.TypeCode c = tc.content_type(); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { write_Any(is, c); } } @@ -652,7 +776,8 @@ case TCKind._tk_except: { int n = tc.member_count(); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { write_Any(is, tc.member_type(i)); } } @@ -664,13 +789,16 @@ write_Any(disc.create_input_stream(), dt); int di = tc.default_index(); int i, n = tc.member_count(); - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) + { org.omg.CORBA.Any label = tc.member_label(i); - if (label.equal(disc)) { + if (label.equal(disc)) + { write_Any(is, tc.member_type(i)); } } - if (i == n && di >= 0) { + if (i == n && di >= 0) + { write_Any(is, tc.member_type(di)); } } @@ -680,9 +808,13 @@ default: throw new org.omg.CORBA.MARSHAL("write_Any: type = " + tc); } - } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) { + } + catch (org.omg.CORBA.TypeCodePackage.BadKind ex) + { throw new org.omg.CORBA.MARSHAL("write_Any: " + ex.toString()); - } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) { + } + catch (org.omg.CORBA.TypeCodePackage.Bounds ex) + { throw new org.omg.CORBA.MARSHAL("write_Any: " + ex.toString()); } } @@ -739,10 +871,11 @@ // doing this specifically to handle Any. This implementation // could be worng but will work for us - public org.omg.CORBA.portable.InputStream create_input_stream() { + public org.omg.CORBA.portable.InputStream create_input_stream() + { CdrInputStream is = CdrInputStream.getInstance(); is._buffer = new byte[_buffer.length]; - System.arraycopy(_buffer, 0, is._buffer, 0, _buffer.length); + System.arraycopy(_buffer,0,is._buffer,0,_buffer.length); is._length = _buffer.length; is._offset = 0; return is; @@ -752,51 +885,63 @@ // protected methods // ----------------------------------------------------------------------- - protected void pool(byte[] oldBuffer) { - if (oldBuffer.length <= MAXIMUM_POOLED_BUFFER_LENGTH) { + protected void pool(byte[] oldBuffer) + { + if (oldBuffer.length <= MAXIMUM_POOLED_BUFFER_LENGTH) + { _pooledBuffer = oldBuffer; } } - protected final void write_ushort_no_align_big_endian(int value) { + protected final void write_ushort_no_align_big_endian(int value) + { int oldOffset = _offset; _offset += 2; - BigEndian.setShort(_buffer, oldOffset, (short) value); + BigEndian.setShort(_buffer, oldOffset, (short)value); } - protected void write_IOR(IOR ior) { - if (ior == null) { + protected void write_IOR(IOR ior) + { + if (ior == null) + { ior = NULL_IOR; } IORHelper.write(this, ior); } - public int begin() { + public int begin() + { write_ulong(0); int saveOffset = _offset; write_boolean(false); return saveOffset; } - public void end(int saveOffset) { + public void end(int saveOffset) + { int endOffset = _offset; _offset = saveOffset - 4; write_ulong(endOffset - saveOffset); _offset = endOffset; } - private void write_TypeCode(org.omg.CORBA.TypeCode tc, java.util.HashMap table) { - try { + private void write_TypeCode(org.omg.CORBA.TypeCode tc, java.util.HashMap table) + { + try + { int tk = tc.kind().value(); // Check if we need to write an indirection - switch (tk) { + switch (tk) + { case TCKind._tk_struct: case TCKind._tk_union: case TCKind._tk_value: String id = tc.id(); - if (!id.equals("")) { - Integer key = (Integer) table.get(id); - if (key != null) { + if (! id.equals("")) + { + Integer key = (Integer)table.get(id); + if (key != null) + { write_ulong(0xffffffff); write_long(key.intValue() - _offset); return; @@ -805,7 +950,8 @@ } } write_ulong(tk); - switch (tk) { + switch (tk) + { case TCKind._tk_null: case TCKind._tk_void: case TCKind._tk_TypeCode: @@ -869,7 +1015,8 @@ write_string(tc.name()); int count = tc.member_count(); write_ulong(count); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { write_string(tc.member_name(i)); } end(saveOffset); @@ -883,7 +1030,8 @@ write_string(tc.name()); int count = tc.member_count(); write_ulong(count); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { write_string(tc.member_name(i)); write_TypeCode(tc.member_type(i), table); } @@ -901,7 +1049,8 @@ write_ulong(di); int count = tc.member_count(); write_ulong(count); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { write_Any(tc.member_label(i).create_input_stream(), dt); write_string(tc.member_name(i)); write_TypeCode(tc.member_type(i), table); @@ -918,7 +1067,8 @@ write_TypeCode(tc.concrete_base_type(), table); int count = tc.member_count(); write_ulong(count); - for (int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) + { write_string(tc.member_name(i)); write_TypeCode(tc.member_type(i), table); write_short(tc.member_visibility(i)); @@ -929,24 +1079,34 @@ default: throw new org.omg.CORBA.MARSHAL("write_TypeCode: kind = " + tk); } - } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) { + } + catch (org.omg.CORBA.TypeCodePackage.BadKind ex) + { throw new org.omg.CORBA.MARSHAL(ex.toString()); - } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) { + } + catch (org.omg.CORBA.TypeCodePackage.Bounds ex) + { throw new org.omg.CORBA.MARSHAL(ex.toString()); } } - private org.omg.CORBA.Any read_disc(org.omg.CORBA.portable.InputStream is, org.omg.CORBA.TypeCode dt) { + private org.omg.CORBA.Any read_disc(org.omg.CORBA.portable.InputStream is, org.omg.CORBA.TypeCode dt) + { int tk = dt.kind().value(); - if (tk == TCKind._tk_alias) { - try { + if (tk == TCKind._tk_alias) + { + try + { return read_disc(is, dt.content_type()); - } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) { + } + catch (org.omg.CORBA.TypeCodePackage.BadKind ex) + { throw new org.omg.CORBA.MARSHAL("read_disc: " + ex.toString()); } } org.omg.CORBA.Any disc = new org.apache.geronimo.interop.rmi.iiop.Any(); - switch (tk) { + switch (tk) + { case TCKind._tk_boolean: disc.insert_boolean(is.read_boolean()); break;
Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CorbaObject.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CorbaObject.java?view=auto&rev=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CorbaObject.java (added) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/CorbaObject.java Wed Mar 23 09:56:34 2005 @@ -0,0 +1,78 @@ +/** + * + * Copyright 2004-2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.interop.rmi.iiop; + +import org.omg.CORBA.*; + +public class CorbaObject implements org.omg.CORBA.Object { + // ----------------------------------------------------------------------- + // unimplemented public methods (only required for full CORBA ORB) + // ----------------------------------------------------------------------- + + public boolean _is_a(String id) { + return false; + } + + public org.omg.CORBA.Request _create_request(org.omg.CORBA.Context p1, String p2, org.omg.CORBA.NVList p3, org.omg.CORBA.NamedValue p4) { + throw new org.omg.CORBA.BAD_OPERATION("_create_request"); + } + + public org.omg.CORBA.Request _create_request(org.omg.CORBA.Context p1, String p2, org.omg.CORBA.NVList p3, org.omg.CORBA.NamedValue p4, org.omg.CORBA.ExceptionList p5, org.omg.CORBA.ContextList p6) { + throw new org.omg.CORBA.BAD_OPERATION("_create_request"); + } + + public org.omg.CORBA.Object _duplicate() { + throw new org.omg.CORBA.BAD_OPERATION("_duplicate"); + } + + public org.omg.CORBA.DomainManager[] _get_domain_managers() { + throw new org.omg.CORBA.BAD_OPERATION("_get_domain_manager"); + } + + public org.omg.CORBA.Object _get_interface_def() { + throw new org.omg.CORBA.BAD_OPERATION("_get_interface_def"); + } + + public org.omg.CORBA.Policy _get_policy(int p1) { + throw new org.omg.CORBA.BAD_OPERATION("_get_policy"); + } + + public int _hash(int p1) { + throw new org.omg.CORBA.BAD_OPERATION("_hash"); + } + + public boolean _is_equivalent(org.omg.CORBA.Object p1) { + throw new org.omg.CORBA.BAD_OPERATION("_is_equivalent"); + } + + public boolean _non_existent() { + throw new org.omg.CORBA.BAD_OPERATION("_non_existent"); + } + + public void _release() { + throw new org.omg.CORBA.BAD_OPERATION("_release"); + } + + public org.omg.CORBA.Request _request(String p1) { + throw new org.omg.CORBA.BAD_OPERATION("_request"); + } + + public org.omg.CORBA.Object _set_policy_override(org.omg.CORBA.Policy[] p1, org.omg.CORBA.SetOverrideType p2) { + throw new org.omg.CORBA.BAD_OPERATION("_set_policy_override"); + } +} Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldByNameComparator.java Wed Mar 23 09:56:34 2005 @@ -17,23 +17,25 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import java.lang.reflect.Field; -import java.util.Comparator; - +import java.lang.reflect.*; +import java.util.*; /** - * * Sort fields by name only. - */ -public class FieldByNameComparator implements Comparator { + ** Sort fields by name only. + **/ +public class FieldByNameComparator implements Comparator +{ public static final FieldByNameComparator SINGLETON = new FieldByNameComparator(); - public int compare(Object x, Object y) { - Field a = (Field) x; - Field b = (Field) y; + public int compare(Object x, Object y) + { + Field a = (Field)x; + Field b = (Field)y; return a.getName().compareTo(b.getName()); } - public boolean equals(Object x) { + public boolean equals(Object x) + { // shouldn't be used return false; } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FieldComparator.java Wed Mar 23 09:56:34 2005 @@ -17,35 +17,46 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import java.lang.reflect.Field; -import java.util.Comparator; - +import java.lang.reflect.*; +import java.util.*; /** - * * Sort fields in the order they must be marshalled for RMI-IIOP. - */ -public class FieldComparator implements Comparator { + ** Sort fields in the order they must be marshalled for RMI-IIOP. + **/ +public class FieldComparator implements Comparator +{ public static final FieldComparator SINGLETON = new FieldComparator(); - public int compare(Object x, Object y) { - Field a = (Field) x; - Field b = (Field) y; - if (a.getType().isPrimitive()) { - if (b.getType().isPrimitive()) { + public int compare(Object x, Object y) + { + Field a = (Field)x; + Field b = (Field)y; + if (a.getType().isPrimitive()) + { + if (b.getType().isPrimitive()) + { return a.getName().compareTo(b.getName()); - } else { + } + else + { return -1; } - } else { - if (b.getType().isPrimitive()) { + } + else + { + if (b.getType().isPrimitive()) + { return 1; - } else { + } + else + { return a.getName().compareTo(b.getName()); } } } - public boolean equals(Object x) { + public boolean equals(Object x) + { // shouldn't be used return false; } Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetter.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetter.java?view=auto&rev=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetter.java (added) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetter.java Wed Mar 23 09:56:34 2005 @@ -0,0 +1,50 @@ +/** + * + * Copyright 2004-2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.interop.rmi.iiop; + +import org.apache.geronimo.interop.util.SystemUtil; + +import java.lang.reflect.Field; + +public abstract class FinalFieldSetter +{ + private static final boolean JDK14 = SystemUtil.isJDK14(); + + public static FinalFieldSetter getInstance(Field f) + { + if(JDK14) + { + return new FinalFieldSetterJdk14(f); + } + else + { + throw new RuntimeException("FinalFieldSetter is not implemented for jdk version: " + + SystemUtil.getVmVersion()); + } + } + + public abstract void setBoolean(Object that, boolean value); + public abstract void setByte(Object that, byte value); + public abstract void setChar(Object that, char value); + public abstract void setDouble(Object that, double value); + public abstract void setFloat(Object that, float value); + public abstract void setInt(Object that, int value); + public abstract void setLong(Object that, long value); + public abstract void setShort(Object that, short value); + public abstract void set(Object that, Object value); +} Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetterJdk14.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetterJdk14.java?view=auto&rev=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetterJdk14.java (added) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/FinalFieldSetterJdk14.java Wed Mar 23 09:56:34 2005 @@ -0,0 +1,107 @@ +/** + * + * Copyright 2004-2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.geronimo.interop.rmi.iiop; + +import java.lang.reflect.Field; + +/* + * FinalFields that are sent across the wire .. how to unmarshall and recreate the object on the + * receiving side? We don't want to invoke the constructor since it would establish values for + * final fields. We have to recreate the final field exactly like it was on the sender side. + * + * The sun.misc.Unsafe does this for us. + */ + +public class FinalFieldSetterJdk14 extends FinalFieldSetter +{ + private final long fieldOffset; + private static final sun.misc.Unsafe unsafe; //Only available for Sun's JDK1.4+ + + static + { + sun.misc.Unsafe val = null; + try + { + Class unsafeClass = Class.forName("sun.misc.Unsafe"); + Field unsafeField = unsafeClass.getDeclaredField("theUnsafe"); + unsafeField.setAccessible(true); + val = (sun.misc.Unsafe)unsafeField.get((java.lang.Object)null); + } + catch(Throwable e) + { + } + unsafe = val; + } + + public FinalFieldSetterJdk14(Field field) + { + if(unsafe != null) + { + fieldOffset = unsafe.objectFieldOffset(field); + } + else + { + fieldOffset = -1; + } + } + + public void setBoolean(Object that, boolean value) + { + unsafe.putBoolean(that, fieldOffset, value); + } + + public void setByte(Object that, byte value) + { + unsafe.putByte(that, fieldOffset, value); + } + + public void setChar(Object that, char value) + { + unsafe.putChar(that, fieldOffset, value); + } + + public void setDouble(Object that, double value) + { + unsafe.putDouble(that, fieldOffset, value); + } + + public void setFloat(Object that, float value) + { + unsafe.putFloat(that, fieldOffset, value); + } + + public void setInt(Object that, int value) + { + unsafe.putInt(that, fieldOffset, value); + } + + public void setLong(Object that, long value) + { + unsafe.putLong(that, fieldOffset, value); + } + + public void setShort(Object that, short value) + { + unsafe.putShort(that, fieldOffset, value); + } + + public void set(Object that, Object value) + { + unsafe.putObject(that, fieldOffset, value); + } +} Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopMessage.java Wed Mar 23 09:56:34 2005 @@ -19,8 +19,8 @@ import org.apache.geronimo.interop.GIOP.*; - -public class GiopMessage { +public class GiopMessage +{ public int size; public int type; public int giopVersion; @@ -28,7 +28,8 @@ public LocateRequestHeader_1_2 locateRequest; public ReplyHeader_1_2 reply; - public String toString() { + public String toString() + { StringBuffer sb = new StringBuffer("GiopMessage("); /* TODO if (header != null) Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/GiopVersion.java Wed Mar 23 09:56:34 2005 @@ -17,7 +17,8 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public class GiopVersion { +public class GiopVersion +{ public static final int VERSION_1_0 = 0; public static final int VERSION_1_1 = 1; public static final int VERSION_1_2 = 2; Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IDLEntityHelper.java Wed Mar 23 09:56:34 2005 @@ -17,14 +17,13 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import java.lang.reflect.Method; +import org.apache.geronimo.interop.*; +import org.apache.geronimo.interop.util.*; +import java.lang.reflect.*; import java.util.HashMap; -import org.apache.geronimo.interop.SystemException; -import org.apache.geronimo.interop.util.ThreadContext; - - -public class IDLEntityHelper implements ObjectHelper { +public class IDLEntityHelper implements ObjectHelper +{ private static Class[] EMPTY_CLASS_ARRAY = {}; private static Object[] EMPTY_OBJECT_ARRAY = {}; @@ -39,71 +38,105 @@ private Method _write; - static IDLEntityHelper getInstance(Class theClass) { - IDLEntityHelper helper = (IDLEntityHelper) _helperMap.get(theClass); - if (helper == null) { - synchronized (_helperMap) { - helper = (IDLEntityHelper) _helperMap.get(theClass); - if (helper == null) { - helper = new IDLEntityHelper(theClass); - _helperMap.put(theClass, helper); - } - } + static IDLEntityHelper getInstance(Class theClass) + { + IDLEntityHelper helper = (IDLEntityHelper)_helperMap.get(theClass); + if (helper == null) + { + synchronized (_helperMap) + { + helper = (IDLEntityHelper)_helperMap.get(theClass); + if (helper == null) + { + helper = new IDLEntityHelper(theClass); + _helperMap.put(theClass, helper); + } + } } return helper; } - private IDLEntityHelper(Class theClass) { - try { + private IDLEntityHelper(Class theClass) + { + try + { Class helper = ThreadContext.loadClass(theClass.getName() + "Helper", theClass); _id = helper.getDeclaredMethod("id", EMPTY_CLASS_ARRAY); _type = helper.getDeclaredMethod("type", EMPTY_CLASS_ARRAY); - _read = helper.getDeclaredMethod("read", new Class[]{org.omg.CORBA.portable.InputStream.class}); - _write = helper.getDeclaredMethod("write", new Class[]{org.omg.CORBA.portable.OutputStream.class, theClass}); - } catch (SystemException ex) { - throw ex; - } catch (Exception ex) { - throw new SystemException(ex); + _read = helper.getDeclaredMethod("read", new Class[] { org.omg.CORBA.portable.InputStream.class }); + _write = helper.getDeclaredMethod("write", new Class[] { org.omg.CORBA.portable.OutputStream.class, theClass }); + } + catch (SystemException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new SystemException(ex); } } - public String id() { - try { - return (String) _id.invoke(null, EMPTY_OBJECT_ARRAY); - } catch (SystemException ex) { - throw ex; - } catch (Exception ex) { - throw new SystemException(ex); + public String id() + { + try + { + return (String)_id.invoke(null, EMPTY_OBJECT_ARRAY); + } + catch (SystemException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new SystemException(ex); } } - public org.omg.CORBA.TypeCode type() { - try { - return (org.omg.CORBA.TypeCode) _type.invoke(null, EMPTY_OBJECT_ARRAY); - } catch (SystemException ex) { - throw ex; - } catch (Exception ex) { - throw new SystemException(ex); + public org.omg.CORBA.TypeCode type() + { + try + { + return (org.omg.CORBA.TypeCode)_type.invoke(null, EMPTY_OBJECT_ARRAY); + } + catch (SystemException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new SystemException(ex); } } - public Object read(ObjectInputStream input) { - try { - return _read.invoke(null, new Object[]{input._cdrInput}); - } catch (SystemException ex) { - throw ex; - } catch (Exception ex) { - throw new SystemException(ex); + public Object read(ObjectInputStream input) + { + try + { + return _read.invoke(null, new Object[] { input._cdrInput }); } - } + catch (SystemException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new SystemException(ex); + } + } - public void write(ObjectOutputStream output, Object value) { - try { - _write.invoke(null, new Object[]{output._cdrOutput, value}); - } catch (SystemException ex) { - throw ex; - } catch (Exception ex) { - throw new SystemException(ex); + public void write(ObjectOutputStream output, Object value) + { + try + { + _write.invoke(null, new Object[] { output._cdrOutput, value }); } - } + catch (SystemException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new SystemException(ex); + } + } } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/IiopVersion.java Wed Mar 23 09:56:34 2005 @@ -17,5 +17,6 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public class IiopVersion { +public class IiopVersion +{ } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ListenerInfo.java Wed Mar 23 09:56:34 2005 @@ -1,26 +0,0 @@ -/** - * - * Copyright 2004-2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.geronimo.interop.rmi.iiop; - -public class ListenerInfo { - public int protocol; - - public String host; - - public int port; -} Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/NameServiceOperations_Skeleton.java Wed Mar 23 09:56:34 2005 @@ -1,373 +0,0 @@ -// -// CORBA RMI-IIOP Skeleton Generator -// Interface: NameServiceOperations_Skeleton -// Date: Wed Dec 08 15:22:39 EST 2004 - -/** - * - * Copyright 2004-2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.geronimo.interop.rmi.iiop; - -import java.util.HashMap; - - -public class NameServiceOperations_Skeleton - extends RemoteObject - implements RemoteInterface { - // - // Fields - // - public java.lang.String[] _ids = {"org.apache.geronimo.interop.rmi.iiop.NameServiceOperations", "RMI:org.apache.geronimo.interop.rmi.iiop.NameServiceOperations:0000000000000000", "NameService"}; - public java.util.HashMap _methods = new HashMap(10); - public org.apache.geronimo.interop.rmi.iiop.NameServiceOperations _servant = null; - public java.lang.String _f3 = "f1"; - public java.lang.String[] _f4 = {"f1", "f2"}; - public org.apache.geronimo.interop.rmi.iiop.ValueType vt$0 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(java.lang.String.class); - public org.apache.geronimo.interop.rmi.iiop.ValueType vt$1 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NameComponent[].class); - public org.apache.geronimo.interop.rmi.iiop.ValueType vt$2 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.omg.CORBA.Object.class); - public org.apache.geronimo.interop.rmi.iiop.ValueType vt$3 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingListHolder.class); - public org.apache.geronimo.interop.rmi.iiop.ValueType vt$4 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.BindingIteratorHolder.class); - public org.apache.geronimo.interop.rmi.iiop.ValueType vt$5 = org.apache.geronimo.interop.rmi.iiop.ValueType.getInstance(org.apache.geronimo.interop.CosNaming.NamingContext.class); - - // - // Constructors - // - public NameServiceOperations_Skeleton() { - super(); - - registerMethods(); - } - - protected void registerMethods() { - super.registerMethods(); - - registerMethod("resolve_host", 0); - registerMethod("to_string", 1); - registerMethod("to_name", 2); - registerMethod("to_url", 3); - registerMethod("resolve_str", 4); - registerMethod("list", 5); - registerMethod("resolve", 6); - registerMethod("bind", 7); - registerMethod("bind_context", 8); - registerMethod("rebind", 9); - registerMethod("rebind_context", 10); - registerMethod("unbind", 11); - registerMethod("new_context", 12); - registerMethod("bind_new_context", 13); - } - - // - // Methods - // - - public void registerMethod(java.lang.String name, int id) { - _methods.put(name, new Integer(id)); - } - - public java.lang.String[] getIds() { - return _ids; - } - - public RemoteInterface $getSkeleton() { - return this; - } - - public ObjectRef $getObjectRef() { - org.apache.geronimo.interop.rmi.iiop.ObjectRef or = new ObjectRef(); - or.$setID("RMI:org.apache.geronimo.interop.rmi.iiop.NameServiceOperations:0000000000000000"); - or.$setObjectKey("org.apache.geronimo.interop.rmi.iiop.NameServiceOperations"); - return or; - } - - public void $invoke(java.lang.String methodName, byte[] objectKey, java.lang.Object instance, org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - java.lang.Integer m = (Integer) _methods.get(methodName); - if (m == null) { - throw new org.omg.CORBA.BAD_OPERATION(methodName); - } - - _servant = (org.apache.geronimo.interop.rmi.iiop.NameServiceOperations) instance; - - if (m.intValue() < 0) { - super.invoke(m.intValue(), objectKey, instance, input, output); - } - - - switch (m.intValue()) { - case 0: - { - resolve_host(input, output); - } - break; - case 1: - { - to_string(input, output); - } - break; - case 2: - { - to_name(input, output); - } - break; - case 3: - { - to_url(input, output); - } - break; - case 4: - { - resolve_str(input, output); - } - break; - case 5: - { - list(input, output); - } - break; - case 6: - { - resolve(input, output); - } - break; - case 7: - { - bind(input, output); - } - break; - case 8: - { - bind_context(input, output); - } - break; - case 9: - { - rebind(input, output); - } - break; - case 10: - { - rebind_context(input, output); - } - break; - case 11: - { - unbind(input, output); - } - break; - case 12: - { - new_context(input, output); - } - break; - case 13: - { - bind_new_context(input, output); - } - break; - } - } - - public void resolve_host(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - java.lang.String rc; - - try { - java.lang.String p0 = (java.lang.String) input.readObject(vt$0); - rc = _servant.resolve_host(p0); - output.writeObject(vt$0, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void to_string(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - java.lang.String rc; - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - rc = _servant.to_string(p0); - output.writeObject(vt$0, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void to_name(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - org.apache.geronimo.interop.CosNaming.NameComponent[] rc; - - try { - java.lang.String p0 = (java.lang.String) input.readObject(vt$0); - rc = _servant.to_name(p0); - output.writeObject(vt$1, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void to_url(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - java.lang.String rc; - - try { - java.lang.String p0 = (java.lang.String) input.readObject(vt$0); - java.lang.String p1 = (java.lang.String) input.readObject(vt$0); - rc = _servant.to_url(p0, p1); - output.writeObject(vt$0, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void resolve_str(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - org.omg.CORBA.Object rc; - - try { - java.lang.String p0 = (java.lang.String) input.readObject(vt$0); - rc = _servant.resolve_str(p0); - output.writeObject(vt$2, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void list(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - - try { - int p0 = input.readInt(); - org.apache.geronimo.interop.CosNaming.BindingListHolder p1 = (org.apache.geronimo.interop.CosNaming.BindingListHolder) input.readObject(vt$3); - org.apache.geronimo.interop.CosNaming.BindingIteratorHolder p2 = (org.apache.geronimo.interop.CosNaming.BindingIteratorHolder) input.readObject(vt$4); - _servant.list(p0, p1, p2); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void resolve(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - org.omg.CORBA.Object rc; - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - rc = _servant.resolve(p0); - output.writeObject(vt$2, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void bind(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - org.omg.CORBA.Object p1 = (org.omg.CORBA.Object) input.readObject(vt$2); - _servant.bind(p0, p1); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void bind_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - org.apache.geronimo.interop.CosNaming.NamingContext p1 = (org.apache.geronimo.interop.CosNaming.NamingContext) input.readObject(vt$5); - _servant.bind_context(p0, p1); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void rebind(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - org.omg.CORBA.Object p1 = (org.omg.CORBA.Object) input.readObject(vt$2); - _servant.rebind(p0, p1); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void rebind_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - org.apache.geronimo.interop.CosNaming.NamingContext p1 = (org.apache.geronimo.interop.CosNaming.NamingContext) input.readObject(vt$5); - _servant.rebind_context(p0, p1); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void unbind(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - _servant.unbind(p0); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void new_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - org.apache.geronimo.interop.CosNaming.NamingContext rc; - - try { - rc = _servant.new_context(); - output.writeObject(vt$5, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } - - public void bind_new_context(org.apache.geronimo.interop.rmi.iiop.ObjectInputStream input, org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream output) { - org.apache.geronimo.interop.CosNaming.NamingContext rc; - - try { - org.apache.geronimo.interop.CosNaming.NameComponent[] p0 = (org.apache.geronimo.interop.CosNaming.NameComponent[]) input.readObject(vt$1); - rc = _servant.bind_new_context(p0); - output.writeObject(vt$5, rc); - } catch (java.lang.Exception ex) { - ex.printStackTrace(); - } catch (java.lang.Error er) { - er.printStackTrace(); - } - } -} Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java?view=diff&r1=158813&r2=158814 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectHelper.java Wed Mar 23 09:56:34 2005 @@ -17,7 +17,8 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public interface ObjectHelper { +public interface ObjectHelper +{ public Object read(ObjectInputStream input); public void write(ObjectOutputStream output, Object value);