SDN Controller Programming Guide

160
ServiceRest Dependency:
<dependency>
<groupId>com.hp.sdn</groupId>
<artifactId>sdn-common-api</artifactId>
<version>${sdn.version}</version>
</dependency>
<dependency>
<groupId>com.hp.sdn</groupId>
<artifactId>sdn-common-misc</artifactId>
<version>${sdn.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
<scope>test</scope>
</dependency>
In order to use SwitchTransferService inject a reference into the business logic implementation
(SwitchManager for example) as depicted in Consuming Services with OSGi Declarative Services
on page 134. Note how SwitchTransferManager with @Component and @Service is directly
annotated. It is possible to have followed the same pattern described in Providing Services with
OSGi Declarative Services on page 126 to keep our communication service implementation clean
from the OSGi restrictions, however communication service implementations rarely consume other
services and thus there is no need of dealing with the fact that dependency components may
come and go (Binding/unbinding injected references).
In real applications creating `new modules to locate communication services would result in a
better organization: For example, using hm-ext-api module for the communication service
interfaces (instead than hm-api as in this example) and hm-ext for the implementations (instead
than hm-bl as in this example).
Creating RSdoc
Trying the REST API with Curl on page 145 describes a way to try the REST API by executing
commands. The HP VAN SDN Controller SDK offers a method to create a semi-automated
interactive RESTful API documentation which offers a better way to interact with REST APIs. It is
called RSdoc because is a combination of JAX-RS [2] and Javadoc [22].
One big advantage of the RSdoc is that JAX-RS annotations and Javadoc are already written when
implementing RESTful Web Services, thus in order to enable the application to create the RSdoc is
relatively easy and automatic: a few configuration files need to be updated.