Archive for the ‘Spring Source’ category

Creating a Profiling Aspect with Spring AOP and AspectJ

March 28th, 2010

As I have mentioned previously, there are several utilities that I often find myself reusing when I join a new project.  One of these utilities is the Logging or Tracing Aspect that I have previously discussed while the other is an aspect that facilitates a rudimentary profiling of the application code.

I first got the idea for such a profiling aspect from the Spring Framework user guide which presents a basic implementation in the Spring AOP section.  I subsequently observed a more sophisticated implementation developed by Jerry Kiely, who I occasionally have the pleasure of working with.

In what follows, I will present an implementation of a profiling aspect and explain how this can be utilised using Spring and AspectJ Load Time Weaving.

» Read more: Creating a Profiling Aspect with Spring AOP and AspectJ

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

Web Form Validation with JBoss RichFaces and Hibernate Validator

February 9th, 2010

Last month I posted about Building a Dynamic Tree with JBoss RichFaces and Spring Web Flow. Since then, I have received a few requests to demonstrate how to implement validation within the modal dialog. There are several internet resources that already deal with this but none that provide a complete working example so I decided I would do just that.

You can download the source code in the form of a Maven project and follow along.

Hibernate Validator Dependencies

First step is to add the Hibernate Validator dependency to the project pom. I have used Hibernate Validator 4.0.0.GA because it is a JSR 303 compliant implementation.

<dependency>
  <groupid>org.hibernate</groupid>
  <artifactid>hibernate-validator</artifactid>
  <version>4.0.0.GA</version>
  <scope>compile</scope>
</dependency>

Listing 1 : Hibernate Validator Dependency

» Read more: Web Form Validation with JBoss RichFaces and Hibernate Validator

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