Action


What are Actions

Actions are business rules that get fired at specific times in the execution of business logic. The action itself is simply a method.

Optionally, your Action annotation can specify that it is restricted to a particular verb:

@Action(verbs = Verbs.UPDATE)
public void myAction() {
...
}

 

ABL defines three types of actions:

EarlyAction

An EarlyAction will be executed only once per transaction per object, and it will be executed at the very first time the object is brought into play in the transaction. This means that an object that is modified by user code (as opposed to modified by a business rule) will have its EarlyActions executed as the first step, before any other business rul is executed. This is intended to give you an opportunity to do something before the object is potentially modified. Note that, since the business rules have not yet executed, we actually don't know whether the object is going to be modified. It is not unusual for business rules to fire, only to realize that, by the time they're done, they have not actually changed anything in the object. Since EarlyActions are called before any of this happens, there is no guarantee that the object will be modified afterwards by the rules.

If an EarlyAction is triggered, not by user code, but by a business rule, its aggregate attributes will be refreshed before it is invoked. This is an exception to the general rule that says "an EarlyAction get executed before anything else".

Action

An Action gets executed whenever the corresponding object is modified within a transaction.

Multiple Action Invocations controlled by return parameter

Actions can be invoked multiple times within a transaction. For example, saving a Purchaseorder with 3 Lineitems might invoke the Customer Logic 3 times.

Each such invocation will fire your logic. If (as is usually the case) you wish to be called only once per transaction, return true to decline further invocations.


CommitAction

A CommitAction is a special kind of Action which gets executed only once, after all the rules for the transaction have executed.


Design Guidelines

In most cases, Business Logic Actions should be merely method calls to re-usable logic services. Several examples are provided, such as InsertInto and Allocate. Be sure to adhere to the instructions in Extensibility. Specific rules regarding Actions:

  1. Commit Actions may not alter their Domain Object 
Comments