Automated Business Logic is designed to minimize and eliminate coding changes required to specify business logic.
You can configure an existing project to use Automated Business Logic using the procedures described in the sub-sections below. You can further explore these settings with the Example described in the following section.
Configure your DataSource
Automated Business Logic operates by handling Gorm events. This is activated by adding the following line to your
currentSessionContextClass = org.springframework.orm.hibernate3.SpringSessionContext
You can copy the properties files from the BusLogicIntroGrails project into yours. They do not require alteration, but you can configure them as described here.
You will also want to copy the file
As shown at the right, copy the following your unzipped distribution to your projects'
Your transactional business logic will of course only be invoked in the context of transactions, so you must ensure that all activity is bracketed by transactions.One easy way to do this is to add the @Transactional annotation (more specifically org.springframework.transaction.annotation.Transactional) to your controller objects. Your service objects will by default be transactional, which works fine here. You can also do this programmatically, or by using the transactional dependency injection. This is a vast topic, which is thankfully covered in Grails documentation (see here for programmatic transactions, and here for more details on Spring transactions).Any activity that is not bracketed within a transaction will not invoke any transactional business logic.
The download zip contains the elements of a Grails project. Proceed as described in Grails Demo Installation. You can investigate the resultant Grails project.
You can then introduce business logic into your own projects. Note you can start very simply: just configure and declare some simple logic - perhaps a multi-attribute constraint, or an auditing rule.