Essence Java Framework
This web site is being migrated to the Essence Wiki
Google
 
Web www.jtoolkit.org weblog.jtoolkit.org
Navigation
Home
SourceForge Home
Articles on Java
Getting Started
Essence Documentation
Download

Contact
Get rewarded for helping out
Email A Question
Weblog

Support This Project

SourceForge.net Logo

Articles Home

FAQ: Why have an alternative to Spring?

What is the difference

The purpose of Spring is to make JEE simpler. The purpose of Essence is to make JSE simpler.

Spring encourages bottom up design by constructing small components and in turn constructing larger components, until finally you have a complete system. Using XML configuration you tend to get lengthy files describing every level of the application. Components can wire themselves so the configuration has but a subset of dependencies in it.  Spring does not have direct support of binding components to a thread.

Essence encourages top down design. This is harder initially as you need to have a partial design to start with. The application is structured as a collection of single threaded logical processes. Each logical process has a number of stateless business components which communicate between shared data collections or messaging. Infrastructure components are hidden or simplified by the infrastructure so configuration should only show high level components.

This is the configuration file for a custom JMS broker with durable queues and topics with clustering support. jms-broker.config  This file describes all the components, their dependencies, where state resides, how it is structured and what persistence/failover is used. It is about 38 lines long. For comparison this is the client jms-client.config

Spring tries hard not to change the way developers develop. This is because Spring attempts to serve the broadest range of uses and not discourage developers from using it. This also suits rapid prototyping which often gets something working quickly.  However having a well designed, maintainable application means you have to go beyond rapid prototyping to a more controlled and well understood system.

Essence encourages a set of best practices for thread and component configuration and enforces them. Essence attempts to describe all references in the configuration file. References between components and all properties are managed by the container. This way you can be sure all dependencies between components and properties are described in the configuration file as the container discourages you to obtaining them via other means. As all processes are single threaded, components can refer to each other without concerns for thread safety or context switching however the container does allow references to single threaded components between processes. Multi-threaded logical processes are also supported.  All components in that logical process are required to be thread safe.  However you can mix single threaded and multi threaded logical processes and only the components in the multi-threaded logical processes need be thread safe.

Essence separates business logic from state.  Business components should be logically stateless.  All state can be stored in collections of immutable objects.  This makes sharing state between processes and JVMs transparent are simple to visualise. An application can be made durable by backing all it state to disk or a second or four servers (or both) and restarting the application reloads the state.  Essence provides this for you through a few lines of configuration.

J2EE has Dao (Data Access Objects) which tend to involve a lot of custom code. Essence has a java.util.Map which can also be viewed as a java.util.Queue. A callback can be added to hear events. Helper methods allow you to searches, joins and perform other complex operations on a Map.

J2EE/Spring/Hibernate has Java Persistence API, JdbcTemplates, Hibernate configuration files and annotations. Essence has a java.util.Map (which has been configured to be persistent, and/or distributed/clustered without code changes.)

J2EE/Spring supports JMS messaging, Essence has implicit messages via a Queue or Map you can add a Callback to hear new messages/events.

J2EE/Spring has complex deployment descriptors and an assortment of configuration files. Essence has one configuration which configures components, messaging, clusters, collections.

J2EE/Spring has an enormous number of classes which you could use. An application in Essence can be written without a single reference to a class, interface or annotation or import for an Essence class.

Sun's J2EE App Server with Spring is around 300 MB. The sample application Essence JMS with the framework, broker and client is 612 KB.

Could you use Essence and Spring together?

Yes. Essence is best at describing the high level system. Essence attempts to hide away low level infrastructure. Spring can describe every level object in the system and has integration for many systems which makes it a good choice.

Copyright 2006 Peter Lawrey Essence Email