不推荐使用:org.apache.http.conn.scheme.scheme不推荐使用 [英] Deprecated: org.apache.http.conn.scheme.scheme is deprecated

查看:399
本文介绍了不推荐使用:org.apache.http.conn.scheme.scheme不推荐使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码段:

schemeRegistry.register(new Scheme("https", factory, 443));    

它说Scheme的构造函数已被弃用,但老实说,我真的不明白该使用哪种新方法. 有人可以给我看一个有关如何正确使用它的简短示例吗?

It says that the constructor for Scheme is deprecated, but I honestly didn't really understand which new method to use instead. Can someone show me a brief example on how to use it properly?

使用它的完整代码如下:

the complete Code in which it is used looks like this:

        org.apache.http.conn.ssl.SSLSocketFactory factory = new org.apache.http.conn.ssl.SSLSocketFactory(clientStore, p12Password, trustStore);
        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("https", factory2, 443));

        DefaultHttpClient httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(httpParams,schemeRegistry), httpParams);

是的,新的ThreadSafeClientConnManager(httpParams,schemeRegistry)"也已被弃用,我可能为此提出另一个问题,但是开始使用Scheme东西,逐步解决所有问题是很好的.

Yes, the "new ThreadSafeClientConnManager(httpParams,schemeRegistry)" is also deprecated and I may open another Question for it, but it would be good to get started with the Scheme thing, to fix everything step by step.

致谢,并感谢您的答复 PS:这里的第一个问题,我大多数时候一直是沉默的读者,我当然期待着下次如何提问的建议,请不要太苛刻.

Regards and thanks for answers PS: First Question here, I have been a silent reader most of the time, I of course look forward to advices on how to ask questions in the next time, still don't be too harsh please.

推荐答案

As stated in the documentation, you should use this constructor instead:

Scheme(String name, int port, SchemeSocketFactory factory)

这篇关于不推荐使用:org.apache.http.conn.scheme.scheme不推荐使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