Xafari Context Service

Some services are supposed to process their own data. This processing may be organized in different ways depending on where it is used (View, business method, DB update) and how large is the size of the object to process. That is where context services should be used.

IXafariService declares a context service to solve the next tasks:

  • Transactional approach to working on service data. It includes the isolation of changes until the CommitChanges operation is called and it also provides the opportunity to make a Rollback afterwards.
  • Batch data processing before committing changes.
  • Unified processing algorithm for data coming from IObjectSpace or UnitOfWork.

Unlike a standard service, a context one is intended to use its own special methods to expand the abilities of IObjectSpace and UnitOfWork. For example, the Numerators service automatically creates numbers for all objects before saving them.

The most prominent features of context services are their abilities to react to IObjectSpace or UnitOfWork events and to perform the operations CommitChanges(), Rollback(), and Reload() in synchronization with IObjectSpace or UnitOfWork. These operations are the core functionality of context services.

Important

During the implementation of a context service, all work with persistent data should be done with the help of the DataAccessor object. The access to this object is possible by request to a certain DataAccessor property. Such approach is required to stabilize the work of both IObjectSpace and UnitOfWork services.

Xafari provides a base abstract class XafariServiceBase to implement context services IXafariService. It is required, that  each context service should define its own context class derived from ServiceSpaceContextBase.

xafari_service_1

To get extensive knowlege about Xafari context services, refer to the Custom Service Example and IServiceSpace topics.