Skip to content
Permalink
Browse files
code-style-refactor
  • Loading branch information
qixiaobo committed Jul 26, 2019
1 parent fb6af3c commit 67d9b4f18d47e4b321576917b720bd78d8a928fe
Showing 1 changed file with 9 additions and 10 deletions.
@@ -24,15 +24,15 @@ public static void setRegistry(Registry registry) {
GenericInvoke.registry = registry;
}

public static void init() {
private static void init() {
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress(registry.getUrl().getProtocol() + "://" + registry.getUrl().getAddress());
applicationConfig = new ApplicationConfig();
applicationConfig.setName("dubbo-proxy");
applicationConfig.setRegistry(registryConfig);
}

private static ConcurrentHashMap<String, ReferenceConfig> cachedConfig = new ConcurrentHashMap<>();
private static ConcurrentHashMap<String, ReferenceConfig<GenericService>> cachedConfig = new ConcurrentHashMap<>();
private static Logger logger = LoggerFactory.getLogger(GenericInvoke.class);

public static Object genericCall(String interfaceName, String group,
@@ -41,16 +41,15 @@ public static Object genericCall(String interfaceName, String group,
if (init.compareAndSet(false, true)) {
init();
}
ReferenceConfig<GenericService> reference = null;
ReferenceConfig<GenericService> reference;
reference = addNewReference(interfaceName, group, version);

try {
GenericService svc = reference.get();
logger.info("dubbo generic invoke, service is {}, method is {} , paramTypes is {} , paramObjs is {} , svc" +
" is {}.", interfaceName
, methodName,paramTypes,paramObjs,svc);
Object result = svc.$invoke(methodName, paramTypes, paramObjs);
return result;
return svc.$invoke(methodName, paramTypes, paramObjs);
} catch (Exception e) {
logger.error("Generic invoke failed",e);
if (e instanceof RpcException) {
@@ -72,9 +71,9 @@ public static Object genericCall(String interfaceName, String group,
}
}

private static ReferenceConfig addNewReference(String interfaceName,
String group, String version) {
ReferenceConfig reference;
private static ReferenceConfig<GenericService> addNewReference(String interfaceName,
String group, String version) {
ReferenceConfig<GenericService> reference;
String cachedKey = interfaceName + group + version;
reference = cachedConfig.get(cachedKey);
if (reference == null) {
@@ -90,8 +89,8 @@ private static ReferenceConfig addNewReference(String interfaceName,
return reference;
}

private static ReferenceConfig initReference(String interfaceName, String group,
String version) {
private static ReferenceConfig<GenericService> initReference(String interfaceName, String group,
String version) {
ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
reference.setGeneric(true);
reference.setApplication(applicationConfig);

0 comments on commit 67d9b4f

Please sign in to comment.