Thursday, August 13, 2009

Code in a "finally" clause "may" fail to execute!!!

We all would have studied that finally block always executes. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.
But here's an example where the finally code will not execute,
try
{
if (userInput)
{
while (true) ;
}
else
{
System.exit(1);
}
}
finally
{
// what ever you want to clean up
}
Please note: If the JVM exits while the try or catch code is being executed, then the finally block will not execute. Likewise, if the thread executing the try or catch code is interrupted or killed, the finally block will not execute even though the application as a whole continues.

United States Postal Service web tool kit

The USPS Web Tool Kit Application Program Interfaces (APIs) allow developers of web-based and shrink-wrapped applications access to the on-line services of the United States Postal Service (USPS). They provide easy access to shipping information and services for your customers. By integrating these APIs into your web site, your customers can utilize the functions provided by the USPS without ever leaving your web site. Once the APIs are integrated into your web site, the USPS Shipping API Server communicates over HTTP using XML (Extensible Markup Language).


Implementing these APIs requires experienced programmers who are familiar with Internet and web site development tools and techniques.


This document provides guidance and step-by-step instructions for installing the USPS APIs, as well as fulfilling various administrative requirements. The administrative requirements vary between different APIs (e.g., submitting samples of labels for some APIs, signing a licensing agreement for certain software, etc.), and this document provides guidance to navigate through the process for the API you are implementing. It is imperative that developers read this manual first, as it provides necessary information and procedures prior to use.


There is a Web Tool Kit User’s Guide for each API available at http://www.usps.com/webtools/. These user guides provide information of the XML transactions to the USPS Shipping API server.

Mozilla Firefox and Microsoft Internet Explorer web browsers descended from Netscape Navigator?

I came to know through wikipedia that both Mozilla Firefox and Microsoft Internet Explorer web browsers descended from Netscape Navigator? It was interesting to me and I thought I would blog about it.
And now, where did Netscape Navigator descended from?!!! Mosiac. If all browsers are from something else then which was the original one? Opera?
The most widely used browser according to me is Firefox and a closer one to it is Chrome. Microsoft Chairman Bill Gates has used Firefox, has commented here that "so much software gets downloaded all the time, but do people actually use it?" I am sure the rest of the world will not agree his views.

Sunday, August 9, 2009

Debate on best framework for developing JEE applications

Frameworks, Frameworks everywhere. Listing frameworks for developing JEE applications:
  1. Echo
  2. Struts
  3. RIFE
  4. JPublish
  5. Verge
  6. Action Framework
  7. Expresso
  8. OpenEmcee
  9. JWAA
  10. Smile
  11. Jeenius
  12. Dovetail
  13. Japple
  14. Nacho
  15. Click
  16. Cocoon
  17. SOFIA
  18. Spring MVC
  19. JATO
  20. Niggle
  21. Shocks
  22. Bento
  23. Turbine
  24. Jaffa
  25. MyFaces
  26. JWarp
  27. Cameleon
  28. Helma
  29. Cassandra
  30. GWT
  31. Millstone
  32. Tapestry
  33. Canyamo
  34. Folium
  35. Bishop
  36. TeaServlet
  37. jStatemachine
  38. Scope
  39. Jacquard
  40. Chiba
  41. Genie
  42. JFormular
  43. Dinamica
  44. Baritus
  45. OXF
  46. WebWork
  47. Maverick
  48. Jucas
  49. Barracuda
  50. wingS
  51. jZonic
  52. Warfare
  53. Macaw
  54. JBanana
  55. Melati
  56. Xoplon
  57. WebOnSwing
  58. Stripes
  59. JSF
May be more...
Introducing Wicket
JSP is by far the worst offender, allowing the embedding of Java code directly in web pages, but to some degree almost all of the frameworks from the list (except Tapestry) above introduce some kind of special syntax to your HTML code.
Special syntax is highly undesirable because it changes the nature of HTML from the kind of pure-and-simple HTML markup that web designers are familiar with, to some kind of special HTML. This special HTML can be more difficult to preview, edit and understand.
Wicket does not introduce any special syntax to HTML. Instead, it extends HTML in a standards-compliant way via a Wicket namespace that is fully compliant with the XHTML standard. This means that you can use Macromedia Dreamweaver, Microsoft Front Page, Word, Adobe Go Live, or any other existing HTML editor to work on your web pages and Wicket components.
A comment on struts
Struts is great for small to medium size application. When the application gets big, especially when presentation logic gets complicated, it is really a big hassle to maintain the a big xml config file. Also a problem to maintain a big properties file for message used all over the application.
This URL discusses on struts and introduces shine.
Too much frameworks, my take will be do not ignore any. Though we may not able to master many.
Struts vs JSF
A good article on Struts vs JSF. http://www.simplica.com/strutsvsjsf.htm
Choosing a java web framework
A comparison presentation given in 2008 javaone conference. http://developers.sun.com/learning/javaoneonline/2008/pdf/TS-6457.pdf
This blog by Manoj maniraj has few more important points to be considered while picking your framework.
Just put in your views on the best framework.

Saturday, August 8, 2009

Java based Telnet daemon

Telnetd is an Open Source effort to implement a Java telnet daemon that is compact and generic and thus easily embeddable into other applications.

Main Features are:
  • Telnet protocol implementation (following specifications, support for NVT, ECHO, TTYPE, NAWS, LINEMODE,NEWENV)
  • Terminal I/O with support for various terminal types
  • Simple UI toolkit as OO layer on top of the basic terminal I/O (work progress)
  • Connection management (host based access and handling of idle connections)
Main focus is a design that is flexible and powerful, yet at the same time stable and with a small runtime footprint. Threads required are two system threads per listener, as well as one per connection.
How To
For starting up the telnetd and the required number of listeners, you have two choices:
  1. using the existing main() in the TelnetD class
  2. instantiating and activating the daemon from within your application.
Bootstrapping from within your application
It will be required to take the following steps:
  1. Assemble/prepare the properties that resemble your desired configuration.
  2. Create a TelnetD instance using one of the given factory methods in the TelnetD class (see API docs).
  3. Start the daemon calling start()

An example is given below, props represents a single Properties instance containing all properties for your desired configuration:

//1. create singleton instance
TelnetD daemon = TelnetD.createTelnetD(props);
//2.start serving
daemon.start();