background preloader

Gson - A Java library to convert JSON to Java objects and vice-versa

Gson - A Java library to convert JSON to Java objects and vice-versa
Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of. There are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes; something that you can not do if you do not have access to the source-code. Gson Goals Provide simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa Allow pre-existing unmodifiable objects to be converted to and from JSON Extensive support of Java Generics Allow custom representations for objects Support arbitrarily complex objects (with deep inheritance hierarchies and extensive use of generic types) Gson Documentation Please use the google-gson Google Group to discuss Gson, or to post questions. Gson Tutorial by StudyTrails

Page Speed SDK released; HAR to Page Speed tool created Monday, May 3rd, 2010 Releasing the Page Speed SDK (all open source) is one step closer to having a common performance metric across all web development tools and environments. Imagine being able to get the same performance analysis results from Firebug, Web Inspector, HttpWatch, Fiddler, Keynote, and Gomez. This will help us develop a common vocabulary and bring more consistency and quality to the field of web performance optimization. This is a quote from Steve on the new HAR to Page Speed work that he has built on top of other work: The importance of an industry standard HTTP archive format is huge. Once you upload a HAR file you get page speed info and more: For a full example, check out a CNN.com archive.

Client-Side Profiling with Selenium 2 - The Automated Tester Tue 23 Nov 2010 Last year David Henderson and I gave a talk at GTAC about how we built a framework to capture the client-side performance of a page using Selenium and YSlow. It was a really interesting project that we did and it got my hooked on Client-side performance metrics. Client-side performance is really important, so much so that venture capitalists look at this before and after they invest in a startup. This year I was chatting to Patrick Lightbody, from BrowserMob, and he was telling me how cool it would be to capture the network traffic and then in a separate task run PageSpeed or YSlow. So this is great that it records but now that we have the data we need to run PageSpeed or YSlow. The code that I created is available on GitHub. ShareThisArea: blog

3 Tools To Track Search Engine, Social Media and Speed Performance of Your Site As web Startups of the new age we are dependent on Google, Facebook, Twitter and other platforms a lot for traffic and spreading the word. We generally fail to keep a track of our performance on these platforms or mostly don’t know what to track and improve. Here are 3 tools that let you judge your Website Speed, Social Media Image and Search Engine standings. Speed Optimization – GTmetrix is webpage speed analysis tool that tracks your page for load time and gives you a list of potential improvement areas. Social Media Tracking – SocialMention is a social media search and analysis platform. Search Engine – SEO-Browser is crawler that gives you a basic view of what Google’s (or any other search Engine) crawler will see in your page. These tools only let you measure the performance. Share some tools that you have been using at your startup to track performance. [Naman is a startup enthusiast and has worked with couple of Indian startups as Product Manager.

Buzz - 富士施乐P105b 黑白激光打印机 赠大容量原装粉盒两个 施乐105B-淘宝商城 2010年11月底,富士施乐发布了新款SLED打印产品,同时邀请了著名影星梁朝伟先生为富士施乐品牌进行代言,提出了“小小环保举动,大大改变地球”的环保理念。这次发布的新品皆采用了目前最为先进的SLED技术,我们测试其中一款入门级黑白输出产品DocuPrint P105b,这款产品具有体积小巧、输出速度快等优点,而独特的SLED技术和EA环保墨粉的加入让这款产品到底如何与众不同呢?接下来的内容将为您一一解答。 富士施乐DocuPrint P105b深度评测 ●入门级激光产品市场分析 对于个人办公、家庭用户和小型用户组来说,文字和文档的输出频率最多,而同样的需求上,彩色的喷墨打印机与黑白的激光打印机成为了两难选择。 富士施乐DocuPrint P105b打印机产品外观 作为激光打印机的鼻祖,富士施乐在去年11月底发布了采用SLED的新品,其中的P105b作为入门黑白激光产品的代表也让人们眼前一亮。 第2页:外形设计精巧时尚 ●外形设计精巧时尚 富士施乐P105b在外形的设计上既没有采用如常见的黑色磨砂设计,也没有使用钢琴烤漆的方案,用户甚至很难从其外形中找到商务打印的风格。 富士施乐DocuPrint P105b银灰色版外观 富士施乐DocuPrint P105b粉色版外观 富士施乐DocuPrint P105b前面板 为节省空置时的占地面积,P105b在机身上加入了折叠式设计理念。 第3页:细节见证老牌实力 ●细节见证老牌实力 作为一个老牌激光打印厂商,其生产的产品在细节上也有很多亮点值得我们关注,如P105b在外壳上使用的是较薄的面板,但在其内部通过纵向拉筋的方法维持其强度,这样的设计不仅减少了材料的使用节约了能源,还在一定程度上降低了产品的重量,产品外包装上采用塑料提手设计,方便用户搬运。 由于该产品在出纸托盘处使用了折叠设计,为锁紧合上的出纸托盘该产品既没有采用锁扣式设计,也没有在转轴处采用阻尼器材,而是利用材料简单的形变原理配合突起来固定,这种设计看起来虽然简单,但却要精细到毫米的工业制造水平才能实现。 富士施乐DocuPrint P105b碳粉仓 这些种设计虽然好处较多,但缺点也十分明显,经过长时间使用,这种塑料材质的磨损必然严重影响其功能的使用。 第4页:SLED在黑白机上到底有何优势 ●SLED在黑白机上到底有何优势 既然P105b使用的是富士施乐独家的SLED技术,那么到底SLED有何优势呢?

Improving Axis2 client http transport performance Although Axis2 supports a many transports http is the highly used one. Axis2 uses Apache HttpClient to implement its http transports sender. By default Axis2 creates a new http client object per invocation. This causes a new MultiThreadedHttpConnectionManager object being created for each invocation. Following code shows this settings. // creates a new connection manager and a http client objectMultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); HttpClient httpClient = new HttpClient(httpConnectionManager); try { client = new ServiceClient(null, null); Options opts = new Options(); client.setOptions(opts); opts.setTo(new EndpointReference(" opts.setAction("urn:TestInOutService"); OMElement payload = buildSoapObject( "" ); System.out.println("Sending the request ...." + System.currentTimeMillis()); } catch (Exception e) { e.printStackTrace(); } finally { if (client !

a blog called foo: HTTP connection reuse in Android Alright, time for something new and hopefully useful, re-using HTTP connections in your application. I've yet to write an Android application that doesn't make any HTTP requests, and they tend to do it frequently. Since all of my applications are also heavily concurrent, passing around a default HttpClient instance will give you thread contention issues and possibly bad dreams later that night. Establishing a new TCP connection to the same server for each request is wasteful, so I'd like to be able to re-use those connections, via the same HttpClient, and do so in a thread safe way. This is easily accomplished with a singleton/factory thingy like so: public class HttpClientFactory { private static DefaultHttpClient client; public synchronized static DefaultHttpClient getThreadSafeClient() { if (client ! client = new DefaultHttpClient(); ClientConnectionManager mgr = client.getConnectionManager(); return client; } } Now whenever you need an HttpClient instance in your app, you can just do this:

Benchmarking Node.js – basic performance tests against Apache + PHP | Change(b)log Several days ago I have done few very basic performance tests to see how node.js server behaves compared to Apache when serving very simple pages. All tests were executed on dual-core Intel T4200 2 GHZ machine with 4 GB RAM running Ubuntu 10.04 Lucid (with X). For comparison I have used node.js 0.1.103 on one side, and Apache 2.2.14 with prefork MPM and PHP 5.2.10 on the other, hitting them with ApacheBench 2.3 and total of 100,000 request with 1,000 concurrent requests during first test: ab -r -n 100000 -c 1000 <url> and then with total of 1,000,000 requests and 20,000 concurrent requests during the second one: ab -r -n 1000000 -c 20000 <url> Basic "Hello World" node.js server used for testing: and equally basic "Hello World" PHP file for Apache: Results 1) Total request: 100,000; concurrency level: 1,000 node.js results: Apache results: CPU Usage: node.js vs Apache/PHP in ApacheBench test - 100k requests, 1k concurrent requests 2) Total requests: 1,000,000; concurrency level: 20,000 Conclusions

