"The REFCODES.ORG codes represent a group of artifacts consolidating parts of my work in the past years. Several topics are covered which I consider useful for you, programmers, developers and software engineers."

What is this repository for?

The refcodes-jobbus artifact makes use of the Command pattern and provides a frame to work with Command (job) instances - also in a distributed environment (e.g. REST, SOA, Cloud Computing) and provides do/undo functionality.

The terms command and job are used interchangeably. To understand the benefits which the job-bus offers, we should briefly understand the Command pattern:

See the blog Having fun with the command pattern on how to do the undo with the refcodes-command artifact ...

Simply speaking, you push a job into your job-bus. You can either wait for the job to be executed and grab its result when done or you use a handle to grab the result later on. The job is being executed asynchronously, it is up to the job-bus where and when it is being executed: For example the job could be transported to some remote JVM to be executed there or the job could get executed as soon as a worker thread is happy to grab the job from a job-queue.

How do I get set up?

To get up and running, include the following dependency (without the three dots "...") in your pom.xml:


The artifact is hosted directly at Maven Central. Jump straight to the source codes at Bitbucket. Read the artifact's javadoc at

How do I get started?

First of all you got to be aware which jobs you got to create for your project (or at least with which ones to start) and on which kind of context your jobs will be applied. Your jobs will actually implement either the Command or the Undoable interface. The terms job, commandand undoablewill be used interchangeable here and there. The context can by of any type, it can be a service, a client or any other Java``Object.

Given you want to apply various arithmetic operations on a list of int values and return the result. Starting with the SumCommandImpl, the code might look as follows:

public class SumCommandImpl extends AbstractUndoable<List<Integer>, Integer, Exception> {

     * {@inheritDoc}
    public Integer execute( List<Integer> aContext ) {
        int theResult = 0;
        for ( Integer eInt : aContext ) {
            theResult += eInt;
        return theResult;

All the values contained in the context (being the list) will be summed up and the sum is returned by the execute method. That's it. There may be additional jobs such as MaxCommandImpl, MinCommandImpl or AverageCommandImpl.

Your jobs may also modify (mutate) the context which would make a job being an Undoable applicable.

a) Create an instance of your JobBus and feed it with your context:

List<Integer> context = new ArrayList<Integer>();
JobBusImpl<List<Integer>> jobBus = new JobBusImpl<List<Integer>>( context );

b) Synchronously executing your Undoable (job) is straight forward:

SumCommandImpl theSumCommand = new SumCommandImpl();
int theSumResult = jobBus.getResult( theSumCommand );

c) For asynchronous execution, you got the remember a handle with which you can retrieve the result later:

String theSumHandle = jobBus.execute( theSumCommand );
if( jobBus.isExecuted( theSumHandle ) ) { 
    int theSumResult = jobBus.getResult( theSumHandle );

You can also wait for execution to finish by calling jobBus.waitForExecution( theSumHandle ).

See the JobBusTest unit test for the source code of this example.

Contribution guidelines

Who do I talk to?

  • Siegfried Steiner (

Terms and conditions

The REFCODES.ORG group of artifacts is published under some open source licenses; covered by the refcodes-licensing (org.refcodes group) artifact - evident in each artifact in question as of the pom.xml dependency included in such artifact.