Overview of Services
Jprovocateur Services (implemented in BusinessLogic class) are more focused on the actual business logic. The idea is that the analyst would be able to provide a simple and clear analysis document to the developer and the developer will map the defined rules to the actual code; This means that mainly on a Service you will validate that data on the POJOs are correct, manipulate them according to business rules and save them on the database.
Each service is build in independent blocks, this means that even if one of your services has problem will not affect the rest of your services; you can even disable it throught the administration menu while in production, until a patch is applied.
Each Service is executed by a flow controller. The flow controller will execute them according to your configuration
- will check that the user has access rights
- will call the validation method to check that the data supplied are ok
- will start a transaction if required.
- will call the execution method to save/update/delete/list the data
- will return the result to its client (the MVC)
Methods on a BasisLogic Class
Jprovocateur offers a class that allows you by extending it, to implement fast the basic CRUD operations or complicated ones. A service is structured in a way that the developer can separate the initialization of the action, the validation of data rules and finally the realization of the action.
The Initializer method on a service is responsible to init your data and return them to the client, e.g. when a user wants to perform an update on a record, he press a button to open the form with the data loaded, the initialize method is responsible e.g to communicate with the database and return the data based on a key.
After the user has modified the record and pressed the update, the system should validate that the entered values are correct. The validation method validates the supplied data, using the Oval Annototations defined on the POJO and any additional business rules that the developer implemented.
After the the successeful validation of the data, the execute method is responsible to perform the actual business purpose of the class e.g for a user registration system, the purpose of the class is to make persistent the user object and send a confirmation email to the user address.
Why to use a BusinessLogic to implement your Services
- 5 lines of code
- simple configuration on the db for the access rights
- Spring Annotations.
in order to created a service (with transaction management, security, validation) that is accessible on the web and can service transparently requests from your Ext J.S forms or other systems.
You can have a look on the example services