/** * Accept and return parameters, having various types. */ public int passSimple(ByteHolder an_octet, int a_long, ShortHolder a_short, StringHolder a_string, DoubleHolder a_double ) { System.out.println("SERVER: ***** Test passing multiple parameters"); System.out.println("SERVER: Received:"); System.out.println("SERVER: octet " + an_octet.value); System.out.println("SERVER: short " + a_short.value); System.out.println("SERVER: string " + a_string.value); // Returning incremented values. an_octet.value++; a_short.value++; // OUT parameter, return only. a_double.value = 1; a_string.value += " [return]"; return 452572; }
/** * Test passing multiple parameters in both directions. */ public void testParameters() { System.out.println("***** Pass multiple parameters."); // Holder classes are required to simulate passing // "by reference" (modification is returned back to the server). ByteHolder a_byte = new ByteHolder((byte) 0); ShortHolder a_short = new ShortHolder((short) 3); StringHolder a_string = new StringHolder("[string 4]"); // This is an 'out' parameter; the value must not be passed to servant. DoubleHolder a_double = new DoubleHolder(56.789); int returned = object.passSimple(a_byte, 2, a_short, a_string, a_double); System.out.println(" Returned value " + returned); System.out.println(" Returned parameters: "); System.out.println(" octet " + a_byte.value); System.out.println(" short " + a_short.value); System.out.println(" string '" + a_string.value+"'"); System.out.println(" double " + a_double.value); }
/** * Passes various parameters in both directions. The parameters that * shoud also return the values are wrapped into holders. */ public int passSimple(ByteHolder an_octet, int a_long, ShortHolder a_short, StringHolder a_string, DoubleHolder a_double ) { InputStream in = null; try { // Get the stream where the parameters must be written: OutputStream out = _request("passSimple", true); // Write the parameters. out.write_octet(an_octet.value); out.write_long(a_long); out.write_short(a_short.value); out.write_string(a_string.value); // Invoke the method. in = _invoke(out); // Read the returned values. int result = in.read_long(); // Read the inout and out parameters. an_octet.value = in.read_octet(); a_short.value = in.read_short(); a_string.value = in.read_string(); a_double.value = in.read_double(); return result; } catch (ApplicationException ex) { // Handle excepion on remote side. in = ex.getInputStream(); throw new MARSHAL(ex.getId()); } catch (RemarshalException _rm) { // Handle instruction to resend the parameters. return passSimple(an_octet, a_long, a_short, a_string, a_double); } finally { _releaseReply(in); } }
/** * Passes various parameters in both directions. * The parameters that must return the value are wrapped in holders. */ int passSimple(ByteHolder an_octet, int a_long, ShortHolder a_short, StringHolder a_string, DoubleHolder a_double );