Client.create()耗时太长。
来源:互联网 发布:优酷客户端网络错误 编辑:程序博客网 时间:2024/04/19 20:38
jersey,一个REST风格服务的开发框架。
现在jersey从1.0升级了到了1.0.1,解决了广大的jerseyer抱怨的初始化Client时的耗时太长的问题。
以前使用jersey Client的时候,必须要先通过Client.create()来创建一下Client,我测试了一下,当我循环创建1000个Client时,耗时基本上达到了1分钟左右。
现在我们完全可以通过spring来注入一个Client,这样我们完全省略了Client.create()一步了。
这个是以前的代码
public Class ClientTestOld(){ public String getHelloWorld(){ String url = "http://localhost/helloworld"; Client c = Client.create(); WebResource r = c.resource(url); return r.get(String.class); }}
现在的代码
public Class ClientTestNew(){ @Resource private Client client; public String getHelloWorld(){ String url = "http://localhost/helloworld"; WebResource r = client.resource(url); return r.get(String.class); }}
当然还需要在applicationContext.xml中加入如下配置:
<bean id="jerseyClient" class="com.sun.jersey.api.client.Client" /><bean id="clientTest" class="com.tianji.www.jersey.client.ClientTestNew" p:client-ref="jerseyClient"/>
pom.xml中jersey依赖也要改成1.0.1,不过jersey-spring现在还只是1.0.1-SNAPSHOT,要注意哦!
- Client.create()耗时太长。
- ICE 域名解析耗时太长
- ruby on rails: bundle install 耗时太长
- 暂时解决 Android-Studio 编译耗时(好久、太长)问题
- Create CXF Client
- 给client端create file
- create client with axis1.4
- 性能问题: SQL*Net message from client 等待时间太长
- Create Ocx control CLIENT Application step by step (VS 2008)
- WCF (Windows Communication Foundation) Create & Implement a WCF Client
- Create NFS server and mount on client on Linux
- create
- create
- Create
- Create
- sql 耗时
- 耗时widget
- printf 耗时
- Android之MessageQueue、Looper、Handler与消息循环
- javascript 常用
- Struts下载文件
- Java的23种设计模式
- Hadoop1.0.3 集群配置
- Client.create()耗时太长。
- java播放wav的基础代码
- winform另一类的程序自动重启
- Winlogon登录和GINA -- NTShellGINA源代码
- HDU 2563 递推思路
- hdu3590 PP and QQ-----删边游戏&&anti--sg
- string字符串常用处理方法
- window.onload 和 $(document).ready的 区别
- sax 解析 xml异常 Invalid byte 2 of 2-byte UTF-8 sequence