本文整理汇总了Java中com.alibaba.dubbo.registry.common.route.ParseUtils类的典型用法代码示例。如果您正苦于以下问题:Java ParseUtils类的具体用法?Java ParseUtils怎么用?Java ParseUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseUtils类属于com.alibaba.dubbo.registry.common.route包,在下文中一共展示了ParseUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findMethodsByService
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
public List<String> findMethodsByService(String service) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
if(providerUrls == null || service == null || service.length() == 0) return ret;
Map<Long, URL> providers = providerUrls.get(service);
if(null == providers || providers.isEmpty()) return ret;
Entry<Long, URL> p = providers.entrySet().iterator().next();
String value = p.getValue().getParameter("methods");
if (value == null || value.length() == 0) {
return ret;
}
String[] methods = value.split(ParseUtils.METHOD_SPLIT);
if (methods == null || methods.length == 0) {
return ret;
}
for(String m : methods) {
ret.add(m);
}
return ret;
}
示例2: hasServicePrivilege
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
public boolean hasServicePrivilege(String service) {
if (service == null || service.length() == 0)
return false;
if (role == null || GUEST.equalsIgnoreCase(role)) {
return false;
}
if(ROOT.equalsIgnoreCase(role)) {
return true;
}
if (servicePrivileges != null && servicePrivileges.size() > 0) {
for (String privilege : servicePrivileges) {
boolean ok = ParseUtils.isMatchGlobPattern(privilege,service);
if (ok) {
return true;
}
}
}
return false;
}
示例3: testInterpolateCollMap_NormalCase
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testInterpolateCollMap_NormalCase() throws Exception {
List<String> expressions = new ArrayList<String>();
expressions.add("xx$var1");
expressions.add("yy${var2}zz");
Map<String, String> params = new HashMap<String, String>();
params.put("var1", "CAT");
params.put("var2", "DOG");
List<String> interpolate = ParseUtils.interpolate(expressions, params);
List<String> expected = new ArrayList<String>();
expected.add("xxCAT");
expected.add("yyDOGzz");
assertEquals(expected, interpolate);
}
示例4: testIsMatchGlobPatternsNeedInterpolate
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testIsMatchGlobPatternsNeedInterpolate() throws Exception {
Collection<String> patternsNeedInterpolate = new HashSet<String>();
Map<String, String> interpolateParams = new HashMap<String, String>();
boolean match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abc");
assertFalse(match);
patternsNeedInterpolate.add("abc*$var1");
patternsNeedInterpolate.add("123${var2}*");
interpolateParams.put("var1", "CAT");
interpolateParams.put("var2", "DOG");
match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abc");
assertFalse(match);
match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abcXXXCAT");
assertTrue(match);
match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "123DOGYYY");
assertTrue(match);
}
示例5: testReplaceMethods
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testReplaceMethods() throws Exception {
assertEquals(
"methods=aaa,bbb",
ParseUtils.replaceParameter(null, "methods", "aaa,bbb"));
assertEquals(
"methods=aaa,bbb",
ParseUtils.replaceParameter("", "methods", "aaa,bbb"));
assertEquals(
"version=1.0.0&application=morgan&weight=10&methods=aaa,bbb",
ParseUtils.replaceParameter("version=1.0.0&application=morgan&weight=10", "methods", "aaa,bbb"));
assertEquals(
"version=1.0.0&methods=ccc,ddd&application=morgan&weight=10",
ParseUtils.replaceParameter("version=1.0.0&methods=aaa,bbb&application=morgan&weight=10", "methods", "ccc,ddd"));
assertEquals(
"dubbo://172.22.3.91:20880/memberService?version=1.0.0&application=morgan&weight=10&methods=aaa,bbb",
ParseUtils.replaceParameter("dubbo://172.22.3.91:20880/memberService?version=1.0.0&application=morgan&weight=10", "methods", "aaa,bbb"));
assertEquals(
"dubbo://172.22.3.91:20880/memberService?version=1.0.0&methods=ccc,ddd&application=morgan&weight=10",
ParseUtils.replaceParameter("dubbo://172.22.3.91:20880/memberService?version=1.0.0&methods=aaa,bbb&application=morgan&weight=10", "methods", "ccc,ddd"));
assertEquals(
"dubbo://172.22.3.91:20880/memberService?version=1.0.0&methods=$ccc,$ddd&application=morgan&weight=10",
ParseUtils.replaceParameter("dubbo://172.22.3.91:20880/memberService?version=1.0.0&methods=$aaa,$bbb&application=morgan&weight=10", "methods", "$ccc,$ddd"));
}
示例6: findMethodsByService
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
public List<String> findMethodsByService(String service) {
List<String> ret = new ArrayList<String>();
ConcurrentMap<String, Map<Long, URL>> providerUrls = getRegistryCache().get(Constants.PROVIDERS_CATEGORY);
if (providerUrls == null || service == null || service.length() == 0) return ret;
Map<Long, URL> providers = providerUrls.get(service);
if (null == providers || providers.isEmpty()) return ret;
Entry<Long, URL> p = providers.entrySet().iterator().next();
String value = p.getValue().getParameter("methods");
if (value == null || value.length() == 0) {
return ret;
}
String[] methods = value.split(ParseUtils.METHOD_SPLIT);
if (methods == null || methods.length == 0) {
return ret;
}
for (String m : methods) {
ret.add(m);
}
return ret;
}
示例7: hasServicePrivilege
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
public boolean hasServicePrivilege(String service) {
if (service == null || service.length() == 0)
return false;
if (role == null || GUEST.equalsIgnoreCase(role)) {
return false;
}
if (ROOT.equalsIgnoreCase(role)) {
return true;
}
if (servicePrivileges != null && servicePrivileges.size() > 0) {
for (String privilege : servicePrivileges) {
boolean ok = ParseUtils.isMatchGlobPattern(privilege, service);
if (ok) {
return true;
}
}
}
return false;
}
示例8: addOwnersOfService
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
/**
* 添加与服务相关的Owner
*
* @param usernames 用于添加的用户名
* @param serviceName 不含通配符
*/
public static void addOwnersOfService(Set<String> usernames, String serviceName,
OwnerService ownerDAO) {
List<String> serviceNamePatterns = ownerDAO.findAllServiceNames();
for (String p : serviceNamePatterns) {
if (ParseUtils.isMatchGlobPattern(p, serviceName)) {
List<String> list = ownerDAO.findUsernamesByServiceName(p);
usernames.addAll(list);
}
}
}
示例9: addOwnersOfServicePattern
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
/**
* 添加与服务模式相关的Owner
*
* @param usernames 用于添加的用户名
* @param serviceNamePattern 服务模式,Glob模式
*/
public static void addOwnersOfServicePattern(Set<String> usernames, String serviceNamePattern,
OwnerService ownerDAO) {
List<String> serviceNamePatterns = ownerDAO.findAllServiceNames();
for (String p : serviceNamePatterns) {
if (ParseUtils.hasIntersection(p, serviceNamePattern)) {
List<String> list = ownerDAO.findUsernamesByServiceName(p);
usernames.addAll(list);
}
}
}
示例10: testParseQueryMultiKeyValue
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testParseQueryMultiKeyValue() throws Exception {
Map<String, String> result = new HashMap<String, String>();
result.put("verion", "1.0.0");
result.put("cluster", "china");
assertEquals(result, ParseUtils.parseQuery("", "verion=1.0.0&cluster=china"));
}
示例11: testInterpolateVariable
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testInterpolateVariable() throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("consumer.address", "10.20.130.230");
String regexp = ParseUtils.interpolate("xx$consumer.address", params);
assertEquals("xx10.20.130.230", regexp);
}
示例12: testInterpolateVariableWithParentheses
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testInterpolateVariableWithParentheses() throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("consumer.address", "10.20.130.230");
String regexp = ParseUtils.interpolate("xx${consumer.address}yy", params);
assertEquals("xx10.20.130.230yy", regexp);
}
示例13: testParseQueryPrefixMultiKeyValue
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testParseQueryPrefixMultiKeyValue() throws Exception {
Map<String, String> result = new HashMap<String, String>();
result.put("consumer.verion", "1.0.0");
result.put("consumer.cluster", "china");
assertEquals(result, ParseUtils.parseQuery("consumer.", "verion=1.0.0&cluster=china"));
}
示例14: test_hasIntersection
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void test_hasIntersection() throws Exception {
assertFalse(ParseUtils.hasIntersection(null, null));
assertFalse(ParseUtils.hasIntersection("dog", null));
assertFalse(ParseUtils.hasIntersection(null, "god"));
assertTrue(ParseUtils.hasIntersection("hello", "hello*"));
assertTrue(ParseUtils.hasIntersection("helloxxx", "hello*"));
assertTrue(ParseUtils.hasIntersection("world", "*world"));
assertTrue(ParseUtils.hasIntersection("xxxworld", "*world"));
assertTrue(ParseUtils.hasIntersection("helloworld", "hello*world"));
assertTrue(ParseUtils.hasIntersection("helloxxxworld", "hello*world"));
assertFalse(ParseUtils.hasIntersection("Yhelloxxxworld", "hello*world"));
assertTrue(ParseUtils.hasIntersection("hello*", "hello"));
assertTrue(ParseUtils.hasIntersection("hello*", "helloxxx"));
assertTrue(ParseUtils.hasIntersection("*world", "world"));
assertTrue(ParseUtils.hasIntersection("*world", "xxxworld"));
assertTrue(ParseUtils.hasIntersection("hello*world", "helloworld"));
assertTrue(ParseUtils.hasIntersection("hello*world", "helloxxxworld"));
assertFalse(ParseUtils.hasIntersection("hello*world", "Yhelloxxxworld"));
assertTrue(ParseUtils.hasIntersection("*world", "hello*world"));
assertTrue(ParseUtils.hasIntersection("*world", "hello*Zworld"));
assertTrue(ParseUtils.hasIntersection("helloZ*", "hello*world"));
assertFalse(ParseUtils.hasIntersection("Zhello*", "hello*world"));
assertFalse(ParseUtils.hasIntersection("hello*world", "hello*worldZ"));
assertTrue(ParseUtils.hasIntersection("hello*world", "hello*world"));
assertTrue(ParseUtils.hasIntersection("hello*world", "hello*Zworld"));
assertTrue(ParseUtils.hasIntersection("helloZ*world", "hello*world"));
assertFalse(ParseUtils.hasIntersection("Zhello*world", "hello*world"));
assertFalse(ParseUtils.hasIntersection("hello*world", "hello*worldZ"));
}
示例15: testFilterByGlobPattern
import com.alibaba.dubbo.registry.common.route.ParseUtils; //导入依赖的package包/类
@Test
public void testFilterByGlobPattern() throws Exception {
Collection<String> values = new ArrayList<String>();
values.add("abc123");
values.add("JQKxyz");
values.add("abc123");
values.add("abcLLL");
Set<String> filter = ParseUtils.filterByGlobPattern("abc*", values);
Set<String> expected = new HashSet<String>();
expected.add("abc123");
expected.add("abcLLL");
assertEquals(expected, filter);
filter = ParseUtils.filterByGlobPattern((Collection<String>)null, values);
assertTrue(filter.isEmpty());
Collection<String> patterns = new ArrayList<String>();
patterns.add("000000000");
patterns.add("abc*");
patterns.add("*xyz");
filter = ParseUtils.filterByGlobPattern(patterns, values);
expected.add("JQKxyz");
assertEquals(expected, filter);
}