提交 8f71e534 编写于 作者: N nzomkxia

separate version and group for service test #313

上级 5367378b
......@@ -28,22 +28,13 @@ public class ConvertUtil {
}
public static Map<String, String> serviceName2Map(String serviceName) {
String group = null;
String version = null;
int i = serviceName.indexOf("/");
if (i > 0) {
group = serviceName.substring(0, i);
serviceName = serviceName.substring(i + 1);
}
i = serviceName.lastIndexOf(":");
if (i > 0) {
version = serviceName.substring(i + 1);
serviceName = serviceName.substring(0, i);
}
String group = Tool.getGroup(serviceName);
String version = Tool.getVersion(serviceName);
String interfaze = Tool.getInterface(serviceName);
Map<String, String> ret = new HashMap<String, String>();
if (!StringUtils.isEmpty(serviceName)) {
ret.put(Constants.INTERFACE_KEY, serviceName);
ret.put(Constants.INTERFACE_KEY, interfaze);
}
if (!StringUtils.isEmpty(version)) {
ret.put(Constants.VERSION_KEY, version);
......@@ -72,27 +63,4 @@ public class ConvertUtil {
return org.apache.dubbo.admin.common.util.Constants.SERVICE;
}
}
// public static <T extends BaseDTO> T convertDTOtoStore(T dto) {
// if (StringUtils.isNotEmpty(dto.getApplication())) {
// dto.setScope("application");
// dto.setKey(dto.getApplication());
// } else {
// dto.setScope("service");
// dto.setKey(dto.getService());
// }
// return dto;
// }
//
// public static <T extends BaseDTO> T convertDTOtoDisplay(T dto) {
// if (dto == null) {
// return null;
// }
// if(dto.getScope().equals("application")) {
// dto.setApplication(dto.getKey());
// } else {
// dto.setService(dto.getKey());
// }
// return dto;
// }
}
......@@ -19,6 +19,7 @@ package org.apache.dubbo.admin.controller;
import com.google.gson.Gson;
import org.apache.dubbo.admin.common.util.Constants;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.admin.model.domain.Consumer;
import org.apache.dubbo.admin.model.domain.Provider;
import org.apache.dubbo.admin.model.dto.ServiceDTO;
......@@ -61,19 +62,9 @@ public class ServiceController {
@RequestMapping(value = "/service/{service}", method = RequestMethod.GET)
public ServiceDetailDTO serviceDetail(@PathVariable String service, @PathVariable String env) {
service = service.replace(Constants.ANY_VALUE, Constants.PATH_SEPARATOR);
String group = null;
String version = null;
String interfaze = service;
int i = interfaze.indexOf("/");
if (i >= 0) {
group = interfaze.substring(0, i);
interfaze = interfaze.substring(i + 1);
}
i = interfaze.lastIndexOf(":");
if (i >= 0) {
version = interfaze.substring(i + 1);
interfaze = interfaze.substring(0, i);
}
String group = Tool.getGroup(service);
String version = Tool.getVersion(service);
String interfaze = Tool.getInterface(service);
List<Provider> providers = providerService.findByService(service);
List<Consumer> consumers = consumerService.findByService(service);
......
......@@ -16,6 +16,7 @@
*/
package org.apache.dubbo.admin.model.domain;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.StringUtils;
......@@ -201,19 +202,9 @@ public class Consumer extends Entity {
}
public URL toUrl() {
String group = null;
String version = null;
String path = service;
int i = path.indexOf("/");
if (i > 0) {
group = path.substring(0, i);
path = path.substring(i + 1);
}
i = path.lastIndexOf(":");
if (i > 0) {
version = path.substring(i + 1);
path = path.substring(0, i);
}
String group = Tool.getGroup(service);
String version = Tool.getVersion(service);
String interfaze = Tool.getInterface(service);
Map<String, String> param = StringUtils.parseQueryString(parameters);
param.put(Constants.CATEGORY_KEY, Constants.CONSUMERS_CATEGORY);
if (group != null) {
......@@ -222,7 +213,7 @@ public class Consumer extends Entity {
if (version != null) {
param.put(Constants.VERSION_KEY, version);
}
return URL.valueOf(Constants.CONSUMER_PROTOCOL + "://" + address + "/" + path
return URL.valueOf(Constants.CONSUMER_PROTOCOL + "://" + address + "/" + interfaze
+ "?" + StringUtils.toQueryString(param));
}
......
......@@ -16,6 +16,7 @@
*/
package org.apache.dubbo.admin.model.domain;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.utils.StringUtils;
......@@ -158,19 +159,9 @@ public class Override extends Entity {
}
public URL toUrl() {
String group = null;
String version = null;
String path = service;
int i = path.indexOf("/");
if (i > 0) {
group = path.substring(0, i);
path = path.substring(i + 1);
}
i = path.lastIndexOf(":");
if (i > 0) {
version = path.substring(i + 1);
path = path.substring(0, i);
}
String group = Tool.getGroup(service);
String version = Tool.getVersion(service);
String interfaze = Tool.getInterface(service);
StringBuilder sb = new StringBuilder();
sb.append(Constants.OVERRIDE_PROTOCOL);
sb.append("://");
......@@ -180,7 +171,7 @@ public class Override extends Entity {
sb.append(Constants.ANYHOST_VALUE);
}
sb.append("/");
sb.append(path);
sb.append(interfaze);
sb.append("?");
Map<String, String> param = StringUtils.parseQueryString(params);
param.put(Constants.CATEGORY_KEY, Constants.CONFIGURATORS_CATEGORY);
......
......@@ -18,6 +18,7 @@
package org.apache.dubbo.admin.model.domain;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
......@@ -208,20 +209,10 @@ public class Route extends Entity {
}
public URL toUrl() {
String group = null;
String version = null;
String path = service;
int i = path.indexOf("/");
if (i > 0) {
group = path.substring(0, i);
path = path.substring(i + 1);
}
i = path.lastIndexOf(":");
if (i > 0) {
version = path.substring(i + 1);
path = path.substring(0, i);
}
return URL.valueOf(Constants.ROUTE_PROTOCOL + "://" + Constants.ANYHOST_VALUE + "/" + path
String group = Tool.getGroup(service);
String version = Tool.getVersion(service);
String interfaze = Tool.getInterface(service);
return URL.valueOf(Constants.ROUTE_PROTOCOL + "://" + Constants.ANYHOST_VALUE + "/" + interfaze
+ "?" + Constants.CATEGORY_KEY + "=" + Constants.ROUTERS_CATEGORY
+ "&router=condition&runtime=" + isRuntime() + "&enabled=" + isEnabled() + "&priority=" + getPriority() + "&force=" + isForce() + "&dynamic=" + isDynamic()
+ "&name=" + getName() + "&" + Constants.RULE_KEY + "=" + URL.encode(getMatchRule() + " => " + getFilterRule())
......
......@@ -17,6 +17,7 @@
package org.apache.dubbo.admin.service.impl;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
......@@ -47,9 +48,14 @@ public class GenericServiceImpl {
public Object invoke(String service, String method, String[] parameterTypes, Object[] params) {
ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
String group = Tool.getGroup(service);
String version = Tool.getVersion(service);
String interfaze = Tool.getInterface(service);
reference.setGeneric(true);
reference.setApplication(applicationConfig);
reference.setInterface(service);
reference.setInterface(interfaze);
reference.setVersion(version);
reference.setGroup(group);
GenericService genericService = reference.get();
return genericService.$invoke(method, parameterTypes, params);
}
......
......@@ -21,6 +21,7 @@ import org.apache.dubbo.admin.common.util.Constants;
import org.apache.dubbo.admin.common.util.Pair;
import org.apache.dubbo.admin.common.util.ParseUtils;
import org.apache.dubbo.admin.common.util.SyncUtils;
import org.apache.dubbo.admin.common.util.Tool;
import org.apache.dubbo.admin.model.domain.Provider;
import org.apache.dubbo.admin.model.dto.ServiceDTO;
import org.apache.dubbo.admin.service.OverrideService;
......@@ -460,21 +461,12 @@ public class ProviderServiceImpl extends AbstractService implements ProviderServ
for (Provider provider : providers) {
String app = provider.getApplication();
String service = provider.getService();
String group = null;
String version = null;
int i = service.indexOf("/");
if (i >= 0) {
group = service.substring(0, i);
service = service.substring(i + 1);
}
i = service.lastIndexOf(":");
if (i >= 0) {
version = service.substring(i + 1);
service = service.substring(0, i);
}
String group = Tool.getGroup(service);
String version = Tool.getVersion(service);
String interfaze = Tool.getInterface(service);
ServiceDTO s = new ServiceDTO();
s.setAppName(app);
s.setService(service);
s.setService(interfaze);
s.setGroup(group);
s.setVersion(version);
result.add(s);
......
......@@ -46,28 +46,6 @@
</v-card>
</v-flex>
</v-layout>
<!--<v-flex xs12>-->
<!--<search v-model="filter" :label="$t('placeholders.searchService')"-->
<!--:hint="$t('testModule.searchServiceHint')"-->
<!--:submit="search"></search>-->
<!--</v-flex>-->
<!--<v-flex xs12>-->
<!--<v-autocomplete-->
<!--flat-->
<!--hide-no-data-->
<!--v-model="service"-->
<!--:loading="loading"-->
<!--:search-input.sync="filter"-->
<!--:hint="$t('testModule.searchServiceHint')"-->
<!--:items="services"-->
<!--item-value="service"-->
<!--item-text="service"-->
<!--:label="$t('placeholders.searchService')"-->
<!--persistent-hint-->
<!--@keyup.enter="search"-->
<!--clearable-->
<!--&gt;</v-autocomplete>-->
<!--</v-flex>-->
<v-flex xs12>
<h3>{{$t('methods')}}</h3>
</v-flex>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册