SDN Controller Programming Guide

161
Create a JSON [37] schema to express our data model. Create hm-
rs/src/main/resources/model.json file with the content from the following RSdoc JSON Schema
listing. (To add more schemas separate them by comma).
RSdoc JSON Schema:
{
"com.hp.hm.model.Switch":
{ "properties":
{
"id": {"type": "long"},
"mac_address": {"type": "string"},
"ip_address": {"type": "string"},
"friendly_name": {"type": "string"},
"active_state": {"type": "string"}
}
}
}
Create a class to register the RESTI API documentation provider under hm-rs module as in the
following DocProvider.java listing. In order to extend from SelfRegisteringRSDocProvider a
dependency must be added. Open the hm-rs/pom.xml file and add the XML extract from the
RSdoc Provider Dependency listing to the <dependencies> node; after updating the POM file
update the Eclipse project dependencies (see Updating Project Dependencies on page 115).
DocProvider.java:
package com.hp.hm.rs;
import org.apache.felix.scr.annotations.Component;
import com.hp.sdn.adm.rsdoc.RSDocProvider;
import com.hp.sdn.adm.rsdoc.SelfRegisteringRSDocProvider;
@Component
public class DocProvider extends SelfRegisteringRSDocProvider {
public DocProvider() {
super("hm", "rsdoc", DocProvider.class.getClassLoader());
}
}
NOTE
The name used to call the super class constructor (“hm”in
DocProvider.java
listing) must not contain
spaces; it may be any name but with no spaces because it is used to generate internal paths.
RSdoc Provider Dependency:
<dependency>
<groupId>com.hp.sdn</groupId>
<artifactId>sdn-adm-api</artifactId>