| | 1 | = The KaRMI Call Protocol = |
| | 2 | |
| | 3 | Currently, the KaRMI call protocol for a remote method invocation |
| | 4 | looks approximately like the following: |
| | 5 | |
| | 6 | == Client side == |
| | 7 | {{{ |
| | 8 | #!java |
| | 9 | ClientConnection c = Technology.getContext(...) |
| | 10 | |
| | 11 | c.openSendCall() |
| | 12 | // marshal arguments |
| | 13 | c.closeSendCall() |
| | 14 | |
| | 15 | normalReturn = c.openReceiveResult() |
| | 16 | if (normalReturn) { |
| | 17 | // unmarshal result |
| | 18 | } else { |
| | 19 | // unmarshal exeption ex |
| | 20 | } |
| | 21 | c.closeReceiveResult() |
| | 22 | |
| | 23 | if (normalReturn) { |
| | 24 | return result; |
| | 25 | } else { |
| | 26 | throw ex; |
| | 27 | } |
| | 28 | }}} |
| | 29 | |
| | 30 | == Server side == |
| | 31 | {{{ |
| | 32 | #!java |
| | 33 | // The connection c belongs one-to-one to the serving |
| | 34 | // thread. |
| | 35 | ServerConnection c; |
| | 36 | |
| | 37 | c.openReceiveCall() |
| | 38 | // unmarshal arguments |
| | 39 | c.closeReceiveCall() |
| | 40 | |
| | 41 | try { |
| | 42 | try { |
| | 43 | // application code |
| | 44 | } catch (Exception ex) { |
| | 45 | c.openSendResult(false) |
| | 46 | // marshal ex |
| | 47 | throw ex |
| | 48 | } |
| | 49 | c.openSendResult(true) |
| | 50 | // marshal result |
| | 51 | } catch (Exception ex) {} |
| | 52 | c.closeSendResult() |
| | 53 | }}} |