001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Mikhail A. Markov, Vasily Zakharov
021: * @version $Revision: 1.1.2.1 $
022: */package org.apache.harmony.rmi.test;
023:
024: import java.rmi.Remote;
025: import java.rmi.RemoteException;
026:
027: import java.rmi.server.UnicastRemoteObject;
028:
029: /**
030: * @author Mikhail A. Markov, Vasily Zakharov
031: * @version $Revision: 1.1.2.1 $
032: */
033: public class MyRemoteObject extends UnicastRemoteObject implements
034: MyRemoteInterface {
035:
036: public MyRemoteObject() throws RemoteException {
037: super ();
038: }
039:
040: public void test_String_Void(String param) throws RemoteException {
041: System.out.println("MyRemoteObject: test_String_Void: param = "
042: + param);
043: }
044:
045: public String test_Void_String() throws RemoteException {
046: System.out.println("MyRemoteObject: test_Void_String");
047: return "MyRemoteObject.test_Void_String";
048: }
049:
050: public void test_Int_Void(int param) throws RemoteException {
051: System.out.println("MyRemoteObject: test_Int_Void: param = "
052: + param);
053: }
054:
055: public int test_Void_Int() throws RemoteException {
056: System.out.println("MyRemoteObject: test_Void_Int");
057: return 987654321;
058: }
059:
060: public void test_Remote_Void(Remote param) throws RemoteException {
061: System.out.println("MyRemoteObject: test_Remote_Void: param = "
062: + param);
063: System.out.println("Call param.test method: "
064: + ((MyRemoteInterface1) param).test1());
065: }
066:
067: public void test_UnicastRemoteObject_Void(Remote param)
068: throws RemoteException {
069: System.out
070: .println("MyRemoteObject: test_UnicastRemoteObject_Void: param = "
071: + param);
072: }
073:
074: public Remote test_Void_Remote() throws RemoteException {
075: System.out.println("MyRemoteObject: test_Void_Remote");
076: return new MyRemoteObject2("MyRemoteObject.test_Void_Remote");
077: }
078:
079: public long test_Long_Long(long param) throws RemoteException {
080: System.out.println("MyRemoteObject: test_Long_Long: param = "
081: + param);
082: return 998877665544332211L;
083: }
084:
085: public String test_String_String(String param)
086: throws RemoteException {
087: System.out
088: .println("MyRemoteObject: test_String_String: param = "
089: + param);
090: return "MyRemoteObject.test_String_String";
091: }
092:
093: public Remote test_Remote_Remote(Remote param)
094: throws RemoteException {
095: System.out
096: .println("MyRemoteObject: test_Remote_Remote: param = "
097: + param);
098: System.out.println("Call param.test method: "
099: + ((MyRemoteInterface1) param).test1());
100: return new MyRemoteObject2("MyRemoteObject.test_Remote_Remote");
101: }
102:
103: public void test_RemoteString_Void(Remote param1, String param2)
104: throws RemoteException {
105: System.out
106: .println("MyRemoteObject: test_RemoteString_Void: param1 = "
107: + param1 + ", param2 = " + param2);
108: System.out.println("Call param1.test method: "
109: + ((MyRemoteInterface1) param1).test1());
110: }
111:
112: public Remote test_RemoteRemote_Remote(Remote param1, Remote param2)
113: throws RemoteException {
114: System.out
115: .println("MyRemoteObject: test_RemoteRemote_Remote: param1 = "
116: + param1 + ", param2 = " + param2);
117: System.out.println("Call param1.test method: "
118: + ((MyRemoteInterface1) param1).test1());
119: System.out.println("Call param2.test method: "
120: + ((MyRemoteInterface3) param2).test3());
121: return new MyRemoteObject2(
122: "MyRemoteObject.test_RemoteRemote_Remote");
123: }
124:
125: public void test_BooleanStringRemote_Void(boolean param1,
126: String param2, Remote param3) throws RemoteException {
127: System.out
128: .println("MyRemoteObject: test_BooleanStringRemote_Void: "
129: + "param1 = "
130: + param1
131: + ", param2 = "
132: + param2
133: + ", param3 = " + param3);
134: System.out.println("Call param3.test method: "
135: + ((MyRemoteInterface1) param3).test1());
136: }
137:
138: public void test_Proxy_Void(Object param) throws RemoteException {
139: System.out.println("MyRemoteObject: test_Proxy_Void: param = "
140: + param);
141: }
142:
143: public void test_IntArray_Void(int[] param) throws RemoteException {
144: System.out
145: .println("MyRemoteObject: test_IntArray_Void: param = ");
146: printIntArray(param);
147: }
148:
149: public int[] test_Void_IntArray() throws RemoteException {
150: System.out.println("MyRemoteObject: test_Void_IntArray");
151: return new int[] { 1, 2 };
152: }
153:
154: public void test_Array_Void(String[] param) throws RemoteException {
155: System.out.println("MyRemoteObject: test_Array_Void: param = ");
156: printArray(param);
157: }
158:
159: public String[] test_Void_Array() throws RemoteException {
160: System.out.println("MyRemoteObject: test_Void_Array");
161: return new String[] { "MyRemoteObject.test_Void_Array 1",
162: "MyRemoteObject.test_Void_Array 2" };
163: }
164:
165: public void test_RemoteArray_Void(Remote[] param)
166: throws RemoteException {
167: System.out
168: .println("MyRemoteObject: test_RemoteArray_Void: param = ");
169: printArray(param);
170: }
171:
172: public Remote[] test_Void_RemoteArray() throws RemoteException {
173: System.out.println("MyRemoteObject: test_Void_RemoteArray");
174: return new Remote[] {
175: new MyRemoteObject1(
176: "MyRemoteObject.test_Void_RemoteArray 1"),
177: new MyRemoteObject1(
178: "MyRemoteObject.test_Void_RemoteArray 2") };
179: }
180:
181: public void test_Exception() throws RemoteException, MyException {
182: System.out.println("MyRemoteObject: test_Exception");
183: throw new MyException("MyRemoteObject.test_Exception");
184: }
185:
186: public void test_Error() throws RemoteException, MyException {
187: System.out.println("MyRemoteObject: test_Error");
188: throw new Error("MyRemoteObject.test_Error");
189: }
190:
191: public void test_RuntimeException() throws RemoteException,
192: MyException {
193: System.out.println("MyRemoteObject: test_RuntimeException");
194: throw new RuntimeException(
195: "MyRemoteObject.text_RuntimeException");
196: }
197:
198: public void test_RemoteException() throws RemoteException {
199: System.out.println("MyRemoteObject: test_RemoteException");
200: throw new RemoteException("MyRemoteObject.text_RemoteException");
201: }
202:
203: public static void printArray(Object[] objs) {
204: if (objs == null) {
205: System.out.println(" Array is NULL.");
206: }
207:
208: for (int i = 0; i < objs.length; ++i) {
209: System.out.println(" " + objs[i]);
210: }
211: }
212:
213: public static void printIntArray(int[] arr) {
214: if (arr == null) {
215: System.out.println(" Int Array is NULL.");
216: }
217:
218: for (int i = 0; i < arr.length; ++i) {
219: System.out.println(" " + arr[i]);
220: }
221: }
222: }
|