Search in sources :

Example 1 with User

use of com.weibo.motan.demo.service.model.User in project motan by weibocom.

the class Motan2RpcClient method motan2XmlCommonClientDemo.

public static void motan2XmlCommonClientDemo(CommonHandler client) throws Throwable {
    System.out.println(client.call("hello", new Object[] { "a" }, String.class));
    User user = new User(1, "AAA");
    System.out.println(user);
    user = (User) client.call("rename", new Object[] { user, "BBB" }, User.class);
    System.out.println(user);
    ResponseFuture future = (ResponseFuture) client.asyncCall("rename", new Object[] { user, "CCC" }, User.class);
    user = (User) future.getValue();
    System.out.println(user);
    ResponseFuture future2 = (ResponseFuture) client.asyncCall("rename", new Object[] { user, "DDD" }, User.class);
    future2.addListener(new FutureListener() {

        @Override
        public void operationComplete(Future future) {
            System.out.println(future.getValue());
        }
    });
    Request request = client.buildRequest("rename", new Object[] { user, "EEE" });
    request.setAttachment("a", "a");
    user = (User) client.call(request, User.class);
    System.out.println(user);
// expect throw exception
// client.call("rename", new Object[]{null, "FFF"}, void.class);
}
Also used : FutureListener(com.weibo.api.motan.rpc.FutureListener) User(com.weibo.motan.demo.service.model.User) Request(com.weibo.api.motan.rpc.Request) Future(com.weibo.api.motan.rpc.Future) ResponseFuture(com.weibo.api.motan.rpc.ResponseFuture) ResponseFuture(com.weibo.api.motan.rpc.ResponseFuture)

Aggregations

Future (com.weibo.api.motan.rpc.Future)1 FutureListener (com.weibo.api.motan.rpc.FutureListener)1 Request (com.weibo.api.motan.rpc.Request)1 ResponseFuture (com.weibo.api.motan.rpc.ResponseFuture)1 User (com.weibo.motan.demo.service.model.User)1