Friday, April 9, 2010

Distributed component events

The application is inspired from the Seam Component Events and uses Spring AOP for event trapping and JGroup for event distribution. The system is divided into two parts Event Generation and Event Consumption. Simple POJOs can be turned into event generator or event consumer.

// Event Generator
public class TemperatureManager{
    private Temperature currentTemperature;

    public void temperatureUpdated(Temperature t){
        this.currentTemperature = t;
// Event Consumer
public class GraphGenerator{
    private Temperature currentTemperature;

    public void updateTemperature(){
        // refresh graph

The above two classes can be part of a single JVM or multiple JVM, with JGroup in place Event Consumer will still consume the events generated by the Event Generator running in different JVM. Spring AOP keeps track of the RaiseEvent annotation and does all the distribution and communication stuff.

Full source code and required libraries with NetBeans project is available at : component-events.rar

No comments:

Post a Comment