]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src-isv/doc/rpc.mediawiki
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src-isv / doc / rpc.mediawiki
1 =Remote Procedure Call=\r
2 Utilities [../javadoc/org/simantics/databoard/method/Server.html|Server] and [../javadoc/org/simantics/databoard/method/Client.html|Client] put MethodInterface over TCP Socket. \r
3 <pre class="code">\r
4     Server myServer      = new Server(8192, mi);\r
5     MethodInterface mi   = new Client("localhost", 8192);\r
6 </pre>\r
7 \r
8 MethodInterface with Server and Client together forms a Remote Procedure Call (RPC) mechanism.\r
9 <pre class="code">\r
10     public interface MyInterface { String helloWorld(String msg); }\r
11     \r
12     [Server]\r
13     MethodInterface mi   = Methods.bindInterface( MyInterface.class, myObject );\r
14     Server myServer      = new Server(8192, mi);\r
15     \r
16     [Client]\r
17     MethodInterface mi   = new Client("localhost", 8192);\r
18     MyInterface myObject = Methods.createProxy( MyInterface.class, mi );\r
19 </pre>\r
20 \r
21 ==Interface Types==\r
22 There are interfaces, method types and method type definitions. \r
23 Interface type describes a software interface. It is a collection of methods type definitions. \r
24 Method type is an unnamed function with the following properties : Response Type, Request Type and ErrorType; where Response Type is any Data Type, Request Type is a Record and Error Type is an Union.\r
25 Method type definition is nominal method description.\r
26 \r
27 The respective Java classes are:\r
28 *[../javadoc/org/simantics/databoard/method/Interface.html|Interface] \r
29 *[../javadoc/org/simantics/databoard/method/MethodTypeDefinition.html|MethodTypeDefinition]\r
30 *[../javadoc/org/simantics/databoard/method/MethodType.html|MethodType]\r
31 \r
32 In java InterfaceType description can be created with one of the following methods:\r
33 * Implementing InterfaceType\r
34 * Reading an Java Interface Class using reflection\r
35 <pre class="code">\r
36     Interface it = new Interface( ... methodDefinitions );\r
37     Interface it = getInterface( MyInterface.class );\r
38 </pre>\r
39 \r
40 [../javadoc/org/simantics/databoard/method/MethodInterface.html|MethodInterface] is a binding of an\r
41 Java Instance and an Interface Type. It decouples the method invocation from the object.\r
42 \r
43 MethodInterface can be created with the following methods:\r
44 * Implementation\r
45 * Reflection\r
46 <pre class="code">\r
47     MethodInterface mi   = new MethodInterface() {...}\r
48     MethodInterface mi   = Datatypes.bindInterface( MyInterface.class, myObject );\r
49 </pre>\r
50 \r
51 Utilities <code>Datatypes.createProxy()</code> and <code>Datatypes.bindInterface()</code> adapt between MethodInterface and Java Instance.\r
52 <pre class="code">\r
53     MethodInterface mi   = Datatypes.bindInterface( MyInterface.class, myObject );\r
54     MyInterface myObject = Datatypes.createProxy( MyInterface.class, mi );\r
55 </pre>\r