1. 程式人生 > 其它 >手寫grpc c++ 簡單demo

手寫grpc c++ 簡單demo

package TestDaiLi;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Main {
   public static  void  main(String []args){

        InvocationHandler handler = new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable { System.out.println(method); if (method.getName().equals("morning")) { System.out.println("Good morning, " + args[0]); } return null; } }; Hello hello = (Hello) Proxy.newProxyInstance( Hello.
class.getClassLoader(), // 傳入ClassLoader new Class[] { Hello.class }, // 傳入要實現的介面 handler); // 傳入處理呼叫方法的InvocationHandler hello.morning("小小"); } }
package TestDaiLi;


public interface Hello {
    void morning(String name);
}