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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,23 +17,21 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import org.apache.geronimo.interop.*; -import org.apache.geronimo.interop.rmi.iiop.client.*; -import org.apache.geronimo.interop.IOP.*; +import java.util.Hashtable; + 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(); - } +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; + +public class ObjectRef implements org.omg.CORBA.Object { // ----------------------------------------------------------------------- // public data // ----------------------------------------------------------------------- @@ -46,32 +44,19 @@ // 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; @@ -88,8 +73,6 @@ private int _port = -1; - //private boolean _automaticFailover; - public byte[] _objectKey; public byte[] _objectState; @@ -97,95 +80,50 @@ public long _objectVersion; // public methods - - 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 ObjectRef() { } - /* - public boolean $getAutomaticFailover() - { - return _automaticFailover; - } - */ - - /* - public void $setAutomaticFailover() - { - _automaticFailover = true; + public Connection $connect() { + Connection conn = $getNamingContext().getConnectionPool().get(_protocol, $getEndpoint(), this); + conn.beforeInvoke(); + return conn; } - */ - 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 @@ -199,155 +137,129 @@ 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"); } - 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; - } + 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"); } } 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(); @@ -357,16 +269,86 @@ key[0] = 'I'; _iiopVersion = IIOP_VERSION_1_1; $setObjectKey(key); - } - else - { + } else { // Initialize for RMI-IIOP. $setObjectKey(compClass.getName()); } } - public Object $getRequestKey() - { + public String[] _ids() { + String[] ids = + { + "" //_type + } + ; + return ids; + } + + public Object $getRequestKey() { + // + //if (_automaticFailover) + //{ + // return $getNamingContext().getRequestKey(); + //} + //else + //{ 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,39 +17,25 @@ */ 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; - ObjectRef objectRef = remote.getObjectRef(); - //if (value instanceof AutomaticFailover) - //{ - // objectRef.$setAutomaticFailover(); - //} - output._cdrOutput.write_Object(objectRef); - } - 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; + output._cdrOutput.write_Object((org.omg.CORBA.Object) remote.$getObjectRef()); + } 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,26 +17,23 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import org.apache.geronimo.interop.util.*; +import org.apache.geronimo.interop.util.ArrayUtil; -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]; @@ -44,23 +41,19 @@ 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]; @@ -68,23 +61,19 @@ 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]; @@ -92,23 +81,19 @@ 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]; @@ -116,23 +101,19 @@ 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]; @@ -140,23 +121,19 @@ 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]; @@ -164,23 +141,19 @@ 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]; @@ -188,23 +161,19 @@ 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]; @@ -212,100 +181,61 @@ 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,57 +17,52 @@ */ 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,11 +17,10 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import org.apache.geronimo.interop.adapter.Adapter; - 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); + public ObjectRef $getObjectRef(); + + public RemoteInterface $getSkeleton(); + + public void $invoke(String method, byte[] objectKey, Object instance, 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,32 +17,14 @@ */ package org.apache.geronimo.interop.rmi.iiop; -import org.apache.geronimo.interop.adapter.Adapter; - -import java.util.HashMap; - public abstract class RemoteObject { - - protected HashMap methods = new HashMap(10); - - public RemoteObject( ) { - registerMethods(); + public RemoteObject() { } 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: @@ -71,4 +53,6 @@ } 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -36,20 +36,26 @@ (byte) 'P', (byte) 'A', (byte) 'S', (byte) 'S' }); - public static Random seedFactory = new Random(); - public String username; - public String password; + public static Random _seedFactory = new Random(); - private static ThreadLocal current = new ThreadLocal(); + public String username; + + public String password; + + // private data + + 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 @@ -60,7 +66,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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,45 +17,30 @@ */ package org.apache.geronimo.interop.rmi.iiop; -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()); - } +import java.io.IOException; - public static ObjectInputStream getInstance(byte[] bytes) - { - return getInstance(CdrInputStream.getInstance(bytes)); +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()); } - 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 getInstance(byte[] bytes) { + return getInstance(CdrInputStream.getInstance(bytes)); } - public static ObjectInputStream getPooledInstance() - { - ObjectInputStream input = null; // (SimpleObjectInputStream)_pool.get(); - if (input == null) - { - input = getInstance(); + 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); } + + input.init(cdrInput); return input; } @@ -63,38 +48,25 @@ // 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(); @@ -106,8 +78,7 @@ // 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,40 +17,27 @@ */ package org.apache.geronimo.interop.rmi.iiop; -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 { - oos = new SimpleObjectOutputStream(); - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - return oos; // getInstance(CdrOutputStream.getInstance()); - } +import java.io.IOException; - public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) - { - ObjectOutputStream output = getInstance(); // (SimpleObjectOutputStream)component.getInstance(); - output.init(cdrOutput); - return output; +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 getPooledInstance() - { - ObjectOutputStream output = null; // (SimpleObjectOutputStream)_pool.get(); - if (output == null) - { - output = getInstance(); + public static ObjectOutputStream getInstance(CdrOutputStream cdrOutput) { + ObjectOutputStream output = null; + try { + output = new SimpleObjectOutputStream(); + } catch (Exception ex) { + throw new SystemException(ex); } + + output.init(cdrOutput); return output; } @@ -58,41 +45,25 @@ // 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; } @@ -105,8 +76,7 @@ // 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,17 +17,14 @@ */ 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); } } 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,17 +17,14 @@ */ 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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -21,55 +21,34 @@ 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); // ----------------------------------------------------------------------- @@ -116,12 +95,10 @@ /** * @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"; } } @@ -130,84 +107,60 @@ * @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()); } } @@ -217,16 +170,14 @@ * @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(); } @@ -235,14 +186,10 @@ * @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); } } @@ -250,10 +197,8 @@ /** * @return */ - public TCKind kind() - { - if (_indirection) - { + public TCKind kind() { + if (_indirection) { return _ref.kind(); } return _kind; @@ -264,18 +209,14 @@ * @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(); @@ -285,25 +226,19 @@ /** * @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) + "::"; @@ -319,10 +254,8 @@ * @throws BadKind */ public String name() - throws BadKind - { - if (_indirection) - { + throws BadKind { + if (_indirection) { return _ref.name(); } /* TODO? @@ -331,8 +264,7 @@ _name = (String)_names.get(new Integer(_kind.value())); } */ - if (_name == null) - { + if (_name == null) { throw new BadKind(); } return _name; @@ -342,8 +274,7 @@ /** * @param name */ - public void name(String name) - { + public void name(String name) { _name = name; } @@ -352,14 +283,11 @@ * @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; @@ -369,16 +297,13 @@ /** * @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]; } } @@ -390,18 +315,14 @@ * @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]; @@ -412,8 +333,7 @@ * @param index * @param name */ - public void member_name(int index, String name) - { + public void member_name(int index, String name) { _member_name[index] = name; } @@ -424,18 +344,14 @@ * @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]; @@ -446,8 +362,7 @@ * @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; } @@ -458,18 +373,14 @@ * @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]; @@ -480,8 +391,7 @@ * @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; } @@ -490,15 +400,12 @@ * @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; @@ -508,8 +415,7 @@ /** * @param disc */ - public void discriminator_type(org.omg.CORBA.TypeCode disc) - { + public void discriminator_type(org.omg.CORBA.TypeCode disc) { _ref = disc; } @@ -518,14 +424,11 @@ * @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; @@ -535,11 +438,9 @@ /** * @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"); @@ -551,17 +452,13 @@ * @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; @@ -571,8 +468,7 @@ /** * @param length */ - public void length(int length) - { + public void length(int length) { _length = length; } @@ -581,21 +477,16 @@ * @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; @@ -605,8 +496,7 @@ /** * @param type */ - public void content_type(org.omg.CORBA.TypeCode type) - { + public void content_type(org.omg.CORBA.TypeCode type) { _ref = type; } @@ -615,15 +505,12 @@ * @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; @@ -633,8 +520,7 @@ /** * @param digits */ - public void fixed_digits(short digits) - { + public void fixed_digits(short digits) { _digits = digits; } @@ -643,15 +529,12 @@ * @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; @@ -661,8 +544,7 @@ /** * @param scale */ - public void fixed_scale(short scale) - { + public void fixed_scale(short scale) { _scale = scale; } @@ -673,19 +555,15 @@ * @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]; @@ -696,8 +574,7 @@ * @param index * @param visibility */ - public void member_visibility(int index, short visibility) - { + public void member_visibility(int index, short visibility) { _member_visibility[index] = visibility; } @@ -706,15 +583,12 @@ * @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; @@ -724,8 +598,7 @@ /** * @param modifier */ - public void type_modifier(short modifier) - { + public void type_modifier(short modifier) { _type_modifier = modifier; } @@ -734,15 +607,12 @@ * @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; @@ -752,8 +622,7 @@ /** * @param base */ - public void concrete_base_type(org.omg.CORBA.TypeCode base) - { + public void concrete_base_type(org.omg.CORBA.TypeCode base) { _ref = base; } @@ -761,8 +630,7 @@ /** * @param ref */ - public void indirection(org.omg.CORBA.TypeCode ref) - { + public void indirection(org.omg.CORBA.TypeCode ref) { _ref = ref; _indirection = true; } @@ -771,8 +639,7 @@ /** * @param id */ - public void recursive(String id) - { + public void recursive(String id) { _id = id; _ref = null; _indirection = true; @@ -782,21 +649,16 @@ /** * */ - 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; } } @@ -809,23 +671,19 @@ /** * @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=158861&r2=158862 ============================================================================== --- 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 Wed Mar 23 18:30:30 2005 @@ -17,10 +17,8 @@ */ 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); } }