Assortment of a Surprisingly Rich and Fast Framework to make Java Applications “Powerful”
Many Java vendors and open-source projects focus on complex tools, built to solve complex problems, often under the umbrella of "enterprise" Java development. Witness the explosion of complexity in J2EE, EJB, and XML. True, there's often a tradeoff between simplicity and power, but some key architects in the Java community are working to swing the pendulum from monolithic frameworks back toward cleaner, simpler ones. A number of new projects are helping to buck the trend toward complexity, choosing instead to build lighter, focused frameworks that an power simpler applications.
In this article, we'll examine a few frameworks, and look at the basic principles that they use to embrace simplicity. We'll look at a lightweight container and a persistence framework. Then, we'll look at how the larger J2EE vendors are supporting the paradigm shift.
A few notable projects use very little of J2EE as a foundation. They are basically attempting to build a simplified notion of what it means to be a persistent object, or a container. Lightweight containers like Pico and Spring provide fewer services, but with a much less invasive architecture than EJB. Hibernate, a persistence framework, provides a persistence alternative for EJB container managed persistence (CMP).
Transparent persistence
Hibernate is an open source project, founded by Gavin King, that provides transparent persistence for Java applications. After all, it's proprietary; it has relatively modest development resources compared to many of the commercial OR-mapping juggernauts; and it's an open source project, which can often work against it in larger IT departments. Still, Hibernate has burst onto the scene with tremendous early momentum, providing a surprisingly rich and fast framework.
Unlike JDO or EJB, it's not based on byte code enhancement or code generation. It uses reflection. It has a small footprint, and runs with very low resource contention, aside from the database itself. I believe that Hibernate is successful primarily for three reasons: it's focused, simple, and fast. Let's look at some of the principles that have made the Hibernate project successful.
- Do one thing, and do it well. Hibernate is an object-relational mapping framework, solely for Java applications on relational databases through JDBC. That's the lion's share of the Java persistence community. It's also a focused problem. By limiting the problem domain to relational databases, Hibernate is able to make some pragmatic decisions that can dramatically impact performance. For example, since the designers knew that they would be using SQL over JDBC, they could take advantage of special algorithms and extensions for high-performance outer joins. Many other persistence frameworks are not limited to relational database back ends. Hibernate effectively trades a looser coupling for higher performance.
- Strive for simplicity. The Hibernate team has invested heavily in effective documentation, and also in good examples. They also have a simple API. I was able to get my first application running in under fifteen minutes. I notice Hibernate's simplicity in many places. Its methods are well named, and the abstraction layers are clear. I can work with pure Java beans, instead of building complex components. Ant integration and XDoclet support is already included. A framework should strive to provide the simplest support possible for its users.
- Pick your battles. If you decide to build simpler applications or frameworks, you're going to have to decide where to focus your attention. You can't adopt every design pattern, or make every performance enhancement. Some of my early Hibernate reservations were related to reflection. The development team rightfully assumed that the reflection overhead would be minimal compared to the performance of the SQL queries that Hibernate would generate. Instead of optimizing reflection, the team focused on the number and efficiency of queries by delaying updates, rolling many SQL statements into one, detecting "no-ops" (like an insert immediately followed by an update and a delete), and so on. The result is a surprisingly fast framework, with the transparency afforded by reflection.
Through simplicity and better focus, the Hibernate team has settled into a nice, rapid release rhythm, and it's served them well. The user community is growing, and they've just completed the second major release. But persistence isn't the only place that the trend toward simplicity is taking root.
Lightweight Containers
Lightweight containers strive to provide services for the simplest components possible. Spring and Pico are probably the most popular. If you've not seen them before, you may be tempted to skip this section, believing that the last thing we need is yet another container. Don't. Lightweight containers like Spring are spreading rapidly, because they can solve problems that other containers can't. While these frameworks are not as well known as Hibernate, at least one of them may be soon. The most interesting aspects, to me, are the transparency of the objects, clean and pluggable services, and the light footprint. All of these goals lead to a simple, effective framework:
- Strive for transparency. When you're building a solution for developers, the simplest solutions are usually the best ones. Spring is not invasive. In fact, the objects that you snap into the container are pure POJOs, plain old Java objects, or JavaBeans, to be more precise. Objects do not depend on the container. They can run outside of the container for better testability, or address other objects as POJOs.
- Allow for extension. Spring supports some simple services out of the box, like JTA and JDBC layers for transaction and database support. Spring also provides a nicely layered API that allows rapid extension by third parties. For example, you can already use both Hibernate and JDO objects within a Spring container.
- Keep a small footprint. Spring's simplicity lets it keep a small footprint. As such, it can be used in ways that you might not expect to use your average J2EE container. It starts quickly enough to be included in tests, even if you plan to run many of them with each build. You can use Spring on the client, or within a mobile device.
Since lightweight containers work with POJOs and clearly separate concerns of various services, they are well-suited for the next generation of program paradigms like aspect oriented programming (AOP). Both Hibernate and Spring present simplified abstractions.
Alternative approaches
Of course, building simpler frameworks from the ground up is only one way to gain simplicity. The Java community is also trying other approaches. Some are trying whole new programming paradigms, like model driven architecture (MDA), or aspect oriented programming (AOP). Others are trying a more incremental approach, like letting tools shield us from some of the complexity.
CATT Ltd is already working on many projects involving Java and J2EE technologies, to implement the user friendly & robust applications. As a step ahead CATT Ltd already started working on alternative approaches. As Java and J2EE Technologies are most happening technologies in Current trend & in future also, applications requires transparent persistence and Light Weight Containers for a quick to response. CATT Ltd is targeting to become the strong to implement applications based on Java and J2EE Platform as we were proved before while working on this technology.
Posted By: S Abdul Razack