This blog covers developing Web-applications based on the latest Java IT technology, popular Open Source Projects, IDE and Software Frameworks the same as Eclipse, Hibernate, Spring, Struts, Maven, etc...

, credit card debt or several
small loans with high interest rate, which in it's turn defines the requirements to the debt management program.
Energy docs for power engineering specialist
Java for beginers

Tuesday, September 25, 2007

PALO ALTO, Sep 17, 2007: The open source Dojo Toolkit is receiving a new grid widget thanks to the generous support and collaboration of the Dojo Community. The Dojo Grid is a key component for Ajax and web application developers because it is able to handle large amounts of information efficiently and intuitively. The companies in this relationship are making a financial and/or engineering contribution to improve and update the grid in time for the Dojo 1.0 release in October.

“We determined that Dojo needed a new grid widget and rather than starting from scratch, we approached the TurboAjax Group about making its feature-rich grid open source and part of the Dojo Toolkit,” said Dylan Schiemann, CEO of SitePen, Inc. "This grid benefits SitePen’s clients and is a great way to advance the Open Web."

TurboGrid is a high-performance grid widget that was originally created to work with the 0.4 version of the Dojo Toolkit. The grid is being updated to work with the latest Dojo features and will now be an official part of the Dojo Toolkit.

“We couldn’t be more thrilled about moving TurboGrid to the Dojo Foundation. This is a unique opportunity where a collection of companies have come together to open source a quality component that is the key to building data-rich applications,” said Scott Miles of the TurboAjax Group.

The Dojo Grid Widget features integration with Dojo’s flexible dojo.data infrastructure, which allows multiple widgets and visualization components to efficiently access large volumes of data. The donated grid supports advanced features such as virtual scrolling, row and column locking, complex cell and row formatting and custom cell editors. The Dojo Grid will also include full accessibility and internationalization support.

“We’re both users of the Dojo Toolkit and supporters of the Dojo Foundation. TurboGrid is a great opportunity for the community to work together in moving Dojo to the next level,” said Coach Wei, CTO and founder of Nexaweb. “Being a strong supporter as well as adopter of open source and open standards, Nexaweb is pleased to contribute to this effort in making Ajax development more efficient, structured, and maintainable for the web 2.0 community.”

“Mozilla and the Dojo Foundation share a commitment to advancing the Open Web,” said Mike Shaver, chief evangelist at the Mozilla Corporation. “We’re glad for the opportunity to join with other contributors to ensure that there are great tools for building accessible, robust applications for the web.”

“Redfin had been looking for a grid widget that worked with Dojo for the new version of our real estate web application,” said Sasha Aickin, engineering manager, Redfin. “The opportunity to contribute to an effort and share development risk across the community is a key benefit of building our application with open source technology including the Dojo Toolkit.”

“This new Grid, coupled with the underlying dojo.data AJAX infrastructure enables an entirely new class of Rich Information Applications,” said Chris Marino, CEO of SnapLogic. “Our users are looking for ways to build applications on top of their SnapLogic data services that can more easily access and present their data, and Dojo 1.0 is a giant step forward.”

“This is excellent code and an amazing show of generosity from the organizations who made it happen,” said Alex Russell, President of the Dojo Foundation. “This is the most capable Open Source web-based grid component available anywhere, and it will form the backbone of applications for years to come. We couldn’t be happier that this donation is happening in time to include the Grid in Dojo’s upcoming 1.0 release.”

How many times have you coded a check for String being null or empty? Countless times, right? I have. We use some ready-to-use classes from open source frameworks or we write our own StringUtils class. More or less they all implement the same thing and it always looks similar to the following code snippet:

String s = ...if (s == null || s.equals(""))...

or similar to the following, which trims leading and ending whitespaces

String s = ...if (s == null || s.trim().equals(""))...

Of course you could also do this:

"".equals(s)

