Archive for the ‘Spring Framework’ category

jBPM Developer Guide

March 1st, 2010

Business Process Management (BPM) has been around in one guise or another for quite a while now and most people have had some exposure to its many facets.  With so much promised, it is easy to see why it has generated so much interest.

jBPM is an open source BPM framework from JBoss that has matured into a real alternative to the many other BPM offerings.  The ‘jBPM Developer Guide’ introduces to its readers the main artifacts of BPM and what is involved in implementing typical jBPM solution.

The book begins by providing a background to BPM and how it can be leveraged to deliver benefit to the business.  This includes an introduction to processes, tasks and process management (Business Process Management or BAM).  As any good book should, terminologies that are associated with BPM are introduced and defined.  Thankfully, the definitions are void of the usual marketing hype.

With the help of an example, graph orientated programming (GOP) is then introduced and its relevance to jBPM discussed.  Specifically the Node, Transition and Process Definition concepts are covered before the author works through sample implementations of each.  Wait states (asynchronous system interactions and human tasks) and automatic nodes are compared before process execution is demonstrated through a sample process execution engine implementation.

The book goes on to give some background to the jBPM project and covers the setup of tools to be used throughout the remainder of the book (Maven, MySql, Eclipse etc.). It outlines how to install jBPM from a distribution and from source. I used the installer to install the version used for the examples (3.2.6.SP1).

Two example process projects are then created using the eclipse designer plugin and then the maven plugin to contrast both approaches.  Use of the ‘Graphical Process Editor’ is also demonstrated.

The jPDL language is then explored in greater depth describing in detail the XML\Class definitions of the process, the various node types (Node, Start State, End State, State, Decision), transitions and the execution token.  As an example (recruitment) process is automated with the jBPM framework.  This is achieved iteratively adding more detail in each stage.

Process instance persistence is discussed in depth.  This includes details on how and when process definition amd process instance persistence occurs.  A brief review is given of the jBPM API to interact with the database and the jBPM\Hibernate persistence configuration.

Human Task’s are explained including details on input data, task action and output data.  The distinction between a TaskNode and Task is also made.  A brief introduction to the jBPM Identity module is provided during a discussion about task assignment before demonstrating an example process.

The transactional behaviour of jBPM is then discussed along with a more detailed discussion on variable mappings and task assignment.  Process variables and the type’s of information stored in process variables are explained and the specific API for variable manipulation is covered in brief, along with the variable persistence and hierarchy. These concepts are demonstrated with a concrete example.

More advanced node types are covered in this chapter including Fork and Join nodes, Super state nodes, Process state nodes and the Email node. Variable mapping strategies as discussed in depth and related to the Process State node.

Further examples of using Super state nodes and Process state nodes are covered in addition to asynchronous execution and the JobExecutor.  The examples focused on the asynchronous execution are thorough and provide a good understanding of this process.

The book finished by discussing the use of jBPM within a JEE environment.  In particular, JTA, Data Source’s, the CommandServiceBean, the JobExecutor and JMS and finally Timers and reminders.

My overall impression of the book was that it relayed the key information required to get up and running with jBPM.  The author was clearly knowledgeable in the subject and provided useful examples to complement the concept’s being discussed.  I liked the fact that the author gives details on installing the developer tools as it allows the reader to follow along with the examples.

The only negative comment I can make was that I found the poor construction of sentences and awkward use of English a little distracting.  It reads as a book that was translated into English from another language.

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 10.00 out of 10)
Loading ... Loading ...

Creating a Logging Aspect with Spring AOP and AspectJ

February 16th, 2010

After working in software development for a number of years, one tends to build up a repository of useful code examples and utilities.  I’m certainly no different in this regard and go one step further by maintaining a hosted Subversion repository to keep such code examples safe and sound (and readily accessible).

One such code example that I often turn to is a logging aspect implemented using Spring AOP and AspectJ.  This logging aspect traces method entry and exit which proves very useful if you need to perform root cause analysis in pre-production environments.

In what follows, I’m going to share this code example.  I have also made the logging aspect source code available for download.

I have assumed you have a reasonable grasp of Aspect Orientated Programming concepts and terminologies.
» Read more: Creating a Logging Aspect with Spring AOP and AspectJ

Marshalling XML with Spring WS and JAXB

February 4th, 2010

The ‘object-relational impedance mismatch’ is a well documented set of conceptual and technical difficulties that are often encountered when a relational database management system is being used by a program written in an object-oriented programming language. A similar impedance mismatch exists when XML is used by a program written in an object-oriented programming language.

Many popular ‘Object-Relational Mapping’ (ORM) frameworks exist that address the object-relational impedance mismatch and no doubt helped to inspire the evolution of ‘Object-XML Mapping’ (OXM) frameworks to address the object-xml impedance mismatch.

