1 package org.jacorb.test.orb.rmi; 2 3 22 23 import org.jacorb.test.orb.rmi.Boo; 24 import org.jacorb.test.orb.rmi.Foo; 25 import org.jacorb.test.orb.rmi.NegativeArgumentException; 26 27 import javax.rmi.PortableRemoteObject ; 28 29 public class RMITestImpl 30 extends PortableRemoteObject 31 implements RMITestInterface 32 { 33 34 public RMITestImpl() 35 throws java.rmi.RemoteException 36 { 37 super(); 38 } 39 40 public String getString() 41 throws java.rmi.RemoteException 42 { 43 return RMITestUtil.STRING; 44 } 45 46 public String testPrimitiveTypes(boolean flag, char c, byte b, 47 short s, int i, long l, float f, double d) 48 throws java.rmi.RemoteException 49 { 50 return RMITestUtil.primitiveTypesToString(flag, c, b, s, i, l, f, d); 51 } 52 53 public String testString(String s) 54 throws java.rmi.RemoteException 55 { 56 return RMITestUtil.echo(s); 57 } 58 59 public RMITestInterface testRMITestInterface(String s, RMITestInterface t) 60 throws java.rmi.RemoteException 61 { 62 return t; 63 } 64 65 public java.rmi.Remote testRemote(String s, java.rmi.Remote t) 66 throws java.rmi.RemoteException 67 { 68 return t; 69 } 70 71 public Foo testSerializable(Foo foo) 72 throws java.rmi.RemoteException 73 { 74 return RMITestUtil.echoFoo(foo); 75 } 76 77 public int[] testIntArray(int[] a) 78 throws java.rmi.RemoteException 79 { 80 for (int i = 0; i < a.length; i++) 81 { 82 a[i]++; 83 } 84 return a; 85 } 86 87 public Foo[] testValueArray(Foo[] a) 88 throws java.rmi.RemoteException 89 { 90 for (int i = 0; i < a.length; i++) 91 { 92 a[i] = RMITestUtil.echoFoo(a[i]); 93 } 94 return a; 95 } 96 97 public String testException(int i) 98 throws NegativeArgumentException, java.rmi.RemoteException 99 { 100 if (i >= 0) 101 return "#" + i; 102 else 103 throw new NegativeArgumentException(i); 104 } 105 106 public Object fooValueToObject(Foo foo) 107 throws java.rmi.RemoteException 108 { 109 return RMITestUtil.echoFoo(foo); 110 } 111 112 public Object booValueToObject(Boo boo) 113 throws java.rmi.RemoteException 114 { 115 return RMITestUtil.echoBoo(boo); 116 } 117 118 public java.util.Vector valueArrayToVector(Foo[] a) 119 throws java.rmi.RemoteException 120 { 121 java.util.Vector v = new java.util.Vector (); 122 123 for (int i = 0; i < a.length; i++) 124 { 125 v.add(RMITestUtil.echoFoo(a[i])); 126 } 127 return v; 128 } 129 130 public Foo[] vectorToValueArray(java.util.Vector v) 131 throws java.rmi.RemoteException 132 { 133 Foo a[] = new Foo[v.size()]; 134 135 for (int i = 0; i < a.length; i++) 136 { 137 a[i] = RMITestUtil.echoFoo((Foo)v.elementAt(i)); 138 } 139 return a; 140 } 141 142 public Object getException() 143 throws java.rmi.RemoteException 144 { 145 Object obj = null; 146 try 147 { 148 NegativeArgumentException e = new NegativeArgumentException(-7777); 149 throw e; 150 } 151 catch (NegativeArgumentException e) 152 { 153 obj = e; 154 } 155 return obj; 156 } 157 158 public Object getZooValue() 159 throws java.rmi.RemoteException 160 { 161 return new Zoo("outer_zoo", 162 "returned by getZooValue", 163 new Zoo("inner_zoo", "inner")); 164 } 165 166 public Object [] testReferenceSharingWithinArray(Object [] a) 167 throws java.rmi.RemoteException 168 { 169 int n = a.length; 170 Object [] b = new Object [2 * n]; 171 for (int i = 0; i < n; i++) 172 b[i + n] = b[i] = a[i]; 173 return b; 174 } 175 176 public java.util.Collection testReferenceSharingWithinCollection( 177 java.util.Collection cin) throws java.rmi.RemoteException 178 { 179 java.util.Collection cout = new java.util.ArrayList (cin); 180 java.util.Iterator i = cin.iterator(); 181 while (i.hasNext()) 182 { 183 cout.add(i.next()); 184 } 185 return cout; 186 } 187 188 public java.util.Vector getVectorWithObjectArrayAsElement() 189 throws java.rmi.RemoteException 190 { 191 java.util.Vector vector = new java.util.Vector (); 192 Object [] innerArray = new Object [3]; 193 innerArray[0] = new Integer (1); 194 innerArray[1] = new Integer (2); 195 innerArray[2] = "Third Element"; 196 vector.add(innerArray); 197 return vector; 198 } 199 200 public java.util.Vector getVectorWithVectorAsElement() 201 throws java.rmi.RemoteException 202 { 203 java.util.Vector vector = new java.util.Vector (); 204 java.util.Vector innerVector = new java.util.Vector (); 205 innerVector.add(new Integer (1)); 206 innerVector.add(new Integer (2)); 207 innerVector.add("Third Element"); 208 vector.add(innerVector); 209 return vector; 210 } 211 212 public java.util.Vector getVectorWithHashtableAsElement() 213 throws java.rmi.RemoteException 214 { 215 java.util.Vector vector = new java.util.Vector (); 216 java.util.Hashtable innerHash = new java.util.Hashtable (); 217 innerHash.put(new Integer (0), new Integer (1)); 218 innerHash.put(new Integer (1), new Integer (2)); 219 innerHash.put(new Integer (2), "Third Element"); 220 vector.add(innerHash); 221 return vector; 222 } 223 224 } 225 | Popular Tags |