which is a case when you do not care if String s is null and you don't have to worry about NPE as if won't happen ("" is never null, whereas s could be). But that's another story.

I have had "extra" warnings turned on in my IDE for couple of days. But today my IDE suprised me when it highlighted

[1] s.equals("")

and suggested that I could optimize it by making it to

[2] s.length() == 0

And guess what?! The IDE was right! I looked at the suggested code briefly, gave it a bit of thought and agreed that it would probably be faster. Method [1] creates a new instance of the String (an empty String, yes I know that all instances of "" would be caught during compilation and optimized and that they all would refer to the same instance). Just to be on the safe side I looked at the source of the String class.

And here is what I found. The length() method returns and integer primitive, which is not calculated with each method call to length(). It is rather a member variable (or constant, as Strings are invariants) of String class that is calculated when new String instance is created. So this method would be super fast.

public int length() { return count;}

On the other side, there is the equals() method, which is fast as well, but not as fast as length method. It has to do a check for class, class casting and comparison of count members (that's what length method returns).

Do not compare Strings with == operator. Unless you want to compare the object references. Use equals() method.

Do not construct new instances like new String("abc"). Simple "abc" will do, unless you really mean that you need a new instance of String with same value.

Do not concatenate Strings in loops using + operator. It's faster to use StringBuffer (or StringBuilder, which is in Tiger and is not synchronized) append() and then toString() methods instead. The plus (+) operator constructs new String object each time.

Tuesday, September 11, 2007

The J2EE field is agog with excitement about a very popular Open Source technology - Hibernate. This technology being elevated to the status of JCP standard. Feedback from J2EE programmers in industry says that knowledge of Hibernate is mandatory for all J2EE aspirants.

Hibernate is an ORM Object-Relational-Mapping technology. It is an Open-Source and free technology, developed in SourceForge. net. There have been a number of such ORM technologies,in recent past. . TopLink is one such tool, subsequently adopted by Oracle and so proprietary. Hibernate from SourceForge and OJB(Object-Relational-Bridge) from Apache are two well known ORM tools, open-source and free. JDO, also falls within the same category.

Gavin King is the lead for Hibernate and Craig Russell & David Jordan, the lead authors for SUN-sponsored JDO effort. Due to some technical problems, it appears that the majority in JCP favours Hibernate today instead of JDO. At first reading though, the difference is not, all that apparent. The syntax and the approach appear to be almost same, but Hibernate syntax is easier to learn.

It is interesting to note that Craig Russell works for SUN and Gavin King is now with JBoss. It shows that JCP is a democratic community and SUN is not dictating terms except to protect the language and its enterprise-level users.

EJB-3, is the latest version and it is heavily influenced by Hibernate. Some readers equate EJB-3 with Hibernate. Oracle supports EJB-3 proposals and as it is the main Database company in j2ee world, EJB-3 has bright future. J2EE by its very name is an Enterprise level technology, and as EJB is the essence of such Enterprise applications, because of the built-in container services offered, the significance of the surging interest in Hibernate can be really appreciated only in association with EJB and hence a detour into EJB is inevitable.

EJB has three types. One type is the SESSION BEAN, residing in ENTERPRISE container, which can be thought of as a function-bean, invoked in RMI-IIOP style. Such session-bean, may be either stateless or stateful. The stateless bean working in Enterprise container has an exact counter-part in Microsoft COM+(MTS), but the other types are said to be available in MS platform only through third-party extensions.

ORM tools have been sometimes used along with Session beans. The only problem till recently was that they were proprietory and rather costly. But nowadays, very reliable open-source ORM tools are available, and even Richard Monson Haefel approves this method as a safe and productive alternative to Entity beans.

The other branch, the ENTITY BEAN has been less lucky. EJB-1. 1, EJB-2. 0 and then EJB-2. 1, have meant a number of changes in the specification relating to Entity Beans. We can say that an Entity bean is an 'Attribute bean' or 'property-bean', with setter and getter methods, invoked in RMI-IIOP style and persisted in Enterprise container. The pattern of defining a typical Javabean is a recurring theme in Java. The same style occurs in BDK, EJB-Entity beans, Struts, JSF and now in Hibernate too. So, it is very important and elegant.

The third branch is Messaging paradigm and MDB. An Enterprise by its very name implies huge number of customers and concurrent transactions, RPC style being like telephone call, could result in 'line-engaged!' problem. If the call involves the called person referring to some records before replying, it leads to line- blocking. But, messaging style, as in email, atleast ensures that the message has been sent. It is evident that dubbing RPC( read 'telephone') as unsuitable, is over-statement. Sometimes, we desire immediate response,too. By the same token, even XML webservice, if it is really serious, should adopt messaging style and it does. MDB (Message-Driven bean) has weathered the storm and is in fact gaining more and more acceptance.

So, why is it that Entity beans alone were found wanting and the specification keeps on changing?Entity beans are of two types. CMP & BMP. CMP stands for Container-Managed Persistence and BMP stands for Bean-managed persistence. Theoretically, the EJB specification does not say anything about the method to be adopted in persisting objects for permanent storage and retrieval. It could be simple object serialization. The database may be object-database or Object-relational database or XML. In practice, however, a database has always meant a Relational Database and its SQL.

In CMP, the coder deals with objects, only in memory. He creates new objects, modifies them, deletes them and views them, all in memory. The task of saving these objects in memory ,to the relational database table is done by the container, automatically. The coder does not write any sql-related code for this.

In BMP, the coder has to write the sql to persist the object in memory to the relational database.

CMP in EJB1. 1 was suitable for simple tables, without complex relationships to other tables. CMP avoids all references to the underlying database. So, it is more portable. There is no vendor-lock-in. CMP can persist data to Object- databases also, besides Relational databases.

But, CMP is not always suitable. If the database is some legacy type, which cannot be used with SQL, the database company gives a proprietory code for persistence and such code has to be used in our program to persist data. The facilities given in CMP originally were found to be too elementary and there were complaints.

But, what matters is that CMP makes use of ORM concepts, though the implementation left much to be desired. It did not expose how the EJB vendor implements it. Weblogic, Oracle, IBM WebSphere, SUN , JBoss, each may implement CMP in any way that they deem fit. Except in special circumstances, it will be better to use CMP, not merely because, it makes the code more portable & is easy to write. Much more important reason is that the EJB container can optimize the performace dramatically, if we adopt CMP. So the developer community wanted to adopt CMP but found it unsuitable for really complex jobs.

Even with all these improvements, CMP was found to be less than the ultimate solution. There was no spossibility for Inheritance.

Though the container services provided by the EJB container are indispensable in a truly large enterprise application, the J2EE camp is almost vertically split into WebTier & EJB-Tier votaries. The WebTier supporters claim that EJB with its steep learning curve and error prone development environment for developers is not really necessary for most applications. And they would like to have an ORM tool, built into the J2EE specification. For afterall, ORM task is not specific to EJB alone. Even Servlets and JSP could use them. In fact, they have been using them, though the J2EE specification was silent about it. ORM tools like OJB, JDO and Hibernate can be used not only in EJB containers but in webcontainer and even in standalone containers. Gavin King makes it a special point in favour of Hibernate. Making such a tool, a J2EE standard, would make development tasks far easier ,to develop either web-tier application or ejb-tier application. saving us from the medley of classpath to required jars.

In a scathing attack on the complexity and questionable performance of EJB Entity beans, Rod Johnson, prophesies, that in a few years time, J2EE will cease to include EJB. Whether, we agree or not, it is worth looking into the criticisms against EJB Entity beans, raised by him. ( 'J2EE Development without EJB' - Wrox/Wiley/DreamTech-2004). For, he is proposing the Spring Framework as an alternative to EJB container and the idea is gaining ground. J2EE developers and students may have to re-orient themselves rather abruptly, to remain relevant to industry.

Friday, September 7, 2007

Java technology is both a high-level, object-oriented programming language and a platform. Java technology is based on the concept of a single Java Virtual Machine (JVM) -- a translator between the language and the underlying software and hardware. All implementations of the programming language must emulate the JVM, enabling Java programs to run on any system that has a version of the JVM.

The Java programming language is unusual because Java programs are both compiled (translated into an intermediate language called Java bytecode) and interpreted (bytecode parsed and run by the JVM). Compilation occurs once, and interpretation happens each time the program runs. Compiled bytecode is a form of optimized machine code for the JVM; the interpreter is an implementation of the JVM.

The Java platform is a software-only platform that runs on top of various hardware-based platforms. It comes in three versions. It consists of the JVM and the Java Application Programming Interface (API), a large collection of ready-made software components (classes) that ease the development and deployment of applets and applications, including robust, secure, and interoperable enterprise applications. It spans everything from basic objects to networking and security and XML generation and Web services. The Java API is grouped into libraries of related classes and interfaces; the libraries are known as packages.

Along with the Java API, every full implementation of the Java platform includes:

Development tools for compiling, running, monitoring, debugging, and documenting applications.

Java technology was developed by Sun Microsystems. The Java Community Process (JCP), an open organization of international Java developers and licensees, develops and revises Java technology specifications, reference implementations, and technology compatibility kits. In 2007, Sun made the bulk of its core Java technology available as open-source software under the GNU general public license version 2 (GPLv2).

The main benefit of the Java language is the portability of Java applications across hardware platforms and operating systems -- possible because the JVM installed on each platform understands the same bytecode.

The Java language and platform are impressively scalable. At the low end, existing applications can easily be adapted for devices with limited-memory resources. Scaling up, the language is an ideal framework for server-side Web programming. Because it was designed to run in a secure manner over networks, it affords this level of security when operating over the Internet. In essence, Java technology extends a user's computing power from the desktop to the resources of the Web. Web components are supported by runtime platforms called Web containers, whose services include request dispatching, security, concurrency, life-cycle management, and access to APIs such as naming, transactions, and e-mail. At the high end, Java application servers serve as Web containers for Java components, XML, and Web services that can interact with databases and provide dynamic Web content; they also provide an application-deployment environment for enterprise applications, with capabilities for transaction management, security, clustering, performance, availability, connectivity, and scalability.

The Java language was one of the first technologies to support open standards in the enterprise, opening the door to using XML and Web services to help share information and applications across business lines.

Multiple editions of the Java platform

Three editions of the Java platform make it easier for software developers, service providers, and device manufacturers to target specific markets:

Java SE (Java Platform, Standard Edition). Formerly called J2SE, Java SE lets you develop and deploy Java applications on desktops and servers, as well as embedded and real-time environments. Java SE includes classes that support the development of Java Web services and provides the foundation for Java Platform, Enterprise Edition (Java EE). Java SE 6 ("Mustang") is the current major release of the Java SE platform. Many Java developers use Java SE 5, also known as Java 5.0 or "Tiger."

Java EE (Java Platform, Enterprise Edition). Formerly called J2EE, the enterprise version assists in the development and deployment of portable, robust, scalable, and secure server-side Java applications. Building on the foundation of Java SE, Java EE provides Web services, component-model, management, and communications APIs for implementing enterprise class SOA and Web 2.0 applications.

Java ME (Java Platform, Micro Edition). Formerly called J2ME, Java ME provides a robust, flexible environment for applications running on a broad range of mobile and embedded devices, such as mobile phones, PDAs, TV set-top boxes, and printers. The Java ME platform includes flexible user interfaces, a robust security model, a broad range of built-in network protocols, and extensive support for networked and offline applications that can be downloaded dynamically. Applications based on Java ME specifications are written once for a wide range of devices yet exploit each device's native capabilities.