We've been quite busy with holidays and Chen going off to JavaOne in India so I didn't have as much time to blog as I normally do or prepare the videos I should be working on. Hopefully I'll recover some time soon and be able to get back to my normal pace.
In recent LWUIT SVN's I deprecated and effectively removed the venerable log class. The main motivation behind that is the fact that logging didn't go through the platform code and never made sense in LWUIT. It was hardcoded for MIDP and had many issues.
That class is replaced by an almost identical class within LWUIT4IO which has similar functionality with a few cool new features. First, it can run on all platforms including Java SE, RIM, MIDP and even Thorsten's new Android port of LWUIT4IO.
Then it has one more "killer feature", it can track file IO seamlessly!
Unlike J2SE, most mobile platforms are really sensitive regarding forgotten streams and its essential to close every stream you open. The problem is that its often really hard to keep track in a large application that deals with many dynamic files constantly. However, since all LWUIT4IO streams are buffered it can easily tell when a stream is opened/closed or double closed. This gets logged automatically if you invoke Log.getInstance().trackFileSystem() which will cause entries to appear in your log containing the URL opened/closed and the number of open streams. This feature helped me in tracking some pretty hairy bugs.
Another feature in LWUIT4IO to which I didn't give enough spotlight is the cache map, its effectively a lean hashtable which stores its data using weak/soft references (depending on the platform) and falls back to storage when not enough memory is available. Its a great way to cache data without going overboard.
One of the cool things about it is the fact that we use it seamlessly for our storage abstraction (which hides RMS or equivalent services) in effect providing faster access to RMS storage which is often slow on devices.
While writing on that subject it dawned on me that I never blogged about our "seamless" serialization support in LWUIT4IO. The Storage class and util class contain methods for reading/writing of objects. All the basic JavaME data types should be supported including: primitive arrays, Strings, Object arrays, Hashtable's and vectors. Arbitrary objects can be stored by implementing com.sun.lwuit.io.Externalizable. This allows easy/efficient persistence and networking between applications.
Give these features a try and let us know how they work for you.
As a side note: due to recent issues with the forum/mailing list that unfortunately remain unresolved to this moment I decided to start answering issues in stack overflow which has a great LWUIT section.
No comments:
Post a Comment