Cosmo 0.7 Service Layer Notes
The service layer consists of a group of interfaces and implementations that provide high-level apis for the application to use. For Cosmo it consists of
UserService and
ContentService .
UserService contains an api for managing users and
ContentService contains an api for managing items.
The implementations for these services are found in
org.osaf.cosmo.service.impl
StandardContentService
The
ContentService implementation uses a
LockManager to synchronize updates to collections. The morse code protocol implementation requires that access to collections must be synchronized. Two threads can't simultaneously update the same collection (add/update/remove item or modify collection details). For each method that updates a collection, locks to all collections involved must be obtained before the transaction completes. The default implementation for
LockManager is
SingleVMLockManager , which is a simple lock manager that works in a single vm (won't work in a clustered environment). Different
LockManager implementations can easily be plugged-in using Spring.
Transactions
Each service implementation is configured in Spring using a
TransactionalProxyFactoryBean , meaning the transaction boundary in Cosmo is the service layer. Each exposed service method is executed in a new transaction. Typically an update request results in the use of a single update service call. This ensures that if the service call fails, the transaction will be rolled back and the database will be returned to the state before the service call. If multiple service calls are required, then it is time to add a new service api that encompasses all the necessary logic for the transaction to be atomic.
--
RandyLetness - 20 Aug 2007