For the Java community, there are a number of OXM frameworks from which to choose (Castor, XStream, JiBX, JAXB) with each having particular strengths and weaknesses. The standard OXM framework for Java is JAXB.

In the following I work through a simple example that demonstrates object to XML marshalling (and demarshalling) using Spring, Spring WS and JAXB (and later JAXB Introductions!)

I have provided Maven projects for download so you can follow along:

Spring OXM and JAXB Source Download
Spring OXM, JAXB and JAXB Introductions Download
» Read more: Marshalling XML with Spring WS and JAXB

Starting out with Spring and Hibernate JPA

January 21st, 2010

More often than not, I am brought onto a project after the project initiation phase has been completed.  By this stage major decisions regarding the development environment and code organisation have already been made.  It would be fairly common that I would refactor and re-organise some of the code and in particular the Hibernate JPA code.

In this post I am going to outline how I prefer to implement and organise the Hibernate JPA code on projects I am involved with (where that option exists). I will also demonstrate how I implement the persistent entity classes, data access objects, associated configuration and unit tests.  A fairly typical project would utilise Maven, Spring and Hibernate JPA.

Creating the Maven Project

My preferred project structure consists of a root project containing a model module and persistence module with the persistence module having a dependency on the model module.  While this would seem pretty straight forward, one now has to decide if one is going to use annotations or  XML configuration for the ORM mapping.  The reason I prefer to make this decision now is that it affects the dependencies of the model module.

There are arguments for and against using annotations or XML for ORM (any XRM really) but if no precedent has been set I normally try to avoid using annotations in model classes.  This way model classes are very clean and the model module does not have any dependencies on javax.persistence.  I was involved in a project using JPA and JAXB annotations in model classes and they became difficult to work with very quickly.

The persistence module really does encapsulate all the information relating to the persistence mechanism with the exception of (some) transactional characteristics which would ordinarily be defined in service classes within a service module.  Of course the price you pay for this is having some quite large XML files.
» Read more: Starting out with Spring and Hibernate JPA

Practical RichFaces

January 8th, 2010

As I had mentioned in a previous post, I recently invested in a couple of books on JBoss RichFaces.  Having read and reviewed JBoss RichFaces 3.3 I set about doing the same for the other book, Practical RichFaces.

The book started out giving the same background information on JSF, RichFaces and Ajax4Jsf but in contrast to JBoss RichFaces 3.3 stated that it will not be using JBoss Seam in the example’s which I was happy about.  That is of course not a reflection on JBoss Seam but more my desire to read about RichFaces and not the many technologies that might complement it.

In the second chapter, the book suggests installing JBoss Tools and as I have not used this Eclipse plug-in before I decided I would do just that.  It then proceeds to work through a small example to verify the Eclipse\JBoss Tools installation.  This is done in some detail and would be quite useful if looking at RichFaces for the first time.

Some time is then spent introducing the main RichFaces components that support Ajax functionality, namely <a4j:comandLink>, <a4j:commandButton>, <a4j:support> and <a4j:poll>.  These concepts were covered clearly and concisely with good use of appropriate examples.  The remaining a4j components are covered in the chapter that follows.

Having covered the a4j components the book then proceeds to cover the majority of rich components dividing the coverage into input components, output components, data iteration components, selection components and menu components.  The coverage of the input components is brief which is to be expected as it would be difficult to add anything to the JBoss RichFaces reference documentation.  The coverage of the output components is a little more in-depth than the reference documentation and demonstrates, by example, some nice tips and tricks.  The data iteration components, selection components and menu components are covered in roughly the same level of detail as that provided by the reference documentation.

The Scrollable Data Table and Tree are given a chapter of their own which covers the main functionality and usage of these components.  As with JBoss RichFaces 3.3 I was disappointed with the level of coverage the Tree component received.  This is one of the more complicated components and I would like to have seen more examples of its usage.

The last chapter on skinning is on a par with JBoss RichFaces 3.3 and covers the subject well.

My overall impression was again that I’m not really sure that this book adds anything to the freely available reference documentation but the tutorial style is certainly easier to read.  I would recommend this book for someone starting out with RichFaces or for someone wanting to read a book end-to-end to get up to speed quickly.  What is really needed for RichFaces is a RichFaces Recipe’s Book which is packed full of real world examples of using rich faces beyond the simple examples available on the RichFaces demo website.

One last comment that I would make on the book is that it got me wondering about the level of proof reading of these books.  There are a number of glaring errors that would have been noticed if reviewed by anyone with RichFaces knowledge who reads this book.  I think these types of mistakes should not make their way to print.

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...