yr.java_function

Contents

yr.java_function#

yr.java_function(class_name: str, function_name: str, function_urn: str) FunctionProxy[source]#

A proxy used to construct java functions and remotely call java functions.

Parameters:
  • class_name (str) – The name of the Java class .

  • function_name (str) – The name of the Java function.

  • function_urn (str) – The URN (Uniform Resource Name) of the Java function.

Returns:

The corresponding function proxy. Data type is StatelessFunction.

Examples

package org.yuanrong.demo;

public class PlusOne{
    public static int PlusOne(int x) {
        System.out.println("PlusOne with x=" + x);
        return x + 1;
    }
}
>>> import yr
>>> yr.init()
>>> java_function_urn = (
...     "sn:cn:yrk:default:"
...     "function:0-yr-defaultservice-java:$latest"
... )
>>> java_add = yr.java_function("org.yuanrong.demo.PlusOne", "PlusOne", java_function_urn)
>>> result = java_add.invoke(1)
>>> print(yr.get(result))