SDN Controller Programming Guide

125
public Switch get(Id<Switch, Long> id);
public List<Switch> find(SwitchFilter filter,
SortSpecification<SwitchSortKey> sortSpecification);
public void delete(Id<Switch, Long> id);
}
Services expose methods that use transfer objects, primitive types, object value types and common
data structures in their signatures; thus, these entities become part of the API and they remain the
same no matter the implementation we choose for our services.
The Switch service depends on the hm-model module because model objects are defined there,
thus the hm-api POM file needs to resolve the dependencies. Open the hm-api/pom.xml file and
add the XML extract from the following listing to the <dependencies> node. After updating the
POM file update the Eclipse project dependencies (see Updating Project Dependencies on page
115).
Application Model Dependency:
<dependency>
<groupId>com.hp.hm</groupId>
<artifactId>hm-model</artifactId>
<version>${project.version}</version>
</dependency>
Service Implementation
Implementation of our API or services will be located at the hm-bl module. As with hm-api, the
business logic module will also depend on the hm-model, as well as on the hm-api module. So
open the hm-bl/pom.xml file and add the XML extract from the following listing to the
<dependencies> node; after updating the POM file update the Eclipse project dependencies (see
Updating Project Dependencies on page 115).
Application API Dependency:
<dependency>
<groupId>com.hp.hm</groupId>
<artifactId>hm-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.hp.hm</groupId>
<artifactId>hm-api</artifactId>
<version>${project.version}</version>
</dependency>
Now, create the Open Flow Service implementation, name it SwitchManager The suffix
Manager is used to denote services implementations. The following listing shows an extract of the
implementation. For the moment it returns fake data, in later information the fake data is replaced
by more realistic data.
SwitchManager.java (Sample Application Service Implementation):
package com.hp.hm.impl;