Reference Guide

Table Of Contents
JSON Module Dependencies:
<dependency>
<groupId>com.hp.util</groupId>
<artifactId>hp-util-codec</artifactId>
<version>${hp-util.version}</version>
</dependency>
<dependency>
<groupId>com.hp.sdn</groupId>
<artifactId>sdn-adm-api</artifactId>
<version>${sdn.version}</version>
</dependency>
The HP VAN SDN Controller SDK uses the Jackson API [38] as the underlying API to handle JSON
conversion.
In order to make the SwitchJsonCodec, and any other codec in the application, available so it can
be reused, create a JSON factory that is registered to the central JSON repository which is
exposed as a regular service called JsonService. The following listing shows the implementation of
this JSON factory:
HmJsonFactory.java:
package com.hp.hm.rs.json;
import com.hp.util.json.AbstractJsonFactory;
import com.hp.util.json.JsonFactory;
...
@Component
@Service
@Property(name = "app", value = "flare")
public class HmJsonFactory extends AbstractJsonFactory {
public HmJsonFactory() {
// Register all application’s JSON codecs
addCodecs(Switch.class, new SwitchJsonCodec());
}
@Deactivate
protected void deactivate() {
clearCodecs();
}
}
HmJsonFactory holds all the JSON codecs; it is an OSGi service so it is registered to the central
JSON repository when it is activated and unregistered from the JSON repository when it is
deactivated. The registration happens automatically because the HP VAN SDN Controller
Framework observes all activated JSON Factories (JsonFactory) services annotated with the
following property: name=flare”.
186