use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class RefererInvocationHandler method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (isLocalMethod(method)) {
if ("toString".equals(method.getName())) {
return clustersToString();
}
if ("equals".equals(method.getName())) {
return proxyEquals(args[0]);
}
if ("hashCode".equals(method.getName())) {
return this.clusters == null ? 0 : this.clusters.hashCode();
}
throw new MotanServiceException("can not invoke local method:" + method.getName());
}
DefaultRequest request = new DefaultRequest();
request.setRequestId(RequestIdGenerator.getRequestId());
request.setArguments(args);
String methodName = method.getName();
boolean async = false;
if (methodName.endsWith(MotanConstants.ASYNC_SUFFIX) && method.getReturnType().equals(ResponseFuture.class)) {
methodName = MotanFrameworkUtil.removeAsyncSuffix(methodName);
async = true;
}
request.setMethodName(methodName);
request.setParamtersDesc(ReflectUtil.getMethodParamDesc(method));
request.setInterfaceName(interfaceName);
return invokeRequest(request, getRealReturnType(async, this.clz, method, methodName), async);
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class ConfigurableWeightLoadBalanceTest method testDoSelectToHolder.
@Test
public void testDoSelectToHolder() {
generate(3, new int[] { 2, 3, 5 }, new int[] { 3, 4, 5 });
List<Referer<IHello>> list = new ArrayList<Referer<IHello>>();
balance.doSelectToHolder(new DefaultRequest(), list);
assertTrue(list.size() > 0 && list.size() <= ConfigurableWeightLoadBalance.MAX_REFERER_COUNT);
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class DefaultRpcCodecTest method testStringArrayRequest.
@Test
public void testStringArrayRequest() throws Exception {
DefaultRequest request = getRequest("java.lang.String[]", new Object[] { new String[] { "hello", "world" } });
testCodecRequest(request);
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class DefaultRpcCodecTest method testObjectTypeRequest.
@Test
public void testObjectTypeRequest() throws Exception {
DefaultRequest request = getRequest("com.weibo.api.motan.protocol.example.Model", new Object[] { new Model("world", 12, Model.class) });
testCodecRequest(request);
}
use of com.weibo.api.motan.rpc.DefaultRequest in project motan by weibocom.
the class DefaultRpcCodecTest method testOriginalTypeRequest.
@Test
public void testOriginalTypeRequest() throws Exception {
DefaultRequest request = getRequest("java.lang.Integer", new Object[] { 1 });
testCodecRequest(request);
}
Aggregations