Archive | December, 2007

Axis2 vs XFire

Recently, I have assigned a web service project to one of my developers. To provide a guideline to choose the stack, I need to look into the solution provided by Axis and XFire again. Previously, it is no brainer in favor of XFire because Axis 1 is using DOM based parser whereas XFire is using StAX. Now, Axis 2 has come out that uses StAX parser as well. After a series of benchmark comparison and arguments from both parties. I feel that picking either framework isn’t likely to matter much. And if it does matter, make sure you chose the proper databinding toolkit as that will have the biggest affect on your performance.

For XFire, it uses JAXB for databinding by default that you are replaced with JiBX. Why JiBX is faster? The reason is JAXB uses reflection to populate the bean whereas JiBX uses byte code generation. According to Dan, JiBX has significant performance improvements. [code]]czoyMjA6XCIgSmlCWCBjYW4gcHJvdmlkZSBzaWduaWZpY2FudCBwZXJmb3JtYW5jZSBpbXByb3ZlbWVudHMgb3ZlciBKQVhCIGFzIGl7WyYqJl19dCBkb2VzIG5vdCB1c2UgcmVmbGVjdGlvbiwgYnV0IGluc3RlYWQgZG9lcyBieXRlIGNvZGUgZ2VuZXJhdGlvbiB0byBvcHRpbWl6ZXtbJiomXX0gZGF0YWJpbmRpbmcgLSA8YSBocmVmPVwiaHR0cDovL25ldHpvb2lkLmNvbS9ibG9nL1wiIHRhcmdldD1cIl9ibGFua1wiPkRhbjwvYT4gXCJ7WyYqJl19O3tbJiomXX0=[[/code]

For Axis2, it creates its own databinding solution named ADB and it is comparable with JiBX. So, Axis2 really has caught up its competitors in term of performance. Whether I will switch to use Axis2. Probably not. Because I don’t see it worth the hassle to learn another databinding solution and WS framework that gives you practically the same thing that XFire already provided. By switching to a StAX based framework you’re likely to see something like a 3-5x speedup (or something like 30x if you switch from rpc/encoded to doc/literal as well). This can make a significant difference in your application’s responsiveness and load handling. As long as you are using StAX, you are good. Oh, before I forget. For anyone who is using XFire or attempt to use XFire, please look at Apache CXF. According to XFire, CXF is XFire 2.0. I am excited to see those new features from CXF:

  1. Spring 2.0 XML support
  2. RESTful service support
  3. JSON support
  4. And some of WS specs support as well

Here is what I found from XFire site: We encourage all users who are currently evaluating XFire to use CXF instead at this point. If you are already an XFire user, you may wish to consider migrating to CXF depending on where you are in your own release cycle. We will continue to support XFire in the future with bug fix releases, but feature development will be focused on CXF. * UPDATE * 12/6/2007: Apache CXF 2.0 currently doesn’t support JiBX. It is expecting to support it for CXF 2.1. Reference http://www.infoq.com/news/2007/02/axis2-xfire-benchmark

Leave a comment Continue Reading →

Flex – Store data in client via SharedObject

Introduction 

The SharedObject class functions like a browser cookie. You use the class to store data on the user’s local hard drive and call that data during the same session or in a later session. Below are the keys of using SharedObject:

  1. Applications can only access their own SharedObject data, and only if they are running on the same domain. The data is not sent to the server and is not accessible by other Flex applications running on other domains.
  2. When you create a SharedObject, Macromedia Flash Player creates a new directory for the application and domain, and creates an empty *.sol file that stores the SharedObject data. The default location of this file is in a subdirectory of the user’s home directory.
  3. By default, Flash can save locally persistent SharedObjects of up to 100K in size. When you try to save a larger set of data, Flash Player displays the Local Storage dialog box, which lets the user allow or deny local storage for the domain that is requesting access.
  4. Some important methods:
    • clear()
    • flush() – write to the file. If not, flex persists it when the application is closed. However, this does not provide the user with an opportunity to increase the available space
    • getLocal(“name”)
    • getSize()
  5. You can store simple data types in a SharedObject. These types are Number, String, Boolean, XML, Date, Array, and Object. After you assign values to the data property, you must instruct Flash Player to write those values to the SharedObject’s file. To force Flash Player to write the values to the SharedObject’s file, use the flush() method:

[code]]czo1MzpcInNoYXJlZE9iamVjdF9JRC5kYXRhLnZhcmlhYmxlID0gdmFsdWU7IC8vc3RvcmUgZGF0YQ0KXCI7e1smKiZdfQ==[[/code]

LSO vs Cookie

  1. LSOs are can store more data than cookies
  2. LSOs never expire
  3. LSOs arent transmitted between the client and the server
  4. LSOs can store native ActionScript datatypes. 

Reference

http://www.adobe.com/support/documentation/en/flex/1/lsos/lsos5.html

Leave a comment Continue Reading →