March 14, 2014

Basic Architectural Design of Service for Enterprise Applications with Class Diagram and Sequence Diagram

Basic requirements for a service implementation are transaction, logging, authorization and of course business rules with service operations. When you think deeply you will see that these requirements are cross cut concerns. It means transaction, logging, security and business rule engine can be thought aspects, infrastructural requirements. These are independent from business domain.

Why transactional ?
It is important for the integrity and consistency of data.

Why log ?
It is important to observe performance, security, errors, statistics.

Why authorization ?
It is important to achieve that any client uses service, can call only operations which it has rights to call.

Why business rule engine ?
Any service operation has some business rules and it is important to cover them with a modern approach.

About Class Diagram of Service
  • The service is designed modular, each module can be thought a service or services, when a module is dependent to an other module, interaction between modules must be using service interfaces.These are important for high cohesion.
  • A Service implementation has data access objects to achieve database operations. 
  • Both service, data access objects and of course service client uses entities to do operations.
  • All service operations must be transactional. It means when a service method is called, all operations, all data access object operations must be in same transaction. So if service call succeed all database changes must be applied to the databases, but if it is failed none of them must be applied.
  • Transaction, business rule engine, log and authorization can be implemented as java interceptors or decorators. Because these are all aspects and independent from business domain.
About Sequence Diagram of Service
  • When a service method is called, transaction is started by the transaction manager.
  • Log Service is used to log that operation is called and other logs for example performance considerations.
  • Authorization Service is used for checking that client has access grants to call service method.
  • Business Rule Engine is used to execute domain specific business rules.
*Log Service and Authorization Service can be seperated from business transaction. The order of service call can be changed according to the different approaches.

Service Class Diagram.vsd, Service Sequence Diagram.vsd

No comments:

Post a Comment