Java Code Examples for org.apache.dubbo.common.URL#getParameter()
The following examples show how to use
org.apache.dubbo.common.URL#getParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboCommonPanel.java From jmeter-plugins-for-apache-dubbo with Apache License 2.0 | 6 votes |
private void doChange(String key) { String address = (StringUtils.isBlank(Constants.DEFAULT_PANEL_ADDRESS) ? addressText.getText() : Constants.DEFAULT_PANEL_ADDRESS); ProviderService providerService = ProviderService.get(address); Map<String, URL> provider = providerService.findByService(key); if (provider != null && !provider.isEmpty()) { URL url = new ArrayList<URL>(provider.values()).get(0); String group = url.getParameter(com.alibaba.dubbo.common.Constants.GROUP_KEY); String version = url.getParameter(com.alibaba.dubbo.common.Constants.VERSION_KEY); String timeout = url.getParameter(com.alibaba.dubbo.common.Constants.TIMEOUT_KEY); String protocol = url.getProtocol() + "://"; String interfaceName = url.getServiceInterface(); String method = url.getParameter(com.alibaba.dubbo.common.Constants.METHODS_KEY); groupText.setText(group); versionText.setText(version); timeoutText.setText(timeout); rpcProtocolText.setSelectedItem(protocol); interfaceText.setText(interfaceName); //set method String[] items = method.split(","); methodList.setModel(new DefaultComboBoxModel<String>(items)); } else { methodList.setModel(new DefaultComboBoxModel<String>(new String[]{})); } }
Example 2
Source File: NacosRegistry.java From dubbo-registry-nacos with Apache License 2.0 | 5 votes |
private Instance createInstance(URL url) { // Append default category if absent String category = url.getParameter(CATEGORY_KEY, DEFAULT_CATEGORY); URL newURL = url.addParameter(CATEGORY_KEY, category); newURL = newURL.addParameter(PROTOCOL_KEY, url.getProtocol()); newURL = newURL.addParameter(PATH_KEY, url.getPath()); String ip = url.getHost(); int port = url.getPort(); Instance instance = new Instance(); instance.setIp(ip); instance.setPort(port); instance.setMetadata(new HashMap<>(newURL.getParameters())); return instance; }
Example 3
Source File: NacosServiceName.java From dubbo-registry-nacos with Apache License 2.0 | 5 votes |
public NacosServiceName(URL url) { serviceInterface = url.getParameter(INTERFACE_KEY); category = isConcrete(serviceInterface) ? DEFAULT_CATEGORY : url.getParameter(CATEGORY_KEY); version = url.getParameter(VERSION_KEY, DEFAULT_PARAM_VALUE); group = url.getParameter(GROUP_KEY, DEFAULT_PARAM_VALUE); value = toValue(); }
Example 4
Source File: NacosNamingServiceUtils.java From dubbo-registry-nacos with Apache License 2.0 | 5 votes |
private static void setServerAddr(URL url, Properties properties) { StringBuilder serverAddrBuilder = new StringBuilder(url.getHost()) // Host .append(":") .append(url.getPort()); // Port // Append backup parameter as other servers String backup = url.getParameter(BACKUP_KEY); if (backup != null) { serverAddrBuilder.append(",").append(backup); } String serverAddr = serverAddrBuilder.toString(); properties.put(SERVER_ADDR, serverAddr); }
Example 5
Source File: ApacheDubboUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * 调用方法 * * @param c * @param method * @param fullUrl * @param args * @return * @throws java.lang.Exception */ public static Object invoke(Class c, Method method, String fullUrl, Object... args) throws Exception { URL url = URL.valueOf(fullUrl); AsyncToSyncInvoker<?> invoker = (AsyncToSyncInvoker<?>) PROTOCOL.refer(c, url); if (invoker.isAvailable()) { Invocation inv = new RpcInvocation(method, url.getParameter("interface"), args); Result ret = invoker.invoke(inv); PROTOCOL.destroy(); return JSON.json(ret.getValue()); } return null; }
Example 6
Source File: DubboGenericServiceFactory.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
private ReferenceBean<GenericService> build(ServiceRestMetadata serviceRestMetadata, Map<String, Object> dubboTranslatedAttributes) { String urlValue = serviceRestMetadata.getUrl(); URL url = URL.valueOf(urlValue); String interfaceName = url.getServiceInterface(); String version = url.getParameter(VERSION_KEY); String group = url.getParameter(GROUP_KEY); return build(interfaceName, version, group, dubboTranslatedAttributes); }
Example 7
Source File: DubboServiceMetadataRepository.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
private DubboMetadataService initDubboMetadataServiceProxy( URL dubboMetadataServiceURL) { String serviceName = dubboMetadataServiceURL.getParameter(APPLICATION_KEY); String version = dubboMetadataServiceURL.getParameter(VERSION_KEY); // Initialize DubboMetadataService with right version return dubboMetadataConfigServiceProxy.initProxy(serviceName, version); }
Example 8
Source File: AbstractSpringCloudRegistry.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
public AbstractSpringCloudRegistry(URL url, DiscoveryClient discoveryClient, DubboServiceMetadataRepository dubboServiceMetadataRepository, DubboMetadataServiceProxy dubboMetadataConfigServiceProxy, JSONUtils jsonUtils, DubboGenericServiceFactory dubboGenericServiceFactory, ConfigurableApplicationContext applicationContext) { super(url); this.servicesLookupInterval = url .getParameter(SERVICES_LOOKUP_INTERVAL_PARAM_NAME, 60L); this.discoveryClient = discoveryClient; this.repository = dubboServiceMetadataRepository; this.dubboMetadataConfigServiceProxy = dubboMetadataConfigServiceProxy; this.jsonUtils = jsonUtils; this.dubboGenericServiceFactory = dubboGenericServiceFactory; this.applicationContext = applicationContext; }
Example 9
Source File: AbstractSpringCloudRegistry.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
protected boolean shouldRegister(URL url) { String side = url.getParameter(SIDE_KEY); boolean should = PROVIDER_SIDE.equals(side); // Only register the Provider. if (!should) { if (logger.isDebugEnabled()) { logger.debug("The URL[{}] should not be registered.", url.toString()); } } return should; }
Example 10
Source File: AbstractSpringCloudRegistry.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
private List<URL> getExportedURLs(DubboMetadataService dubboMetadataService, URL url) { String serviceInterface = url.getServiceInterface(); String group = url.getParameter(GROUP_KEY); String version = url.getParameter(VERSION_KEY); // The subscribed protocol may be null String subscribedProtocol = url.getParameter(PROTOCOL_KEY); String exportedURLsJSON = dubboMetadataService.getExportedURLs(serviceInterface, group, version); return jsonUtils.toURLs(exportedURLsJSON).stream() .filter(exportedURL -> subscribedProtocol == null || subscribedProtocol.equalsIgnoreCase(exportedURL.getProtocol())) .collect(Collectors.toList()); }
Example 11
Source File: AbstractSpringCloudRegistry.java From spring-cloud-alibaba with Apache License 2.0 | 5 votes |
private void subscribeDubboMetadataServiceURLs(URL url, NotifyListener listener) { String serviceInterface = url.getServiceInterface(); String group = url.getParameter(GROUP_KEY); String version = url.getParameter(VERSION_KEY); String protocol = url.getParameter(PROTOCOL_KEY); List<URL> urls = repository.findSubscribedDubboMetadataServiceURLs( serviceInterface, group, version, protocol); listener.notify(urls); }
Example 12
Source File: NacosRegistry.java From dubbo-registry-nacos with Apache License 2.0 | 4 votes |
private void appendIfPresent(StringBuilder target, URL url, String parameterName) { String parameterValue = url.getParameter(parameterName); if (!org.apache.commons.lang3.StringUtils.isBlank(parameterValue)) { target.append(SERVICE_NAME_SEPARATOR).append(parameterValue); } }
Example 13
Source File: NacosRegistry.java From dubbo-registry-nacos with Apache License 2.0 | 4 votes |
private void filterServiceNames(Set<String> serviceNames, URL url) { final List<String> categories = getCategories(url); final String targetServiceInterface = url.getServiceInterface(); final String targetVersion = url.getParameter(VERSION_KEY, ""); final String targetGroup = url.getParameter(GROUP_KEY, ""); filterData(serviceNames, serviceName -> { // split service name to segments // (required) segments[0] = category // (required) segments[1] = serviceInterface // (optional) segments[2] = version // (optional) segments[3] = group String[] segments = serviceName.split(SERVICE_NAME_SEPARATOR, -1); int length = segments.length; if (length != 4) { // must present 4 segments return false; } String category = segments[CATEGORY_INDEX]; if (!categories.contains(category)) { // no match category return false; } String serviceInterface = segments[SERVICE_INTERFACE_INDEX]; // no match service interface if (!WILDCARD.equals(targetServiceInterface) && !StringUtils.isEquals(targetServiceInterface, serviceInterface)) { return false; } // no match service version String version = segments[SERVICE_VERSION_INDEX]; if (!WILDCARD.equals(targetVersion) && !StringUtils.isEquals(targetVersion, version)) { return false; } String group = segments[SERVICE_GROUP_INDEX]; return group == null || WILDCARD.equals(targetGroup) || StringUtils.isEquals(targetGroup, group); }); }
Example 14
Source File: NacosNamingServiceUtils.java From dubbo-registry-nacos with Apache License 2.0 | 4 votes |
private static void putPropertyIfAbsent(URL url, Properties properties, String propertyName, String defaultValue) { String propertyValue = url.getParameter(propertyName); putPropertyIfAbsent(properties, propertyName, propertyValue, defaultValue); }
Example 15
Source File: NacosNamingServiceUtils.java From dubbo-registry-nacos with Apache License 2.0 | 2 votes |
/** * The group of {@link NamingService} to register * * @param connectionURL {@link URL connection url} * @return non-null, "default" as default * @since 2.7.5 */ public static String getGroup(URL connectionURL) { return connectionURL.getParameter("nacos.group", DEFAULT_GROUP); }