Search in sources :

Example 1 with ReferenceConfigCache

use of com.alibaba.dubbo.config.utils.ReferenceConfigCache 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);
    }
}
Also used : GenericService(com.alibaba.dubbo.rpc.service.GenericService) ReferenceConfig(com.alibaba.dubbo.config.ReferenceConfig) ReferenceConfigCache(com.alibaba.dubbo.config.utils.ReferenceConfigCache)

Aggregations

ReferenceConfig (com.alibaba.dubbo.config.ReferenceConfig)1 ReferenceConfigCache (com.alibaba.dubbo.config.utils.ReferenceConfigCache)1 GenericService (com.alibaba.dubbo.rpc.service.GenericService)1