SDN Controller Programming Guide

83
}
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:
package com.hp.demo.cassandra.model.alert;
import com.hp.api.Id;
import com.hp.demo.cassandra.model.AbstractTransportable;
...
public class CassandraAlert extends
AbstractTransportable<CassandraAlert, String> {
...
private Severity severity;
private Date timestamp;
private String description;
private boolean state;
private String origin;
private String topicId;
public CassandraAlert(String sysId, boolean state, String topicId,
String origin, Date timestamp, Severity severity, String description) {
super(sysId);
init(topicId, origin, timestamp, severity, state, description);
}
public CassandraAlert(String uid, String sysId, boolean state,
String topicId, String origin, Date timestamp,
Severity severity, String description) {
super(uid, sysId);
init(topicId, origin, timestamp, severity, state, description);
}