Merge pull request #6 from qixiaobo/fix-group-for-register
[dubbo-proxy.git] / src / main / java / org / apache / dubbo / proxy / service / GenericInvoke.java
index 8c600b0d6a4036ad7a69e9e351c1cd83623e22e9..eccdcd885f23708115f97cecf275d61a19796d0f 100644 (file)
@@ -24,7 +24,7 @@ public class GenericInvoke {
         GenericInvoke.registry = registry;
     }
 
-    public static void init() {
+    private static void init() {
         RegistryConfig registryConfig = new RegistryConfig();
         registryConfig.setAddress(registry.getUrl().getProtocol() + "://" + registry.getUrl().getAddress());
         registryConfig.setGroup(registry.getUrl().getParameter(org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY));
@@ -33,7 +33,7 @@ public class GenericInvoke {
         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,
@@ -42,15 +42,15 @@ public class GenericInvoke {
         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("hsf generic invoke, service is {}, method is {} , paramTypes is {} , paramObjs is {} , svc is {}.", interfaceName
+            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 +72,9 @@ public class GenericInvoke {
         }
     }
 
-    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 +90,8 @@ public class GenericInvoke {
         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);