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