Calling Back-End Services

It is possible to connect the presentation layer to the service (application) layer, if you are modeling your application's back-end with one of the other cartridges, and you're modeling services using the <<Service>> stereotype you will simply need to model a dependency from the controller class to the service class.

You can have dependencies to as many services as you like, for each one of the them an accessor will be generated.

Because of the strict separation between the three enterprise tiers it would not be a good idea to make the bpm4struts cartridge aware of how to call the actual service instances in the back-end tier, since this is most likely different on different platforms (Spring, EJB, ...). For this reason we have introduced a namespace property called serviceAccessorPattern. It allows you to specify how calls to the back end ought to be rendered, if you have generated the project structure using the andromdapp:generate Maven plugin you should not need to change this property.

One could argue why not calling service operations directly from the activity graph, here are a few reasons:

  1. Activity graphs can have only one context at a time, so your deferred calls would be limited to a single service
  2. Operation signatures do not always perfectly map, parameter names and types might be different; generally speaking it is good practice to have an intermediate layer in which you can handle these differences.
  3. Often you will not want to directly expose exceptions from the back-end to your presentation layer, this can also be handled in the controller.

howto/org/andromda/test/back-end.gif

Next

Next section: Tables.