Important!: ABL is no longer supported since OpenXava 5.3. Look at the migration notes for v5.3.

Automated Business Logic (ABL) with OpenXava

ABL is a library that allows you to write your business logic declaratively using annotations, this logic will be executed automatically on commit time.
ABL is included in OpenXava since v4.5. To active it you only need to add the next property to the persistence unit in your persistence.xml:
<persistence-unit name="default">
  ...
  <properties>
    ...
    <property name="hibernate.current_session_context_class"
          value="com.autobizlogic.abl.session.LogicThreadLocalSessionContext"/>
  </properties>
</persistence-unit>
Now you can add declarative logic, for example, if you have an entity like the next one:
package org.openxava.test.model
 
import javax.persistence.*
import org.openxava.annotations.*
 
@Entity
class MiniOrder {
 
    @Id
    int number
 
    @Column(length=40) @Required
    String description
 
    @Required
    BigDecimal productPrice
 
    @Required
    int qtyOrdered
 
    BigDecimal amount
 
}
You can define the calculation for the amount property writing a class with Logic sufix and ABL annotations:
package org.openxava.test.businesslogic
 
import com.autobizlogic.abl.annotations.*
 
class MiniOrderLogic {
 
    @Formula("productPrice * qtyOrdered") // This is an ABL annotations
    public void deriveAmount() { }
 
}
Just with this code each time that the database will be updated ABL will recalculate the amount value automatically.

Learn more about how to use ABL in OpenXava