对mongodb进行java编程_谁说没枪头就捅不死人 在 Java中和mongodb交互的最直接的选择就是使用MongoDB Java Driver,其下载地址是: 说,在Java中操作mongodb的API还是很简洁,下面对其一些常见的使用做些介绍。 1、连接数据库 和mongodb建立连接的示例代码如下: Mongo m =new Mongo("localhost",27017); DB db = m.getDB("db_test"); 尽 管这里获得了表示mongodb的db_test数据库连接的对象db,但这时并没有真正和mongodb建立连接,所以即便这时数据库没起来也不会抛出 异常,尽管你还是需要catch它的实例化过程。 2、取得DBCollection mongodb中的collection在Java中使用DBCollection表示(这是一个抽象类,尽管你不必需要知道),创建DBCollection实例也是一行代码,和创建DB实例一样,这个操作并不涉及真正的和数据库之间的通信。 DBCollection coll = db.getCollection("collection1"); 要获得类似mysql中“show tables”功能,可以使用如下代码: Set for(String s : colls){ System.out.println(s); }3、插入文档 mongodb 存储JSON格式的文档,而在Java中表示这种数据格式的最简便的类就是Map了。 DBCollection coll = db.getCollection("collection1"); BasicDBObject doc =new BasicDBObject(); doc.put("name", "kafka0102"); doc.put("age", 28); doc.put("time", newDate()); coll.insert(doc); mongodb 中每个插入的文档会产生个唯一标识_id。 insert函数也支持插入文档列表: insert(List 而提交操作也有update( DBObject q , DBObject o )、remove( DBObject o )。 4、查询文档4.1、findOne

Scaling Twitter: Making Twitter 10000 Percent Faster Update 6: Some interesting changes from Twitter's Evan Weaver: everything in RAM now, database is a backup; peaks at 300 tweets/second; every tweet followed by average 126 people; vector cache of tweet IDs; row cache; fragment cache; page cache; keep separate caches; GC makes Ruby optimization resistant so went with Scala; Thrift and HTTP are used internally; 100s internal requests for every external request; rewrote MQ but kept interface the same; 3 queues are used to load balance requests; extensive A/B testing for backwards capability; switched to C memcached client for speed; optimize critical path; faster to get the cached results from the network memory than recompute them locally.Update 5: Twitter on Scala. A Conversation with Steve Jenson, Alex Payne, and Robey Pointer by Bill Venners. Twitter started as a side project and blew up fast, going from 0 to millions of page views within a few terrifying months.

Related: