=Remote Procedure Call= Utilities [../javadoc/org/simantics/databoard/method/Server.html|Server] and [../javadoc/org/simantics/databoard/method/Client.html|Client] put MethodInterface over TCP Socket.
Server myServer = new Server(8192, mi); MethodInterface mi = new Client("localhost", 8192);MethodInterface with Server and Client together forms a Remote Procedure Call (RPC) mechanism.
public interface MyInterface { String helloWorld(String msg); } [Server] MethodInterface mi = Methods.bindInterface( MyInterface.class, myObject ); Server myServer = new Server(8192, mi); [Client] MethodInterface mi = new Client("localhost", 8192); MyInterface myObject = Methods.createProxy( MyInterface.class, mi );==Interface Types== There are interfaces, method types and method type definitions. Interface type describes a software interface. It is a collection of methods type definitions. 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. Method type definition is nominal method description. The respective Java classes are: *[../javadoc/org/simantics/databoard/method/Interface.html|Interface] *[../javadoc/org/simantics/databoard/method/MethodTypeDefinition.html|MethodTypeDefinition] *[../javadoc/org/simantics/databoard/method/MethodType.html|MethodType] In java InterfaceType description can be created with one of the following methods: * Implementing InterfaceType * Reading an Java Interface Class using reflection
Interface it = new Interface( ... methodDefinitions ); Interface it = getInterface( MyInterface.class );[../javadoc/org/simantics/databoard/method/MethodInterface.html|MethodInterface] is a binding of an Java Instance and an Interface Type. It decouples the method invocation from the object. MethodInterface can be created with the following methods: * Implementation * Reflection
MethodInterface mi = new MethodInterface() {...} MethodInterface mi = Datatypes.bindInterface( MyInterface.class, myObject );Utilities
Datatypes.createProxy()
and Datatypes.bindInterface()
adapt between MethodInterface and Java Instance.
MethodInterface mi = Datatypes.bindInterface( MyInterface.class, myObject ); MyInterface myObject = Datatypes.createProxy( MyInterface.class, mi );