什么是 apache 中的 SchemeRegistry 以及什么时候应该使用它? [英] What is SchemeRegistry in apache and When it should be used?
问题描述
Apache HTTPClient 包含 SchemeRegistry
类 (org.apache.http.conn.scheme.SchemeRegistry)
Apache HTTPClient contains SchemeRegistry
class (org.apache.http.conn.scheme.SchemeRegistry)
- 什么是方案注册?
- 什么时候可以使用?
如果我使用如下方案注册表会产生什么影响
What impact does it make if i use scheme registry like below
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme(WEBSERVICE_URI_SCHEME, 80 ,PlainSocketFactory.getSocketFactory()));
PoolingClientConnectionManager wsConnManager = new PoolingClientConnectionManager (registry);
推荐答案
什么是方案注册?
What is Scheme Registry?
协议方案注册表维护每个不同协议方案的连接套接字工厂的映射.例如,HTTPS 方案要求使用 TLS/SSL 保护连接.您可能还希望通过为 HTTP 和 HTTPS 方案注册自定义套接字工厂来自定义创建和初始化这些方案的套接字的方式.
Protocol scheme registry maintains a map of connection socket factories per distinct protocol scheme. For instance, HTTPS scheme requires that connections be secured with TLS/SSL. One may also want to customize the way sockets for HTTP and HTTPS schemes are created and initialized by registering a custom socket factory for those schemes.
如果我使用如下方案注册表会产生什么影响
What impact does it make if i use scheme registry like below
您最终会得到一个自定义协议方案(例如,MYHTTP
).
You end up with a custom protocol scheme (say, MYHTTP
).
每当您使用此方案(例如,myhttp://somehost/someservice/
)执行请求时,您的自定义套接字工厂将用于创建和初始化与目标服务器的传出连接.
Whenever you execute a request using this scheme (say, myhttp://somehost/someservice/
) your custom socket factory will be used to create and initialize outgoing connections to the target server.
这篇关于什么是 apache 中的 SchemeRegistry 以及什么时候应该使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!