本文整理汇总了Java中com.alibaba.dubbo.common.URL.getServiceInterface方法的典型用法代码示例。如果您正苦于以下问题:Java URL.getServiceInterface方法的具体用法?Java URL.getServiceInterface怎么用?Java URL.getServiceInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.dubbo.common.URL
的用法示例。
在下文中一共展示了URL.getServiceInterface方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Page handle(URL url) {
String provider = url.getParameterAndDecoded("provider");
if (provider == null || provider.length() == 0) {
throw new IllegalArgumentException("Please input provider parameter.");
}
URL providerUrl = URL.valueOf(provider);
RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
String parameter;
if (url.hasParameter("service")) {
parameter = "service=" + url.getParameter("service");
} else if (url.hasParameter("host")) {
parameter = "host=" + url.getParameter("host");
} else if (url.hasParameter("application")) {
parameter = "application=" + url.getParameter("application");
} else {
parameter = "service=" + providerUrl.getServiceInterface();
}
return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
示例2: handle
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Page handle(URL url) {
String consumer = url.getParameterAndDecoded("consumer");
if (consumer == null || consumer.length() == 0) {
throw new IllegalArgumentException("Please input consumer parameter.");
}
URL consumerUrl = URL.valueOf(consumer);
RegistryContainer.getInstance().getRegistry().unsubscribe(consumerUrl, NotifyListenerAdapter.NOTIFY_LISTENER);
String parameter;
if (url.hasParameter("service")) {
parameter = "service=" + url.getParameter("service");
} else if (url.hasParameter("host")) {
parameter = "host=" + url.getParameter("host");
} else if (url.hasParameter("application")) {
parameter = "application=" + url.getParameter("application");
} else {
parameter = "service=" + consumerUrl.getServiceInterface();
}
return new Page("<script type=\"text/javascript\">window.location.href=\"consumers.html?" + parameter + "\";</script>");
}
示例3: isMatch
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public static boolean isMatch(URL consumerUrl, URL providerUrl) {
String consumerInterface = consumerUrl.getServiceInterface();
String providerInterface = providerUrl.getServiceInterface();
if( ! (Constants.ANY_VALUE.equals(consumerInterface) || StringUtils.isEquals(consumerInterface, providerInterface)) ) return false;
if (! isMatchCategory(providerUrl.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY),
consumerUrl.getParameter(Constants.CATEGORY_KEY, Constants.DEFAULT_CATEGORY))) {
return false;
}
if (! providerUrl.getParameter(Constants.ENABLED_KEY, true)
&& ! Constants.ANY_VALUE.equals(consumerUrl.getParameter(Constants.ENABLED_KEY))) {
return false;
}
String consumerGroup = consumerUrl.getParameter(Constants.GROUP_KEY);
String consumerVersion = consumerUrl.getParameter(Constants.VERSION_KEY);
String consumerClassifier = consumerUrl.getParameter(Constants.CLASSIFIER_KEY, Constants.ANY_VALUE);
String providerGroup = providerUrl.getParameter(Constants.GROUP_KEY);
String providerVersion = providerUrl.getParameter(Constants.VERSION_KEY);
String providerClassifier = providerUrl.getParameter(Constants.CLASSIFIER_KEY, Constants.ANY_VALUE);
return (Constants.ANY_VALUE.equals(consumerGroup) || StringUtils.isEquals(consumerGroup, providerGroup) || StringUtils.isContains(consumerGroup, providerGroup))
&& (Constants.ANY_VALUE.equals(consumerVersion) || StringUtils.isEquals(consumerVersion, providerVersion))
&& (consumerClassifier == null || Constants.ANY_VALUE.equals(consumerClassifier) || StringUtils.isEquals(consumerClassifier, providerClassifier));
}
示例4: toServicePath
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
private String toServicePath(URL url) {
String name = url.getServiceInterface();
if (Constants.ANY_VALUE.equals(name)) {
return toRootPath();
}
return toRootDir() + URL.encode(name);
}
示例5: doNotify
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
private void doNotify(Jedis jedis, Collection<String> keys, URL url, Collection<NotifyListener> listeners) {
if (keys == null || keys.size() == 0
|| listeners == null || listeners.size() == 0) {
return;
}
long now = System.currentTimeMillis();
List<URL> result = new ArrayList<URL>();
List<String> categories = Arrays.asList(url.getParameter(Constants.CATEGORY_KEY, new String[0]));
String consumerService = url.getServiceInterface();
for (String key : keys) {
if (! Constants.ANY_VALUE.equals(consumerService)) {
String prvoiderService = toServiceName(key);
if (! prvoiderService.equals(consumerService)) {
continue;
}
}
String category = toCategoryName(key);
if (! categories.contains(Constants.ANY_VALUE) && ! categories.contains(category)) {
continue;
}
List<URL> urls = new ArrayList<URL>();
Map<String, String> values = jedis.hgetAll(key);
if (values != null && values.size() > 0) {
for (Map.Entry<String, String> entry : values.entrySet()) {
URL u = URL.valueOf(entry.getKey());
if (! u.getParameter(Constants.DYNAMIC_KEY, true)
|| Long.parseLong(entry.getValue()) >= now) {
if (UrlUtils.isMatch(url, u)) {
urls.add(u);
}
}
}
}
if (urls.isEmpty()) {
urls.add(url.setProtocol(Constants.EMPTY_PROTOCOL)
.setAddress(Constants.ANYHOST_VALUE)
.setPath(toServiceName(key))
.addParameter(Constants.CATEGORY_KEY, category));
}
result.addAll(urls);
if (logger.isInfoEnabled()) {
logger.info("redis notify: " + key + " = " + urls);
}
}
if (result == null || result.size() == 0) {
return;
}
for (NotifyListener listener : listeners) {
notify(url, listener, result);
}
}
示例6: toServicePath
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
private String toServicePath(URL url) {
return root + url.getServiceInterface();
}
示例7: invoke
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Result invoke(final Invoker<?> invoker, final Invocation invocation) throws RpcException {
if (tracer == null) {
return invoker.invoke(invocation);
}
final long startTime = System.currentTimeMillis();
final RpcContext context = RpcContext.getContext();
// 传入参数,暂不做处理
final String localIp = IpUtils.getRealIpWithStaticCache();
final int localPort = context.getLocalPort();
final URL url = context.getUrl();
final String appName = url.getParameter("application");
final String serviceName = url.getServiceInterface();
final String methodName = context.getMethodName();
final Endpoint endpoint = Endpoint.create(serviceName,localIp, localPort);
final boolean isConsumerSide = context.isConsumerSide();
Span span = null;
try {
if (isConsumerSide) { // 是否是消费者
final Span parentSpan = tracer.getParentSpan();
if (parentSpan == null) { // 为rootSpan
// 生成root Span
span = tracer.newSpan(appName, serviceName, methodName);
} else {
span = tracer.newSpan(appName, serviceName, methodName, parentSpan);
}
} else if (context.isProviderSide()) {
final String traceId = invocation.getAttachment(TracerConstant.TRACE_ID);
final String parentId = invocation.getAttachment(TracerConstant.PARENT_SPAN_ID);
final String spanId = invocation.getAttachment(TracerConstant.SPAN_ID);
final boolean sample = traceId != null;
span = tracer.genSpan(appName, serviceName, methodName, traceId, parentId, spanId, sample);
} else {
LOGGER.error("[" + url + "] [notConsumerNorProvider]");
return invoker.invoke(invocation);
}
invokerBefore(invocation, span, endpoint, startTime);
final Result result = invoker.invoke(invocation);
final Throwable throwable = result.getException();
if (throwable != null && !isConsumerSide) {
span.addException(serviceName, methodName, throwable, endpoint);
}
return result;
} catch (final RpcException ex) {
if (span != null) {
span.addException(serviceName, methodName, ex, endpoint);
}
throw ex;
} finally {
if (span != null) {
final long end = System.currentTimeMillis();
invokerAfter(endpoint, span, end, isConsumerSide); // 调用后记录annotation
}
}
}
示例8: doNotify
import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
private void doNotify(Jedis jedis, Collection<String> keys, URL url, Collection<NotifyListener> listeners) {
if (keys == null || keys.size() == 0
|| listeners == null || listeners.size() == 0) {
return;
}
long now = System.currentTimeMillis();
List<URL> result = new ArrayList<URL>();
List<String> categories = Arrays.asList(url.getParameter(Constants.CATEGORY_KEY, new String[0]));
String consumerService = url.getServiceInterface();
for (String key : keys) {
if (!Constants.ANY_VALUE.equals(consumerService)) {
String prvoiderService = toServiceName(key);
if (!prvoiderService.equals(consumerService)) {
continue;
}
}
String category = toCategoryName(key);
if (!categories.contains(Constants.ANY_VALUE) && !categories.contains(category)) {
continue;
}
List<URL> urls = new ArrayList<URL>();
Map<String, String> values = jedis.hgetAll(key);
if (values != null && values.size() > 0) {
for (Map.Entry<String, String> entry : values.entrySet()) {
URL u = URL.valueOf(entry.getKey());
if (!u.getParameter(Constants.DYNAMIC_KEY, true)
|| Long.parseLong(entry.getValue()) >= now) {
if (UrlUtils.isMatch(url, u)) {
urls.add(u);
}
}
}
}
if (urls.isEmpty()) {
urls.add(url.setProtocol(Constants.EMPTY_PROTOCOL)
.setAddress(Constants.ANYHOST_VALUE)
.setPath(toServiceName(key))
.addParameter(Constants.CATEGORY_KEY, category));
}
result.addAll(urls);
if (logger.isInfoEnabled()) {
logger.info("redis notify: " + key + " = " + urls);
}
}
if (result == null || result.size() == 0) {
return;
}
for (NotifyListener listener : listeners) {
notify(url, listener, result);
}
}