Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are designing a system which mimics a BPEL application with sets of functional requirements such as bulk messaging, managing SLAs, error handling and so on.

One of the intentions is to modularize these functional and non-functional aspects into separate web apps so that we can choose at build time and plug them all together.

How does one go about designing this app - choosing design patterns for a controlling framework that delegates between the modules?

Put another way - it's like the chain of activities in an ESB, so the controller passes on to A then B then C. In other cases it goes A > B > D and so on.

So my question: what design pattern does this controller have? How can it decide the logic of whether at the end of A, should it call B or C

share|improve this question
up vote 1 down vote accepted


You have "macro" commands, which consist of other commands.

class Command { 
    public abstract void execute()
class MacroCommand extends Command {
    List<Command> body;
    public void append( Command aCommand ) { body.add(aCommand); }
class A extends Command {...}
class B extends Command {...}
class A_B extends MacroCommand {
    public A_B() { append(new A()); append(new B()); }
share|improve this answer
If my controller is A_B of your example, how would I make it conditional , i.e. do B if A succeeds and so on – shinynewbike Jun 24 '11 at 10:00
@shinynewbike: Use if statements. A MacroCommand is the easy way to have an unconditional sequence. If you want "code"-style BPEL, you have to write actual code. There's no magical way to have code-like behavior without simply writing code. A Command can (trivially) depend on other Commands without being a simplistic MacroCommand. – S.Lott Jun 24 '11 at 10:03
@shinynewbike You could do something similar in concept to Linux pipes. Clearly put, output from each Command could be passed to an object which can control the flow (do nothing, skip, goto, abort...). – James Poulson Jul 14 '12 at 3:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.