类 URL
- java.lang.Object
-
- org.apache.dubbo.common.URL
-
- 所有已实现的接口:
Serializable
- 直接已知子类:
ServiceAddressURL,ServiceConfigURL
public class URL extends Object implements Serializable
URL - Uniform Resource Locator (Immutable, ThreadSafe)url example:
- http://www.facebook.com/friends?param1=value1¶m2=value2
- http://username:password@10.20.130.230:8080/list?version=1.0.0
- ftp://username:password@192.168.1.7:21/1/read.txt
- registry://192.168.1.7:9090/org.apache.dubbo.service1?param1=value1¶m2=value2
Some strange example below:
- 192.168.1.3:20880
for this case, url protocol = null, url host = 192.168.1.3, port = 20880, url path = null - file:///home/user1/router.js?type=script
for this case, url protocol = file, url host = null, url path = home/user1/router.js - file://home/user1/router.js?type=script
for this case, url protocol = file, url host = home, url path = user1/router.js - file:///D:/1/router.js?type=script
for this case, url protocol = file, url host = null, url path = D:/1/router.js - file:/D:/1/router.js?type=script
same as above file:///D:/1/router.js?type=script - /home/user1/router.js?type=script
for this case, url protocol = null, url host = null, url path = home/user1/router.js - home/user1/router.js?type=script
for this case, url protocol = null, url host = home, url path = user1/router.js
-
-
构造器概要
构造器 构造器 说明 URL(String protocol, String host, int port)URL(String protocol, String host, int port, String path)URL(String protocol, String host, int port, String[] pairs)URL(String protocol, String host, int port, String path, String... pairs)URL(String protocol, String host, int port, String path, Map<String,String> parameters)URL(String protocol, String host, int port, Map<String,String> parameters)URL(String protocol, String username, String password, String host, int port, String path)URL(String protocol, String username, String password, String host, int port, String path, String... pairs)URL(String protocol, String username, String password, String host, int port, String path, Map<String,String> parameters)URL(URLAddress urlAddress, URLParam urlParam)URL(URLAddress urlAddress, URLParam urlParam, Map<String,Object> attributes)
-
方法概要
-
-
-
构造器详细资料
-
URL
public URL(URLAddress urlAddress, URLParam urlParam)
-
URL
public URL(URLAddress urlAddress, URLParam urlParam, Map<String,Object> attributes)
-
URL
public URL(String protocol, String host, int port, String path, Map<String,String> parameters)
-
URL
public URL(String protocol, String username, String password, String host, int port, String path)
-
URL
public URL(String protocol, String username, String password, String host, int port, String path, String... pairs)
-
-
方法详细资料
-
valueOf
public static URL valueOf(String url)
parse decoded url string, formatted dubbo://host:port/path?param=value, into strutted URL.- 参数:
url- , decoded url string- 返回:
-
valueOf
public static URL valueOf(String url, ScopeModel scopeModel)
-
valueOf
public static URL valueOf(String url, boolean encoded)
parse normal or encoded url string into strutted URL: - dubbo://host:port/path?param=value - URL.encode("dubbo://host:port/path?param=value")- 参数:
url- , url stringencoded- , encoded or decoded- 返回:
-
getUrlAddress
public URLAddress getUrlAddress()
-
getUrlParam
public URLParam getUrlParam()
-
getProtocol
public String getProtocol()
-
getUsername
public String getUsername()
-
getPassword
public String getPassword()
-
getAuthority
public String getAuthority()
refer to https://datatracker.ietf.org/doc/html/rfc3986- 返回:
- authority
-
getUserInformation
public String getUserInformation()
refer to https://datatracker.ietf.org/doc/html/rfc3986- 返回:
- user information
-
getHost
public String getHost()
-
getPort
public int getPort()
-
setPort
public URL setPort(int port)
-
getPort
public int getPort(int defaultPort)
-
getAddress
public String getAddress()
-
getIp
public String getIp()
-
getBackupAddress
public String getBackupAddress()
-
getBackupAddress
public String getBackupAddress(int defaultPort)
-
getPath
public String getPath()
-
getAbsolutePath
public String getAbsolutePath()
-
getParameters
public Map<String,String> getParameters(Predicate<String> nameToSelect)
Get the parameters to be selected(filtered)
-
getParameter
public <T> T getParameter(String key, Class<T> valueType)
Get parameter- 类型参数:
T- the type of parameter value- 参数:
key- the key of parametervalueType- the type of parameter value- 返回:
- get the parameter if present, or
null - 从以下版本开始:
- 2.7.8
-
getParameter
public <T> T getParameter(String key, Class<T> valueType, T defaultValue)
Get parameter- 类型参数:
T- the type of parameter value- 参数:
key- the key of parametervalueType- the type of parameter valuedefaultValue- the default value if parameter is absent- 返回:
- get the parameter if present, or
defaultValuewill be used. - 从以下版本开始:
- 2.7.8
-
setScopeModel
public URL setScopeModel(ScopeModel scopeModel)
-
getScopeModel
public ScopeModel getScopeModel()
-
getOrDefaultFrameworkModel
public FrameworkModel getOrDefaultFrameworkModel()
-
getOrDefaultApplicationModel
public ApplicationModel getOrDefaultApplicationModel()
-
getApplicationModel
public ApplicationModel getApplicationModel()
-
getOrDefaultModuleModel
public ModuleModel getOrDefaultModuleModel()
-
setServiceModel
public URL setServiceModel(ServiceModel serviceModel)
-
getServiceModel
public ServiceModel getServiceModel()
-
getParameter
public double getParameter(String key, double defaultValue)
-
getParameter
public float getParameter(String key, float defaultValue)
-
getParameter
public long getParameter(String key, long defaultValue)
-
getParameter
public int getParameter(String key, int defaultValue)
-
getParameter
public short getParameter(String key, short defaultValue)
-
getParameter
public byte getParameter(String key, byte defaultValue)
-
getPositiveParameter
public float getPositiveParameter(String key, float defaultValue)
-
getPositiveParameter
public double getPositiveParameter(String key, double defaultValue)
-
getPositiveParameter
public long getPositiveParameter(String key, long defaultValue)
-
getPositiveParameter
public int getPositiveParameter(String key, int defaultValue)
-
getPositiveParameter
public short getPositiveParameter(String key, short defaultValue)
-
getPositiveParameter
public byte getPositiveParameter(String key, byte defaultValue)
-
getParameter
public char getParameter(String key, char defaultValue)
-
getParameter
public boolean getParameter(String key, boolean defaultValue)
-
hasParameter
public boolean hasParameter(String key)
-
getMethodParameterAndDecoded
public String getMethodParameterAndDecoded(String method, String key, String defaultValue)
-
getMethodParameter
public String getMethodParameter(String method, String key, String defaultValue)
-
getMethodParameter
public double getMethodParameter(String method, String key, double defaultValue)
-
getMethodPositiveParameter
public double getMethodPositiveParameter(String method, String key, double defaultValue)
-
getMethodPositiveParameter
public float getMethodPositiveParameter(String method, String key, float defaultValue)
-
getMethodPositiveParameter
public long getMethodPositiveParameter(String method, String key, long defaultValue)
-
getMethodPositiveParameter
public int getMethodPositiveParameter(String method, String key, int defaultValue)
-
getMethodPositiveParameter
public short getMethodPositiveParameter(String method, String key, short defaultValue)
-
getMethodPositiveParameter
public byte getMethodPositiveParameter(String method, String key, byte defaultValue)
-
getMethodParameter
public boolean getMethodParameter(String method, String key, boolean defaultValue)
-
hasMethodParameter
public boolean hasMethodParameter(String method)
-
isLocalHost
public boolean isLocalHost()
-
isAnyHost
public boolean isAnyHost()
-
addParameter
public URL addParameter(String key, CharSequence value)
-
addParameters
public URL addParameters(Map<String,String> parameters)
Add parameters to a new url.- 参数:
parameters- parameters in key-value pairs- 返回:
- A new URL
-
removeParameters
public URL removeParameters(Collection<String> keys)
-
clearParameters
public URL clearParameters()
-
toIdentityString
public String toIdentityString()
-
toFullString
public String toFullString()
-
toParameterString
public String toParameterString()
-
toJavaURL
public URL toJavaURL()
-
toInetSocketAddress
public InetSocketAddress toInetSocketAddress()
-
getColonSeparatedKey
public String getColonSeparatedKey()
The format is "{interface}:[version]:[group]"- 返回:
-
getServiceKey
public String getServiceKey()
The format of return value is '{group}/{interfaceName}:{version}'- 返回:
-
getDisplayServiceKey
public String getDisplayServiceKey()
Format : interface:version- 返回:
-
getPathKey
public String getPathKey()
The format of return value is '{group}/{path/interfaceName}:{version}'- 返回:
-
getProtocolServiceKey
public String getProtocolServiceKey()
-
toServiceStringWithoutResolving
public String toServiceStringWithoutResolving()
-
toServiceString
public String toServiceString()
-
getServiceName
@Deprecated public String getServiceName()
已过时。
-
getServiceInterface
public String getServiceInterface()
-
getIntParameter
@Deprecated public int getIntParameter(String key)
已过时。Replace togetParameter(String, int)
-
getIntParameter
@Deprecated public int getIntParameter(String key, int defaultValue)
已过时。Replace togetParameter(String, int)
-
getPositiveIntParameter
@Deprecated public int getPositiveIntParameter(String key, int defaultValue)
已过时。Replace togetPositiveParameter(String, int)
-
getBooleanParameter
@Deprecated public boolean getBooleanParameter(String key)
已过时。Replace togetParameter(String, boolean)
-
getBooleanParameter
@Deprecated public boolean getBooleanParameter(String key, boolean defaultValue)
已过时。Replace togetParameter(String, boolean)
-
getMethodIntParameter
@Deprecated public int getMethodIntParameter(String method, String key)
已过时。Replace togetMethodParameter(String, String, int)
-
getMethodIntParameter
@Deprecated public int getMethodIntParameter(String method, String key, int defaultValue)
已过时。Replace togetMethodParameter(String, String, int)
-
getMethodPositiveIntParameter
@Deprecated public int getMethodPositiveIntParameter(String method, String key, int defaultValue)
已过时。Replace togetMethodPositiveParameter(String, String, int)
-
getMethodBooleanParameter
@Deprecated public boolean getMethodBooleanParameter(String method, String key)
已过时。Replace togetMethodParameter(String, String, boolean)
-
getMethodBooleanParameter
@Deprecated public boolean getMethodBooleanParameter(String method, String key, boolean defaultValue)
已过时。Replace togetMethodParameter(String, String, boolean)
-
toConfiguration
public Configuration toConfiguration()
-
putMethodParameter
public static void putMethodParameter(String method, String key, String value, Map<String,Map<String,String>> methodParameters)
-
getApplication
public String getApplication()
-
getRemoteApplication
public String getRemoteApplication()
-
getGroup
public String getGroup()
-
getVersion
public String getVersion()
-
getCategory
public String getCategory()
-
getSide
public String getSide()
-
hasAttribute
public boolean hasAttribute(String key)
-
getServiceParameter
public String getServiceParameter(String service, String key, String defaultValue)
-
getServiceParameter
public double getServiceParameter(String service, String key, double defaultValue)
-
getServiceParameter
public float getServiceParameter(String service, String key, float defaultValue)
-
getServiceParameter
public short getServiceParameter(String service, String key, short defaultValue)
-
getServiceParameter
public boolean getServiceParameter(String service, String key, boolean defaultValue)
-
getPositiveServiceParameter
public float getPositiveServiceParameter(String service, String key, float defaultValue)
-
getPositiveServiceParameter
public double getPositiveServiceParameter(String service, String key, double defaultValue)
-
getPositiveServiceParameter
public long getPositiveServiceParameter(String service, String key, long defaultValue)
-
getPositiveServiceParameter
public int getPositiveServiceParameter(String service, String key, int defaultValue)
-
getPositiveServiceParameter
public short getPositiveServiceParameter(String service, String key, short defaultValue)
-
getPositiveServiceParameter
public byte getPositiveServiceParameter(String service, String key, byte defaultValue)
-
getServiceMethodParameterAndDecoded
public String getServiceMethodParameterAndDecoded(String service, String method, String key)
-
getServiceMethodParameterAndDecoded
public String getServiceMethodParameterAndDecoded(String service, String method, String key, String defaultValue)
-
getServiceMethodParameterStrict
public String getServiceMethodParameterStrict(String service, String method, String key)
-
getServiceMethodParameter
public String getServiceMethodParameter(String service, String method, String key)
-
getServiceMethodParameter
public String getServiceMethodParameter(String service, String method, String key, String defaultValue)
-
getServiceMethodParameter
public double getServiceMethodParameter(String service, String method, String key, double defaultValue)
-
getServiceMethodParameter
public float getServiceMethodParameter(String service, String method, String key, float defaultValue)
-
getServiceMethodParameter
public long getServiceMethodParameter(String service, String method, String key, long defaultValue)
-
getServiceMethodParameter
public int getServiceMethodParameter(String service, String method, String key, int defaultValue)
-
getMethodParameter
public short getMethodParameter(String service, String method, String key, short defaultValue)
-
getServiceMethodParameter
public byte getServiceMethodParameter(String service, String method, String key, byte defaultValue)
-
hasServiceMethodParameter
public boolean hasServiceMethodParameter(String service, String method, String key)
-
toSerializableURL
public URL toSerializableURL()
-
-