What is SchemeRegistry in apache and When it should be used?

旧城冷巷雨未停 提交于 2019-12-13 11:50:52

问题


Apache HTTPClient contains SchemeRegistry class (org.apache.http.conn.scheme.SchemeRegistry)

  • What is Scheme Registry?
  • When can it be used?

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);

回答1:


What is Scheme Registry?

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

You end up with a custom protocol scheme (say, MYHTTP).

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.



来源:https://stackoverflow.com/questions/18146912/what-is-schemeregistry-in-apache-and-when-it-should-be-used

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!