use of com.alibaba.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class ConfigTest method testGenericServiceConfig.
@Test
public void testGenericServiceConfig() throws Exception {
ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
service.setApplication(new ApplicationConfig("test"));
service.setRegistry(new RegistryConfig("mock://localhost"));
service.setInterface(DemoService.class.getName());
service.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN);
service.setRef(new GenericService() {
public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
return null;
}
});
try {
service.export();
Collection<Registry> collection = MockRegistryFactory.getCachedRegistry();
MockRegistry registry = (MockRegistry) collection.iterator().next();
URL url = registry.getRegistered().get(0);
Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
} finally {
MockRegistryFactory.cleanCachedRegistry();
service.unexport();
}
}
use of com.alibaba.dubbo.rpc.service.GenericService in project dubbo by alibaba.
the class EnumBak method testGenricEnumCompat.
// verify compatibility when 2.0.5 invokes 2.0.3
@Ignore
@Test
public void testGenricEnumCompat() {
int port = 20880;
URL consumerurl = URL.valueOf("dubbo://127.0.0.1:" + port + "/test?timeout=" + Integer.MAX_VALUE);
Invoker<GenericService> reference = protocol.refer(GenericService.class, consumerurl);
GenericService demoProxy = (GenericService) proxy.getProxy(reference);
Object obj = demoProxy.$invoke("enumlength", new String[] { Type[].class.getName() }, new Object[] { new Type[] { Type.High, Type.High } });
System.out.println("obj---------->" + obj);
reference.destroy();
}
use of com.alibaba.dubbo.rpc.service.GenericService in project tesla by linking12.
the class DynamicDubboClient method doRemoteCall.
@Override
public String doRemoteCall(final FilterRpcDO rpcDo, final String jsonInput) {
try {
final String serviceName = rpcDo.getServiceName();
final String methodName = rpcDo.getMethodName();
final String group = rpcDo.getServiceGroup();
final String version = rpcDo.getServiceVersion();
final String paramType = rpcDo.getInputParam();
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>();
reference.setApplication(applicationConfig);
reference.setRegistry(registryConfig);
reference.setInterface(serviceName);
reference.setGroup(group);
reference.setGeneric(true);
reference.setCheck(false);
reference.setVersion(version);
ReferenceConfigCache cache = ReferenceConfigCache.getCache();
GenericService genericService = cache.get(reference);
Pair<String[], Object[]> typeAndValue = paramTypeAndValue(paramType, jsonInput);
Object response = genericService.$invoke(methodName, typeAndValue.getLeft(), typeAndValue.getRight());
return JSON.toJSONString(response);
} catch (Throwable e) {
throw new IllegalArgumentException(String.format("service definition is wrong,please check the proto file you update,service is %s, method is %s", rpcDo.getServiceName(), rpcDo.getMethodName()), e);
}
}
Aggregations