]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.databoard/src-isv/doc/rpc.mediawiki b/bundles/org.simantics.databoard/src-isv/doc/rpc.mediawiki
new file mode 100644 (file)
index 0000000..8e209e3
--- /dev/null
@@ -0,0 +1,55 @@
+=Remote Procedure Call=\r
+Utilities [../javadoc/org/simantics/databoard/method/Server.html|Server] and [../javadoc/org/simantics/databoard/method/Client.html|Client] put MethodInterface over TCP Socket. \r
+<pre class="code">\r
+    Server myServer      = new Server(8192, mi);\r
+    MethodInterface mi   = new Client("localhost", 8192);\r
+</pre>\r
+\r
+MethodInterface with Server and Client together forms a Remote Procedure Call (RPC) mechanism.\r
+<pre class="code">\r
+    public interface MyInterface { String helloWorld(String msg); }\r
+    \r
+    [Server]\r
+    MethodInterface mi   = Methods.bindInterface( MyInterface.class, myObject );\r
+    Server myServer      = new Server(8192, mi);\r
+    \r
+    [Client]\r
+    MethodInterface mi   = new Client("localhost", 8192);\r
+    MyInterface myObject = Methods.createProxy( MyInterface.class, mi );\r
+</pre>\r
+\r
+==Interface Types==\r
+There are interfaces, method types and method type definitions. \r
+Interface type describes a software interface. It is a collection of methods type definitions. \r
+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
+Method type definition is nominal method description.\r
+\r
+The respective Java classes are:\r
+*[../javadoc/org/simantics/databoard/method/Interface.html|Interface] \r
+*[../javadoc/org/simantics/databoard/method/MethodTypeDefinition.html|MethodTypeDefinition]\r
+*[../javadoc/org/simantics/databoard/method/MethodType.html|MethodType]\r
+\r
+In java InterfaceType description can be created with one of the following methods:\r
+* Implementing InterfaceType\r
+* Reading an Java Interface Class using reflection\r
+<pre class="code">\r
+    Interface it = new Interface( ... methodDefinitions );\r
+    Interface it = getInterface( MyInterface.class );\r
+</pre>\r
+\r
+[../javadoc/org/simantics/databoard/method/MethodInterface.html|MethodInterface] is a binding of an\r
+Java Instance and an Interface Type. It decouples the method invocation from the object.\r
+\r
+MethodInterface can be created with the following methods:\r
+* Implementation\r
+* Reflection\r
+<pre class="code">\r
+    MethodInterface mi   = new MethodInterface() {...}\r
+    MethodInterface mi   = Datatypes.bindInterface( MyInterface.class, myObject );\r
+</pre>\r
+\r
+Utilities <code>Datatypes.createProxy()</code> and <code>Datatypes.bindInterface()</code> adapt between MethodInterface and Java Instance.\r
+<pre class="code">\r
+    MethodInterface mi   = Datatypes.bindInterface( MyInterface.class, myObject );\r
+    MyInterface myObject = Datatypes.createProxy( MyInterface.class, mi );\r
+</pre>\r