Reference Guide

Table Of Contents
DAOData access object to interact with the persistence layer.
A sample of each of these will be presented in this section. For demonstration purposes a
Demo application that persists Alerts in the Distributed Database (Cassandra) has been
created.
Business Logic Reference
When the Cassandra demo application is installed, the OSGi service for business logic gets
activated. This service provides a north bound interface. Any external entity/app can use this
service via the API provided by this service. In this case, we have Alert service using Cassandra.
This service provides an API for all north bound operations such as posting an Alert into the
database, deleting the alerts and updating the alert state. There is another interface that provides
for the READ operations and is mostly used by the GUI interface. This second north bound service
is called CassandraAlertUIService.
The implementation of these services needs to interact with the underlying persistence layer. This is
done by using an OSGi @Reference as shown below.
CassandraAlertManager.java:
@Component
@Service
public class CassandraAlertManager implements
CassandraAlertUIService, CassandraAlertService {
@Reference(policy = ReferencePolicy.DYNAMIC,
cardinality = ReferenceCardinality.MANDATORY_UNARY)
private volatile DataStoreService<DataStoreContext> dataStoreService;
@Reference(policy = ReferencePolicy.DYNAMIC,
cardinality = ReferenceCardinality.MANDATORY_UNARY)
private volatile DistQueryService<DataStoreContext> queryService;
...
}
The above snippet shows the usage of @Reference. OSGi framework caches the dataStoreService
and queryService objects in the CassandraAlertManager. Whenever, the client or application
issues a query to the database, these objects will be used to get access to the persistence layer.
DTO (Transport Object)
Data that needs to be persisted can be divided into logical groups and these logical groups are
tables of the database. Every table has fixed columns and every row has a fixed type of Row Key
or Primary Key.
DTO is a java representation of a row of a table in the database. Any application that needs to
write a row needs to fill data into a DTO and hand it over to the persistence layer. The persistence
layer understands a DTO and converts it into a format that is required for the underlying database.
The reverse holds too. When reading something from the database, the data will be converted into
a DTO (for a single row read) or a list of DTO (multi row read) or a page of DTO (paged read)
and given back to the requestor.
Here is an example DTO used in the demo app:
CassandraAlert.java:
89