Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRef.java Fri Mar 25 03:54:30 2005 @@ -17,21 +17,23 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import java.util.Hashtable; - -import org.apache.geronimo.interop.IIOP.*; +import org.apache.geronimo.interop.*; +import org.apache.geronimo.interop.rmi.iiop.client.*; import org.apache.geronimo.interop.IOP.*; -import org.apache.geronimo.interop.SystemException; -import org.apache.geronimo.interop.rmi.iiop.client.ClientNamingContext; -import org.apache.geronimo.interop.rmi.iiop.client.Connection; -import org.apache.geronimo.interop.security.SimpleSubject; -import org.apache.geronimo.interop.util.FutureObject; -import org.apache.geronimo.interop.util.ThreadContext; -import org.apache.geronimo.interop.util.UTF8; -import org.apache.geronimo.interop.util.UnsignedShort; - +import org.apache.geronimo.interop.IIOP.*; +import org.apache.geronimo.interop.security.*; +import org.apache.geronimo.interop.util.*; +import java.util.*; + +public class ObjectRef extends CorbaObject +{ + //public static final Component $component = new Component(ObjectRef.class); + + public static ObjectRef _getInstance() + { + return new ObjectRef(); //(ObjectRef)$component.getInstance(); + } -public class ObjectRef implements org.omg.CORBA.Object { // ----------------------------------------------------------------------- // public data // ----------------------------------------------------------------------- @@ -44,19 +46,32 @@ // private data // ----------------------------------------------------------------------- - private static FutureObject _defaultNamingContext = new FutureObject() { - public Object evaluate() { + private static FutureObject _defaultNamingContext = new FutureObject() + { + public Object evaluate() + { Hashtable env = new Hashtable(); return ClientNamingContext.getInstance(env); } }; - private static Version VERSION_1_1 = new Version((byte) 1, (byte) 1); + private static Version VERSION_1_1 = new Version((byte)1, (byte)1); - private static Version VERSION_1_2 = new Version((byte) 1, (byte) 2); + private static Version VERSION_1_2 = new Version((byte)1, (byte)2); private static TaggedComponent[] NO_PROFILE_COMPONENTS = {}; + /* + private static TaggedProfile AUTOMATIC_FAILOVER_PROFILE; + + static + { + AUTOMATIC_FAILOVER_PROFILE = new TaggedProfile(); + AUTOMATIC_FAILOVER_PROFILE.tag = AutomaticFailover.PROFILE_TAG; + AUTOMATIC_FAILOVER_PROFILE.profile_data = ArrayUtil.EMPTY_BYTE_ARRAY; + } + */ + private int _iiopVersion = IIOP_VERSION_1_2; private org.apache.geronimo.interop.IOP.IOR _ior; @@ -73,6 +88,8 @@ private int _port = -1; + //private boolean _automaticFailover; + public byte[] _objectKey; public byte[] _objectState; @@ -80,50 +97,95 @@ public long _objectVersion; // public methods - - public ObjectRef() { + + public ObjectRef() + { + } + + public Connection $connect() + { + try + { + Connection conn = $getNamingContext().getConnectionPool().get(_protocol, $getEndpoint(), this); + conn.beforeInvoke(); + return conn; + } + catch (RuntimeException ex) + { + //if (_automaticFailover) + //{ + // throw new RetryInvokeException(ex); + //} + //else + //{ + throw ex; + //} + } } - public Connection $connect() { - Connection conn = $getNamingContext().getConnectionPool().get(_protocol, $getEndpoint(), this); - conn.beforeInvoke(); - return conn; + /* + public boolean $getAutomaticFailover() + { + return _automaticFailover; + } + */ + + /* + public void $setAutomaticFailover() + { + _automaticFailover = true; } + */ - public int $getIiopVersion() { + public int $getIiopVersion() + { return _iiopVersion; } - public void $setIiopVersion(int version) { + public void $setIiopVersion(int version) + { _iiopVersion = version; } - public String $getID() { - if (_repositoryID == null) { + public String $getID() + { + if (_repositoryID == null) + { return ""; - } else { + } + else + { return _repositoryID; } } - public void $setID(String id) { + public void $setID(String id) + { _repositoryID = id; } - public org.apache.geronimo.interop.IOP.IOR $getIOR() { - if (_ior == null) { + public org.apache.geronimo.interop.IOP.IOR $getIOR() + { + if (_ior == null) + { ProfileBody_1_1 profileBody = new ProfileBody_1_1(); profileBody.iiop_version = _iiopVersion == IIOP_VERSION_1_1 - ? VERSION_1_1 : VERSION_1_2; - if (_host == null || _host.length() == 0) { + ? VERSION_1_1 : VERSION_1_2; + if (_host == null || _host.length() == 0) + { profileBody.host = ThreadContext.getDefaultRmiHost(); - } else { + } + else + { profileBody.host = _host; } - if (_port == -1) { - profileBody.port = (short) ThreadContext.getDefaultRmiPort(); - } else { - profileBody.port = (short) _port; + if (_port == -1) + { + profileBody.port = (short)ThreadContext.getDefaultRmiPort(); + } + else + { + profileBody.port = (short)_port; } profileBody.object_key = _objectKey; // TODO: if protocol using SSL, set port to 0 and set components @@ -137,129 +199,155 @@ IOR ior = new IOR(); ior.type_id = $getID(); - ior.profiles = new TaggedProfile[]{profile}; + ior.profiles = new TaggedProfile[] { profile }; return ior; } return _ior; } - public void $setIOR(org.apache.geronimo.interop.IOP.IOR ior) { + public void $setIOR(org.apache.geronimo.interop.IOP.IOR ior) + { _ior = ior; _endpoint = null; _objectKey = null; $getObjectKey(); // set _protocol, _host, _port, _objectKey } - public ClientNamingContext $getNamingContext() { - if (_namingContext == null) { - _namingContext = (ClientNamingContext) _defaultNamingContext.getValue(); + public ClientNamingContext $getNamingContext() + { + if (_namingContext == null) + { + _namingContext = (ClientNamingContext)_defaultNamingContext.getValue(); } return _namingContext; } - public void $setNamingContext(ClientNamingContext namingContext) { + public void $setNamingContext(ClientNamingContext namingContext) + { _namingContext = namingContext; } - public int $getProtocol() { - if (_objectKey == null) { + public int $getProtocol() + { + if (_objectKey == null) + { $getObjectKey(); // to set _protocol } return _protocol; } - public void $setProtocol(int protocol) { + public void $setProtocol(int protocol) + { _protocol = protocol; _ior = null; } - public String $getHost() { - if (_objectKey == null) { + public String $getHost() + { + if (_objectKey == null) + { $getObjectKey(); // to set _host } return _host; } - public void $setHost(String host) { + public void $setHost(String host) + { _host = host; _endpoint = null; _ior = null; } - public int $getPort() { - if (_objectKey == null) { + public int $getPort() + { + if (_objectKey == null) + { $getObjectKey(); // to set _port } return _port; } - public void $setPort(int port) { + public void $setPort(int port) + { _port = port; _endpoint = null; _ior = null; } - public String $getEndpoint() { - if (_endpoint == null) { + public String $getEndpoint() + { + if (_endpoint == null) + { _endpoint = _host + ":" + _port; } return _endpoint; } - public byte[] $getObjectKey() { - if (_objectKey == null) { - if (_ior == null) { + public byte[] $getObjectKey() + { + if (_objectKey == null) + { + if (_ior == null) + { throw new IllegalStateException("$getObjectKey: _ior == null && _objectKey = null"); } - TaggedProfile profile = _ior.profiles[0]; - if (profile.tag == TAG_INTERNET_IOP.value - && _ior.profiles.length == 1) { - ProfileBody_1_1 profileBody; - CdrInputStream input = CdrInputStream.getInstanceForEncapsulation(); - input.setEncapsulation(profile.profile_data); - profileBody = ProfileBody_1_1Helper.read(input); - input.recycle(); - - _protocol = Protocol.IIOP; // TODO: IIOP/SSL etc. - _iiopVersion = profileBody.iiop_version.minor; - _host = profileBody.host; - _port = UnsignedShort.intValue(profileBody.port); - _objectKey = profileBody.object_key; - } else { - throw new SystemException("TODO"); + int n = _ior.profiles.length; + for (int i = 0; i < n; i++) + { + TaggedProfile profile = _ior.profiles[i]; + if (profile.tag == TAG_INTERNET_IOP.value) + { + ProfileBody_1_1 profileBody; + CdrInputStream input = CdrInputStream.getInstanceForEncapsulation(); + input.setEncapsulation(profile.profile_data); + profileBody = ProfileBody_1_1Helper.read(input); + input.recycle(); + + _protocol = Protocol.IIOP; // TODO: IIOP/SSL etc. + _iiopVersion = profileBody.iiop_version.minor; + _host = profileBody.host; + _port = UnsignedShort.intValue(profileBody.port); + _objectKey = profileBody.object_key; + } } } return _objectKey; } - public String $getObjectKeyString() { + public String $getObjectKeyString() + { return UTF8.toString($getObjectKey()); } - public void $setObjectKey(byte[] objectKey) { + public void $setObjectKey(byte[] objectKey) + { _objectKey = objectKey; _ior = null; } - public void $setObjectKey(String objectKey) { + public void $setObjectKey(String objectKey) + { $setObjectKey(UTF8.fromString(objectKey)); } - public void $setObjectKey(String prefix, byte[] suffixBytes) { + public void $setObjectKey(String prefix, byte[] suffixBytes) + { byte[] prefixBytes = UTF8.fromString(prefix); int p = prefixBytes.length; int s = suffixBytes.length; byte[] objectKey = new byte[p + 1 + s]; System.arraycopy(prefixBytes, 0, objectKey, 0, p); - objectKey[p] = (byte) ':'; + objectKey[p] = (byte)':'; System.arraycopy(suffixBytes, 0, objectKey, p + 1, s); $setObjectKey(objectKey); } - public void $setObjectKey(Class compClass) { + public void $setObjectKey(Class compClass) + { SimpleSubject subject = SimpleSubject.getCurrent(); if (subject != null - && (subject.getFlags() & SimpleSubject.FLAG_SESSION_MANAGER) != 0) { + && (subject.getFlags() & SimpleSubject.FLAG_SESSION_MANAGER) != 0) + { // Initialize for simple IDL interoperability. ObjectKey objectKey = new ObjectKey(); objectKey.component = compClass.getName(); @@ -269,86 +357,16 @@ key[0] = 'I'; _iiopVersion = IIOP_VERSION_1_1; $setObjectKey(key); - } else { + } + else + { // Initialize for RMI-IIOP. $setObjectKey(compClass.getName()); } } - public String[] _ids() { - String[] ids = - { - "" //_type - } - ; - return ids; - } - - public Object $getRequestKey() { - // - //if (_automaticFailover) - //{ - // return $getNamingContext().getRequestKey(); - //} - //else - //{ + public Object $getRequestKey() + { return null; - //} - } - - public boolean _is_a(String id) { - return false; - } - - // ----------------------------------------------------------------------- - // unimplemented public methods (only required for full CORBA ORB) - // ----------------------------------------------------------------------- - - 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/ObjectRefHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/ObjectRefHelper.java Fri Mar 25 03:54:30 2005 @@ -17,25 +17,39 @@ */ package org.apache.geronimo.interop.rmi.iiop; +import org.apache.geronimo.interop.*; +import org.apache.geronimo.interop.IOP.*; - - -public class ObjectRefHelper implements ObjectHelper { - public static ObjectRefHelper getInstance(Class theClass) { +public class ObjectRefHelper implements ObjectHelper +{ + public static ObjectRefHelper getInstance(Class theClass) + { return new ObjectRefHelper(); } - public Object read(ObjectInputStream input) { + public Object read(ObjectInputStream input) + { return input._cdrInput.read_Object(); } - public void write(ObjectOutputStream output, Object value) { - if (value == null || value instanceof ObjectRef) { - output._cdrOutput.write_Object((org.omg.CORBA.Object) value); - } else if (value instanceof RemoteInterface) { - RemoteInterface remote = (RemoteInterface) value; - output._cdrOutput.write_Object((org.omg.CORBA.Object) remote.$getObjectRef()); - } else { + public void write(ObjectOutputStream output, Object value) + { + if (value == null || value instanceof ObjectRef) + { + output._cdrOutput.write_Object((org.omg.CORBA.Object)value); + } + else if (value instanceof RemoteInterface) + { + RemoteInterface remote = (RemoteInterface)value; + ObjectRef objectRef = remote.getObjectRef(); + //if (value instanceof AutomaticFailover) + //{ + // objectRef.$setAutomaticFailover(); + //} + output._cdrOutput.write_Object(objectRef); + } + else + { throw new IllegalArgumentException("class = " + value.getClass()); } } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/PrimitiveType.java Fri Mar 25 03:54:30 2005 @@ -17,23 +17,26 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import org.apache.geronimo.interop.util.ArrayUtil; +import org.apache.geronimo.interop.util.*; - -public class PrimitiveType { +public class PrimitiveType +{ public static final int BOOLEAN = 1; - public static final int BYTE = 2; - public static final int CHAR = 3; - public static final int DOUBLE = 4; - public static final int FLOAT = 5; - public static final int INT = 6; - public static final int LONG = 7; - public static final int SHORT = 8; - - public static final ObjectHelper BOOLEAN_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final int BYTE = 2; + public static final int CHAR = 3; + public static final int DOUBLE = 4; + public static final int FLOAT = 5; + public static final int INT = 6; + public static final int LONG = 7; + public static final int SHORT = 8; + + public static final ObjectHelper BOOLEAN_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_BOOLEAN_ARRAY; } boolean[] array = new boolean[n]; @@ -41,19 +44,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - boolean[] array = (boolean[]) value; + public void write(ObjectOutputStream output, Object value) + { + boolean[] array = (boolean[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_boolean_array(array, 0, n); } } - ; + ; - public static final ObjectHelper BYTE_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper BYTE_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_BYTE_ARRAY; } byte[] array = new byte[n]; @@ -61,19 +68,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - byte[] array = (byte[]) value; + public void write(ObjectOutputStream output, Object value) + { + byte[] array = (byte[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_octet_array(array, 0, n); } } - ; + ; - public static final ObjectHelper CHAR_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper CHAR_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_CHAR_ARRAY; } char[] array = new char[n]; @@ -81,19 +92,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - char[] array = (char[]) value; + public void write(ObjectOutputStream output, Object value) + { + char[] array = (char[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_char_array(array, 0, n); } } - ; + ; - public static final ObjectHelper DOUBLE_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper DOUBLE_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_DOUBLE_ARRAY; } double[] array = new double[n]; @@ -101,19 +116,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - double[] array = (double[]) value; + public void write(ObjectOutputStream output, Object value) + { + double[] array = (double[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_double_array(array, 0, n); } } - ; + ; - public static final ObjectHelper FLOAT_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper FLOAT_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_FLOAT_ARRAY; } float[] array = new float[n]; @@ -121,19 +140,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - float[] array = (float[]) value; + public void write(ObjectOutputStream output, Object value) + { + float[] array = (float[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_float_array(array, 0, n); } } - ; + ; - public static final ObjectHelper INT_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper INT_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_INT_ARRAY; } int[] array = new int[n]; @@ -141,19 +164,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - int[] array = (int[]) value; + public void write(ObjectOutputStream output, Object value) + { + int[] array = (int[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_long_array(array, 0, n); } } - ; + ; - public static final ObjectHelper LONG_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper LONG_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_LONG_ARRAY; } long[] array = new long[n]; @@ -161,19 +188,23 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - long[] array = (long[]) value; + public void write(ObjectOutputStream output, Object value) + { + long[] array = (long[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_longlong_array(array, 0, n); } } - ; + ; - public static final ObjectHelper SHORT_ARRAY_HELPER = new ObjectHelper() { - public Object read(ObjectInputStream input) { + public static final ObjectHelper SHORT_ARRAY_HELPER = new ObjectHelper() + { + public Object read(ObjectInputStream input) + { int n = input._cdrInput.read_long(); - if (n == 0) { + if (n == 0) + { return ArrayUtil.EMPTY_SHORT_ARRAY; } short[] array = new short[n]; @@ -181,61 +212,100 @@ return array; } - public void write(ObjectOutputStream output, Object value) { - short[] array = (short[]) value; + public void write(ObjectOutputStream output, Object value) + { + short[] array = (short[])value; int n = array.length; output._cdrOutput.write_long(n); output._cdrOutput.write_short_array(array, 0, n); } } - ; + ; - public static int get(Class _class) { - if (_class == boolean.class) { + public static int get(Class _class) + { + if (_class == boolean.class) + { return BOOLEAN; - } else if (_class == byte.class) { + } + else if (_class == byte.class) + { return BYTE; - } else if (_class == char.class) { + } + else if (_class == char.class) + { return CHAR; - } else if (_class == double.class) { + } + else if (_class == double.class) + { return DOUBLE; - } else if (_class == float.class) { + } + else if (_class == float.class) + { return FLOAT; - } else if (_class == int.class) { + } + else if (_class == int.class) + { return INT; - } else if (_class == long.class) { + } + else if (_class == long.class) + { return LONG; - } else if (_class == short.class) { + } + else if (_class == short.class) + { return SHORT; - } else { - throw new IllegalArgumentException("class = " + _class.getName()); + } + else + { + throw new IllegalArgumentException("class = " +_class.getName()); } } - public static ObjectHelper getArrayHelper(Class _class) { - if (_class == boolean.class) { + public static ObjectHelper getArrayHelper(Class _class) + { + if (_class == boolean.class) + { return BOOLEAN_ARRAY_HELPER; - } else if (_class == byte.class) { + } + else if (_class == byte.class) + { return BYTE_ARRAY_HELPER; - } else if (_class == char.class) { + } + else if (_class == char.class) + { return CHAR_ARRAY_HELPER; - } else if (_class == double.class) { + } + else if (_class == double.class) + { return DOUBLE_ARRAY_HELPER; - } else if (_class == float.class) { + } + else if (_class == float.class) + { return FLOAT_ARRAY_HELPER; - } else if (_class == int.class) { + } + else if (_class == int.class) + { return INT_ARRAY_HELPER; - } else if (_class == long.class) { + } + else if (_class == long.class) + { return LONG_ARRAY_HELPER; - } else if (_class == short.class) { + } + else if (_class == short.class) + { return SHORT_ARRAY_HELPER; - } else { - throw new IllegalArgumentException("class = " + _class.getName()); + } + else + { + throw new IllegalArgumentException("class = " +_class.getName()); } } - public static org.omg.CORBA.TypeCode getTypeCode(int p) { - switch (p) { + public static org.omg.CORBA.TypeCode getTypeCode(int p) + { + switch (p) + { case BOOLEAN: return TypeCode.BOOLEAN; case BYTE: // java byte is IDL octet Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/Protocol.java Fri Mar 25 03:54:30 2005 @@ -17,52 +17,57 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public abstract class Protocol { - public static final int IIOP = 1; +public abstract class Protocol +{ + public static final int IIOP = 1; public static final int IIOPS = 2; - public static final int HTTP = 3; + public static final int HTTP = 3; public static final int HTTPS = 4; - public static String getName(int protocol) { - switch (protocol) { - case IIOP: - return "iiop"; - case IIOPS: - return "iiop"; - case HTTP: - return "http"; - case HTTPS: - return "https"; - default: - throw new IllegalArgumentException("protocol = " + protocol); + public static String getName(int protocol) + { + switch (protocol) + { + case IIOP: return "iiop"; + case IIOPS: return "iiop"; + case HTTP: return "http"; + case HTTPS: return "https"; + default: throw new IllegalArgumentException("protocol = " + protocol); } } - public static String getScheme(int protocol) { - switch (protocol) { - case IIOP: - return "iiop:"; - case IIOPS: - return "iiop:"; - case HTTP: - return "http:"; - case HTTPS: - return "https:"; - default: - throw new IllegalArgumentException("protocol = " + protocol); + public static String getScheme(int protocol) + { + switch (protocol) + { + case IIOP: return "iiop:"; + case IIOPS: return "iiop:"; + case HTTP: return "http:"; + case HTTPS: return "https:"; + default: throw new IllegalArgumentException("protocol = " + protocol); } } - public static int getNumber(String protocol) { - if (protocol.equals("iiop")) { + public static int getNumber(String protocol) + { + if (protocol.equals("iiop")) + { return IIOP; - } else if (protocol.equals("iiops")) { + } + else if (protocol.equals("iiops")) + { return IIOPS; - } else if (protocol.equals("http")) { + } + else if (protocol.equals("http")) + { return HTTP; - } else if (protocol.equals("https")) { + } + else if (protocol.equals("https")) + { return HTTPS; - } else { + } + else + { throw new IllegalArgumentException("protocol = " + protocol); } } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteInterface.java Fri Mar 25 03:54:30 2005 @@ -17,10 +17,11 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public interface RemoteInterface { - public ObjectRef $getObjectRef(); - - public RemoteInterface $getSkeleton(); +import org.apache.geronimo.interop.adapter.Adapter; - public void $invoke(String method, byte[] objectKey, Object instance, ObjectInputStream input, ObjectOutputStream output); +public interface RemoteInterface { + public ObjectRef getObjectRef(); +// public RemoteInterface $getSkeleton(); + public void invoke(String method, byte[] objectKey, Adapter adapter, ObjectInputStream input, ObjectOutputStream output); +// public void $invoke(String method, byte[] objectKey, ObjectInputStream input, ObjectOutputStream output); } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/RemoteObject.java Fri Mar 25 03:54:30 2005 @@ -17,14 +17,32 @@ */ package org.apache.geronimo.interop.rmi.iiop; +import org.apache.geronimo.interop.adapter.Adapter; + +import java.util.HashMap; + public abstract class RemoteObject { - public RemoteObject() { + + protected HashMap methods = new HashMap(10); + + public RemoteObject( ) { + registerMethods(); } protected void registerMethods() { registerMethod("_is_a", -1); } + protected void registerMethod( String methodName, int id ) + { + methods.put( methodName, new Integer(id) ); + } + + protected Integer getMethodId( String methodName ) + { + return (Integer)methods.get( methodName ); + } + public void invoke(int id, byte[] objectKey, Object instance, ObjectInputStream input, ObjectOutputStream output) { switch (id) { case -1: @@ -53,6 +71,4 @@ } public abstract String[] getIds(); - - public abstract void registerMethod(String name, int id); } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SecurityInfo.java Fri Mar 25 03:54:30 2005 @@ -36,26 +36,20 @@ (byte) 'P', (byte) 'A', (byte) 'S', (byte) 'S' }); - public static Random _seedFactory = new Random(); + public static Random seedFactory = new Random(); + public String username; + public String password; - public String username; - - public String password; - - // private data - - private static ThreadLocal _current = new ThreadLocal(); + private static ThreadLocal current = new ThreadLocal(); public static SecurityInfo getCurrent() { - return (SecurityInfo) _current.get(); + return (SecurityInfo) current.get(); } public static void setCurrent(SecurityInfo info) { - _current.set(info); + current.set(info); } - // TODO: delegate to use DataProtection class - /** * * Encode a username or password to prevent accidental disclosure * * by packet sniffers etc. The intention is not to provide strong @@ -66,7 +60,7 @@ * * similar requirements in Random.java. */ public static byte[] encode(String plainText) { - int seed = _seedFactory.nextInt(); // data race, but we don't care + int seed = seedFactory.nextInt(); // data race, but we don't care Random random = new Random(seed); byte[] utf8 = UTF8.fromString(plainText); int n = utf8.length; Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectInputStream.java Fri Mar 25 03:54:30 2005 @@ -17,56 +17,84 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import java.io.IOException; - -import org.apache.geronimo.interop.SystemException; -import org.apache.geronimo.interop.util.JavaObject; - - -public class SimpleObjectInputStream extends ObjectInputStream { - public static ObjectInputStream getInstance() { - return getInstance(CdrInputStream.getInstance()); +import org.apache.geronimo.interop.*; +import org.apache.geronimo.interop.rmi.*; +import org.apache.geronimo.interop.util.*; +import java.io.*; + +public class SimpleObjectInputStream extends ObjectInputStream +{ + //public static final Component component = new Component(SimpleObjectInputStream.class); + + public static ObjectInputStream getInstance() + { + ObjectInputStream ois = null; + try { + ois = new SimpleObjectInputStream(); + } catch (IOException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + return ois; // getInstance(CdrInputStream.getInstance()); } - public static ObjectInputStream getInstance(byte[] bytes) { + public static ObjectInputStream getInstance(byte[] bytes) + { return getInstance(CdrInputStream.getInstance(bytes)); } - public static ObjectInputStream getInstance(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) { - ObjectInputStream input = null; - try { - input = new SimpleObjectInputStream(); - } catch (Exception ex) { - throw new SystemException(ex); - } - + public static ObjectInputStream getInstance(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) + { + ObjectInputStream input = getInstance(); // (SimpleObjectInputStream)component.getInstance(); input.init(cdrInput); return input; } + public static ObjectInputStream getPooledInstance() + { + ObjectInputStream input = null; // (SimpleObjectInputStream)_pool.get(); + if (input == null) + { + input = getInstance(); + } + return input; + } + // ----------------------------------------------------------------------- // private data // ----------------------------------------------------------------------- + //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(SimpleObjectInputStream.class.getName()); + // ----------------------------------------------------------------------- // public methods // ----------------------------------------------------------------------- - public SimpleObjectInputStream() throws IOException { + public SimpleObjectInputStream() throws IOException + { super(); } - public void $reset() { + public void $reset() + { _cdrInput.reset(); } - public void recycle() { + public void recycle() + { $reset(); + //_pool.put(this); + } + + public Exception readException(ValueType type) + { + return (Exception)readObject(type); } - public Object readObject(ValueType type) { + public Object readObject(ValueType type) + { ObjectHelper h = type.helper; - if (h != null) { + if (h != null) + { return h.read(this); } byte[] bytes = _cdrInput.read_octet_sequence(); @@ -78,7 +106,8 @@ // protected methods // ----------------------------------------------------------------------- - protected void init(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) { + protected void init(org.apache.geronimo.interop.rmi.iiop.CdrInputStream cdrInput) + { super.init(cdrInput); } } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/SimpleObjectOutputStream.java Fri Mar 25 03:54:30 2005 @@ -17,53 +17,82 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import java.io.IOException; - -import org.apache.geronimo.interop.SystemException; -import org.apache.geronimo.interop.util.ArrayUtil; -import org.apache.geronimo.interop.util.JavaObject; - - -public class SimpleObjectOutputStream extends ObjectOutputStream { - public static ObjectOutputStream getInstance() { - return getInstance(CdrOutputStream.getInstance()); - } - - public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) { - ObjectOutputStream output = null; +import org.apache.geronimo.interop.*; +import org.apache.geronimo.interop.rmi.*; +import org.apache.geronimo.interop.util.*; +import java.io.*; + +public class SimpleObjectOutputStream extends ObjectOutputStream +{ + //public static final Component component = new Component(SimpleObjectOutputStream.class); + + public static ObjectOutputStream getInstance() + { + ObjectOutputStream oos = null; try { - output = new SimpleObjectOutputStream(); - } catch (Exception ex) { - throw new SystemException(ex); + oos = new SimpleObjectOutputStream(); + } catch (IOException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } + return oos; // getInstance(CdrOutputStream.getInstance()); + } + public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) + { + ObjectOutputStream output = getInstance(); // (SimpleObjectOutputStream)component.getInstance(); output.init(cdrOutput); return output; } + public static ObjectOutputStream getPooledInstance() + { + ObjectOutputStream output = null; // (SimpleObjectOutputStream)_pool.get(); + if (output == null) + { + output = getInstance(); + } + return output; + } + // ----------------------------------------------------------------------- // private data // ----------------------------------------------------------------------- + //private static ThreadLocalInstancePool _pool = new ThreadLocalInstancePool(SimpleObjectOutputStream.class.getName()); + // ----------------------------------------------------------------------- // public methods // ----------------------------------------------------------------------- - public SimpleObjectOutputStream() throws IOException { + public SimpleObjectOutputStream() throws IOException + { super(); } - public void $reset() { + public void $reset() + { _cdrOutput.reset(); } - public void recycle() { + public void recycle() + { $reset(); + //_pool.put(this); + } + + public void writeException(ValueType type, Exception value) + { + String repositoryID = "IDL:" + type._class.getName().replace('.', '/') + ":1.0"; + _cdrOutput.write_string(repositoryID); + writeObject(type, value); + _hasException = true; } - public void writeObject(ValueType type, Object value) { + public void writeObject(ValueType type, Object value) + { ObjectHelper h = type.helper; - if (h != null) { + if (h != null) + { h.write(this, value); return; } @@ -76,7 +105,8 @@ // protected methods // ----------------------------------------------------------------------- - protected void init(CdrOutputStream cdrOutput) { + protected void init(CdrOutputStream cdrOutput) + { super.init(cdrOutput); } } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringHelper.java Fri Mar 25 03:54:30 2005 @@ -17,14 +17,17 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public class StringHelper implements ObjectHelper { +public class StringHelper implements ObjectHelper +{ public static final StringHelper SINGLETON = new StringHelper(); - public Object read(ObjectInputStream input) { + public Object read(ObjectInputStream input) + { return input._cdrInput.read_string(); } - public void write(ObjectOutputStream output, Object value) { - output._cdrOutput.write_string((String) value); + public void write(ObjectOutputStream output, Object value) + { + output._cdrOutput.write_string((String)value); } } Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHelper.java?view=auto&rev=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHelper.java (added) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHelper.java Fri Mar 25 03:54:30 2005 @@ -0,0 +1,109 @@ +/** + * + * 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; + +/** + ** Generated by Sybase EAServer 5.0 - Thu Nov 04 15:51:10 NZDT 2004 + ** + ** from com::sybase::djc::rmi::iiop::StringSeq (file C:/easme/build/idl/com-sybase-djc-rmi-iiop.idl, line 13). + ** + ** Please do not modify this file. + **/ + +public abstract class StringSeqHelper +{ + public static java.lang.String[] clone + (java.lang.String[] _value) + { + if (_value == null) + { + return null; + } + int _16 = _value.length; + java.lang.String[] _clone = new java.lang.String[_16]; + for (int _17 = 0; _17 < _16; _17++) + { + _clone[_17] = _value[_17]; + } + return _clone; + } + + public static java.lang.String[] read + (org.omg.CORBA.portable.InputStream _input) + { + int _18 = _input.read_ulong(); + java.lang.String[] value = new java.lang.String[_18]; + for (int _19 = 0; _19 < _18; _19++) + { + value[_19] = _input.read_string(); + } + return value; + } + + public static void write + (org.omg.CORBA.portable.OutputStream _output, + java.lang.String[] value) + { + if (value == null) + { + value = new java.lang.String[0]; + } + int _20 = value.length; + _output.write_ulong(_20); + for (int _21 = 0; _21 < _20; _21++) + { + _output.write_string(value[_21]); + } + } + + public static org.omg.CORBA.TypeCode _type; + + public static org.omg.CORBA.TypeCode type() + { + if (_type == null) + { + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); + _type = orb.create_sequence_tc(0, orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string)); + } + return _type; + } + + public static void insert + (org.omg.CORBA.Any any, + java.lang.String[] value) + { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + + public static java.lang.String[] extract + (org.omg.CORBA.Any any) + { + if (! any.type().equal(type())) + { + throw new org.omg.CORBA.BAD_OPERATION(); + } + return read(any.create_input_stream()); + } + + public static java.lang.String id() + { + return "IDL:com/sybase/djc/rmi/iiop/StringSeq:1.0"; + } +} Added: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHolder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHolder.java?view=auto&rev=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHolder.java (added) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringSeqHolder.java Fri Mar 25 03:54:30 2005 @@ -0,0 +1,58 @@ +/** + * + * 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; + +/** + ** Generated by Sybase EAServer 5.0 - Thu Nov 04 15:51:10 NZDT 2004 + ** + ** from com::sybase::djc::rmi::iiop::StringSeq (file C:/easme/build/idl/com-sybase-djc-rmi-iiop.idl, line 13). + ** + ** Please do not modify this file. + **/ + +public final class StringSeqHolder implements org.omg.CORBA.portable.Streamable +{ + public java.lang.String[] value; + + public StringSeqHolder() + { + } + + public StringSeqHolder + (java.lang.String[] _value) + { + value = _value; + } + + public org.omg.CORBA.TypeCode _type() + { + return org.apache.geronimo.interop.rmi.iiop.StringSeqHelper.type(); + } + + public void _read + (org.omg.CORBA.portable.InputStream _input) + { + value = org.apache.geronimo.interop.rmi.iiop.StringSeqHelper.read(_input); + } + + public void _write + (org.omg.CORBA.portable.OutputStream _output) + { + org.apache.geronimo.interop.rmi.iiop.StringSeqHelper.write(_output, value); + } +} Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/StringValueHelper.java Fri Mar 25 03:54:30 2005 @@ -17,14 +17,17 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public class StringValueHelper implements ObjectHelper { +public class StringValueHelper implements ObjectHelper +{ public static final StringValueHelper SINGLETON = new StringValueHelper(); - public Object read(ObjectInputStream input) { + public Object read(ObjectInputStream input) + { return input._cdrInput.read_string(); } - public void write(ObjectOutputStream output, Object value) { - output._cdrOutput.write_string((String) value); + public void write(ObjectOutputStream output, Object value) + { + output._cdrOutput.write_string((String)value); } } Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/TypeCode.java Fri Mar 25 03:54:30 2005 @@ -21,34 +21,55 @@ import org.omg.CORBA.TypeCodePackage.BadKind; import org.omg.CORBA.TypeCodePackage.Bounds; - /** * * An implementation of CORBA 'TypeCode' for use with RMI-IIOP. */ -public class TypeCode extends org.omg.CORBA.TypeCode { +public class TypeCode + extends org.omg.CORBA.TypeCode +{ // ----------------------------------------------------------------------- // public data // ----------------------------------------------------------------------- public static final TypeCode NULL = new TypeCode(TCKind.tk_null); + public static final TypeCode VOID = new TypeCode(TCKind.tk_void); + public static final TypeCode ANY = new TypeCode(TCKind.tk_any); + public static final TypeCode BOOLEAN = new TypeCode(TCKind.tk_boolean); + public static final TypeCode CHAR = new TypeCode(TCKind.tk_char); + public static final TypeCode WCHAR = new TypeCode(TCKind.tk_wchar); + public static final TypeCode OCTET = new TypeCode(TCKind.tk_octet); + public static final TypeCode SHORT = new TypeCode(TCKind.tk_short); + public static final TypeCode USHORT = new TypeCode(TCKind.tk_ushort); + public static final TypeCode LONG = new TypeCode(TCKind.tk_long); + public static final TypeCode ULONG = new TypeCode(TCKind.tk_ulong); + public static final TypeCode LONGLONG = new TypeCode(TCKind.tk_longlong); + public static final TypeCode ULONGLONG = new TypeCode(TCKind.tk_ulonglong); + public static final TypeCode FLOAT = new TypeCode(TCKind.tk_float); + public static final TypeCode DOUBLE = new TypeCode(TCKind.tk_double); - public static final TypeCode LONGDOUBLE = new TypeCode(TCKind.tk_longdouble); + + public static final TypeCode LONGDOUBLE = new TypeCode( + TCKind.tk_longdouble); + public static final TypeCode STRING = new TypeCode(TCKind.tk_string); + public static final TypeCode WSTRING = new TypeCode(TCKind.tk_wstring); + public static final TypeCode OBJREF = new TypeCode(TCKind.tk_objref); + public static final TypeCode TYPECODE = new TypeCode(TCKind.tk_TypeCode); // ----------------------------------------------------------------------- @@ -95,10 +116,12 @@ /** * @param kind */ - public TypeCode(TCKind kind) { + public TypeCode(TCKind kind) + { _kind = kind; _default = -1; - if (kind.value() == TCKind._tk_objref) { + if (kind.value() == TCKind._tk_objref) + { _type = "Object"; } } @@ -107,60 +130,84 @@ * @param tc * @return */ - public boolean equal(org.omg.CORBA.TypeCode tc) { - if (_indirection) { + public boolean equal(org.omg.CORBA.TypeCode tc) + { + if (_indirection) + { return _ref.equal(tc); } - try { + try + { int tk = _kind.value(); - if (tk != tc.kind().value()) { + if (tk != tc.kind().value()) + { return false; } // TODO: compare id() - if (_member_name != null) { + if (_member_name != null) + { int n = _member_name.length; - if (n != tc.member_count()) { + if (n != tc.member_count()) + { return false; } - for (int i = 0; i < n; i++) { - if (!equalIfNotEmpty(member_name(i), tc.member_name(i))) { + for (int i = 0; i < n; i++) + { + if (!equalIfNotEmpty(member_name(i), tc.member_name(i))) + { return false; } - if (!member_type(i).equal(tc.member_type(i))) { + if (!member_type(i).equal(tc.member_type(i))) + { return false; } } } - if (tk == TCKind._tk_union) { - if (!discriminator_type().equal(tc.discriminator_type())) { + if (tk == TCKind._tk_union) + { + if (!discriminator_type().equal(tc.discriminator_type())) + { return false; } int n = _member_name.length; - for (int i = 0; i < n; i++) { - if (!member_label(i).equal(tc.member_label(i))) { + for (int i = 0; i < n; i++) + { + if (!member_label(i).equal(tc.member_label(i))) + { return false; } } } if (tk == TCKind._tk_array - || tk == TCKind._tk_sequence - || tk == TCKind._tk_string - || tk == TCKind._tk_wstring) { - if (length() != tc.length()) { + || + tk == TCKind._tk_sequence + || + tk == TCKind._tk_string + || tk == TCKind._tk_wstring) + { + if (length() != tc.length()) + { return false; } } if (tk == TCKind._tk_alias - || tk == TCKind._tk_array - || tk == TCKind._tk_sequence) { - if (!content_type().equal(tc.content_type())) { + || + tk == TCKind._tk_array + || tk == TCKind._tk_sequence) + { + if (!content_type().equal(tc.content_type())) + { return false; } } return true; - } catch (org.omg.CORBA.TypeCodePackage.BadKind ex) { + } + catch (org.omg.CORBA.TypeCodePackage.BadKind ex) + { throw new org.omg.CORBA.UNKNOWN(ex.toString()); - } catch (org.omg.CORBA.TypeCodePackage.Bounds ex) { + } + catch (org.omg.CORBA.TypeCodePackage.Bounds ex) + { throw new org.omg.CORBA.UNKNOWN(ex.toString()); } } @@ -170,14 +217,16 @@ * @return */ public boolean equivalent - (org.omg.CORBA.TypeCode tc) { + (org.omg.CORBA.TypeCode tc) + { throw new org.omg.CORBA.NO_IMPLEMENT(); } /** * @return */ - public org.omg.CORBA.TypeCode get_compact_typecode() { + public org.omg.CORBA.TypeCode get_compact_typecode() + { throw new org.omg.CORBA.NO_IMPLEMENT(); } @@ -186,10 +235,14 @@ * @param b * @return */ - private boolean equalIfNotEmpty(String a, String b) { - if (a.length() == 0 || b.length() == 0) { + private boolean equalIfNotEmpty(String a, String b) + { + if (a.length() == 0 || b.length() == 0) + { return true; - } else { + } + else + { return a.equals(b); } } @@ -197,8 +250,10 @@ /** * @return */ - public TCKind kind() { - if (_indirection) { + public TCKind kind() + { + if (_indirection) + { return _ref.kind(); } return _kind; @@ -209,14 +264,18 @@ * @throws BadKind */ public String id() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.id(); } - if (_id != null) { + if (_id != null) + { return _id; } - if (_type != null && _type.equals("Object")) { + if (_type != null && _type.equals("Object")) + { return ""; } return default_id(); @@ -226,19 +285,25 @@ /** * @param id */ - public void id(String id) { - if (!id.equals("")) { + public void id(String id) + { + if (!id.equals("")) + { _id = id; - if (id.startsWith("IDL:") && id.endsWith(":1.0")) { + if (id.startsWith("IDL:") && id.endsWith(":1.0")) + { // Infer _type field from standard IDL format _id id = id.substring(4, id.length() - 4); - if (id.startsWith("omg.org/")) { + if (id.startsWith("omg.org/")) + { id = id.substring(8); } _type = ""; - for (; ;) { + for (; ;) + { int slash = id.indexOf('/'); - if (slash == -1) { + if (slash == -1) + { break; } _type = _type + id.substring(0, slash) + "::"; @@ -254,8 +319,10 @@ * @throws BadKind */ public String name() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.name(); } /* TODO? @@ -264,7 +331,8 @@ _name = (String)_names.get(new Integer(_kind.value())); } */ - if (_name == null) { + if (_name == null) + { throw new BadKind(); } return _name; @@ -274,7 +342,8 @@ /** * @param name */ - public void name(String name) { + public void name(String name) + { _name = name; } @@ -283,11 +352,14 @@ * @throws BadKind */ public int member_count() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.member_count(); } - if (_member_name == null) { + if (_member_name == null) + { throw new BadKind(); } return _member_name.length; @@ -297,13 +369,16 @@ /** * @param count */ - public void member_count(int count) { + public void member_count(int count) + { _member_name = new String[count]; _member_type = new org.omg.CORBA.TypeCode[count]; - if (_kind.value() == TCKind._tk_union) { + if (_kind.value() == TCKind._tk_union) + { _member_label = new org.omg.CORBA.Any[count]; } - if (_kind.value() == TCKind._tk_value) { + if (_kind.value() == TCKind._tk_value) + { _member_visibility = new short[count]; } } @@ -315,14 +390,18 @@ * @throws Bounds */ public String member_name(int index) - throws BadKind, Bounds { - if (_indirection) { + throws BadKind, Bounds + { + if (_indirection) + { return _ref.member_name(index); } - if (_member_name == null) { + if (_member_name == null) + { throw new BadKind(); } - if (index < 0 || index >= _member_name.length) { + if (index < 0 || index >= _member_name.length) + { throw new Bounds(); } return _member_name[index]; @@ -333,7 +412,8 @@ * @param index * @param name */ - public void member_name(int index, String name) { + public void member_name(int index, String name) + { _member_name[index] = name; } @@ -344,14 +424,18 @@ * @throws Bounds */ public org.omg.CORBA.TypeCode member_type(int index) - throws BadKind, Bounds { - if (_indirection) { + throws BadKind, Bounds + { + if (_indirection) + { return _ref.member_type(index); } - if (_member_type == null) { + if (_member_type == null) + { throw new BadKind(); } - if (index < 0 || index >= _member_type.length) { + if (index < 0 || index >= _member_type.length) + { throw new Bounds(); } return _member_type[index]; @@ -362,7 +446,8 @@ * @param index * @param type */ - public void member_type(int index, org.omg.CORBA.TypeCode type) { + public void member_type(int index, org.omg.CORBA.TypeCode type) + { _member_type[index] = type; } @@ -373,14 +458,18 @@ * @throws Bounds */ public org.omg.CORBA.Any member_label(int index) - throws BadKind, Bounds { - if (_indirection) { + throws BadKind, Bounds + { + if (_indirection) + { return _ref.member_label(index); } - if (_member_label == null) { + if (_member_label == null) + { throw new BadKind(); } - if (index < 0 || index >= _member_label.length) { + if (index < 0 || index >= _member_label.length) + { throw new Bounds(); } return _member_label[index]; @@ -391,7 +480,8 @@ * @param index * @param label */ - public void member_label(int index, org.omg.CORBA.Any label) { + public void member_label(int index, org.omg.CORBA.Any label) + { _member_label[index] = label; } @@ -400,12 +490,15 @@ * @throws BadKind */ public org.omg.CORBA.TypeCode discriminator_type() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.discriminator_type(); } if (_ref == null - || _kind.value() != TCKind._tk_union) { + || _kind.value() != TCKind._tk_union) + { throw new BadKind(); } return _ref; @@ -415,7 +508,8 @@ /** * @param disc */ - public void discriminator_type(org.omg.CORBA.TypeCode disc) { + public void discriminator_type(org.omg.CORBA.TypeCode disc) + { _ref = disc; } @@ -424,11 +518,14 @@ * @throws BadKind */ public int default_index() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.default_index(); } - if (_kind.value() != TCKind._tk_union) { + if (_kind.value() != TCKind._tk_union) + { throw new BadKind(); } return _default; @@ -438,9 +535,11 @@ /** * @param index */ - public void default_index(int index) { + public void default_index(int index) + { _default = index; - if (index != -1) { + if (index != -1) + { // We must store the member label for the discriminator type // as some legal value, so we use zero. _member_label[index] = new Any(_ref, "0"); @@ -452,13 +551,17 @@ * @throws BadKind */ public int length() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.length(); } int tk = _kind.value(); - if (tk != TCKind._tk_string && tk != TCKind._tk_wstring - && tk != TCKind._tk_sequence && tk != TCKind._tk_array) { + if (tk != TCKind._tk_string && + tk != TCKind._tk_wstring + && tk != TCKind._tk_sequence && tk != TCKind._tk_array) + { throw new BadKind(); } return _length; @@ -468,7 +571,8 @@ /** * @param length */ - public void length(int length) { + public void length(int length) + { _length = length; } @@ -477,16 +581,21 @@ * @throws BadKind */ public org.omg.CORBA.TypeCode content_type() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.content_type(); } int tk = _kind.value(); if (_ref == null || (tk != TCKind._tk_alias - && tk != TCKind._tk_array - && tk != TCKind._tk_sequence - && tk != TCKind._tk_value_box)) { + && + tk != TCKind._tk_array + && + tk != TCKind._tk_sequence + && tk != TCKind._tk_value_box)) + { throw new BadKind(); } return _ref; @@ -496,7 +605,8 @@ /** * @param type */ - public void content_type(org.omg.CORBA.TypeCode type) { + public void content_type(org.omg.CORBA.TypeCode type) + { _ref = type; } @@ -505,12 +615,15 @@ * @throws BadKind */ public short fixed_digits() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.fixed_digits(); } int tk = _kind.value(); - if (tk != TCKind._tk_fixed) { + if (tk != TCKind._tk_fixed) + { throw new BadKind(); } return _digits; @@ -520,7 +633,8 @@ /** * @param digits */ - public void fixed_digits(short digits) { + public void fixed_digits(short digits) + { _digits = digits; } @@ -529,12 +643,15 @@ * @throws BadKind */ public short fixed_scale() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.fixed_scale(); } int tk = _kind.value(); - if (tk != TCKind._tk_fixed) { + if (tk != TCKind._tk_fixed) + { throw new BadKind(); } return _scale; @@ -544,7 +661,8 @@ /** * @param scale */ - public void fixed_scale(short scale) { + public void fixed_scale(short scale) + { _scale = scale; } @@ -555,15 +673,19 @@ * @throws Bounds */ public short member_visibility - (int index) - throws BadKind, Bounds { - if (_indirection) { + (int index) + throws BadKind, Bounds + { + if (_indirection) + { return _ref.member_visibility(index); } - if (_member_type == null) { + if (_member_type == null) + { throw new BadKind(); } - if (index < 0 || index >= _member_visibility.length) { + if (index < 0 || index >= _member_visibility.length) + { throw new Bounds(); } return _member_visibility[index]; @@ -574,7 +696,8 @@ * @param index * @param visibility */ - public void member_visibility(int index, short visibility) { + public void member_visibility(int index, short visibility) + { _member_visibility[index] = visibility; } @@ -583,12 +706,15 @@ * @throws BadKind */ public short type_modifier() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.type_modifier(); } int tk = _kind.value(); - if (tk != TCKind._tk_value) { + if (tk != TCKind._tk_value) + { throw new BadKind(); } return _type_modifier; @@ -598,7 +724,8 @@ /** * @param modifier */ - public void type_modifier(short modifier) { + public void type_modifier(short modifier) + { _type_modifier = modifier; } @@ -607,12 +734,15 @@ * @throws BadKind */ public org.omg.CORBA.TypeCode concrete_base_type() - throws BadKind { - if (_indirection) { + throws BadKind + { + if (_indirection) + { return _ref.concrete_base_type(); } int tk = _kind.value(); - if (tk != TCKind._tk_value) { + if (tk != TCKind._tk_value) + { throw new BadKind(); } return _ref; @@ -622,7 +752,8 @@ /** * @param base */ - public void concrete_base_type(org.omg.CORBA.TypeCode base) { + public void concrete_base_type(org.omg.CORBA.TypeCode base) + { _ref = base; } @@ -630,7 +761,8 @@ /** * @param ref */ - public void indirection(org.omg.CORBA.TypeCode ref) { + public void indirection(org.omg.CORBA.TypeCode ref) + { _ref = ref; _indirection = true; } @@ -639,7 +771,8 @@ /** * @param id */ - public void recursive(String id) { + public void recursive(String id) + { _id = id; _ref = null; _indirection = true; @@ -649,16 +782,21 @@ /** * */ - public void fix_recursive_members() { + public void fix_recursive_members() + { String id = _id == null ? default_id() : _id; int n = _member_type.length; - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { TypeCode mt = (TypeCode) _member_type[i]; - if (mt._kind.value() == TCKind._tk_sequence) { + if (mt._kind.value() == TCKind._tk_sequence) + { TypeCode ct = (TypeCode) mt._ref; if (ct._indirection - && ct._ref == null - && ct._id.equals(id)) { + && + ct._ref == null + && ct._id.equals(id)) + { ct._ref = this; } } @@ -671,19 +809,23 @@ /** * @return */ - private String default_id() { + private String default_id() + { // Take _type, and generate _id, e.g. // if _type = "SessionManager::Manager", // then _id = "IDL:SessionManager/Manager:1.0". - if (_type == null) { + if (_type == null) + { return ""; } StringBuffer id = new StringBuffer(_type.length() + 10); id.append("IDL:"); int n = _type.length(); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { char c = _type.charAt(i); - if (c == ':' && i + 1 < n && _type.charAt(i + 1) == ':') { + if (c == ':' && i + 1 < n && _type.charAt(i + 1) == ':') + { i++; } id.append(c == ':' ? '/' : c); Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java?view=diff&r1=159004&r2=159005 ============================================================================== --- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java (original) +++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/UnsupportedProtocolVersionException.java Fri Mar 25 03:54:30 2005 @@ -17,8 +17,10 @@ */ package org.apache.geronimo.interop.rmi.iiop; -public class UnsupportedProtocolVersionException extends RuntimeException { - public UnsupportedProtocolVersionException(String version) { +public class UnsupportedProtocolVersionException extends RuntimeException +{ + public UnsupportedProtocolVersionException(String version) + { super(version); } }