Why Spring + lighty.io?
lighty.io targets the Java SE runtime, which means it is completely compatible with Spring Boot. The lighty-controller-spring-di artifact provides a Spring @Configuration base class that exposes all lighty.io services as Spring beans — ready for @Autowired injection anywhere in your application.
Project Setup
Generate a Spring Boot skeleton at start.spring.io with the Web dependency, then add lighty.io to your pom.xml:
<!-- Spring DI extension for lighty.io -->
<dependency>
<groupId>io.lighty.core</groupId>
<artifactId>lighty-controller-spring-di</artifactId>
<version>${lighty.version}</version>
</dependency>
<!-- Default single-node configuration -->
<dependency>
<groupId>io.lighty.resources</groupId>
<artifactId>singlenode-configuration</artifactId>
<version>${lighty.version}</version>
</dependency>
<!-- NETCONF Southbound module -->
<dependency>
<groupId>io.lighty.modules.southbound.netconf</groupId>
<artifactId>lighty-netconf-sb</artifactId>
<version>${lighty.version}</version>
</dependency>
lighty.io Spring Configuration
Create a @Configuration class extending LightyCoreSpringConfiguration. This initializes the lighty controller and any southbound plugins as Spring beans:
@Configuration
public class LightyConfiguration extends LightyCoreSpringConfiguration {
@Bean
LightyController initLightyController() throws Exception {
final LightyControllerBuilder lightyControllerBuilder = new LightyControllerBuilder();
final Set mavenModelPaths = new HashSet<>();
mavenModelPaths.addAll(NetconfConfigUtils.NETCONF_TOPOLOGY_MODELS);
mavenModelPaths.add($YangModuleInfoImpl.getInstance());
final LightyController lightyController = lightyControllerBuilder
.from(ControllerConfigUtils.getDefaultSingleNodeConfiguration(mavenModelPaths))
.build();
lightyController.start().get();
return lightyController;
}
@Bean
NetconfSBPlugin initNetconfSBP(LightyController lightyController)
throws ExecutionException, InterruptedException {
final NetconfConfiguration netconfSBPConfiguration =
NetconfConfigUtils.injectServicesToTopologyConfig(
NetconfConfigUtils.createDefaultNetconfConfiguration(),
lightyController.getServices());
final NetconfSBPlugin netconfSouthboundPlugin = new NetconfTopologyPluginBuilder()
.from(netconfSBPConfiguration, lightyController.getServices())
.build();
netconfSouthboundPlugin.start().get();
return netconfSouthboundPlugin;
}
}
NETCONF Device REST Service
With lighty services available as Spring beans, inject DataBroker and MountPointService directly into your REST controllers:
@RestController
@RequestMapping(path = "netconf")
public class NetconfDeviceRestService {
@Autowired
@Qualifier("BindingDataBroker")
private DataBroker dataBroker;
@Autowired
private MountPointService mountPointService;
// GET /netconf/list — returns all connected NETCONF devices
@GetMapping(path = "/list")
public ResponseEntity getNetconfDevicesIds() throws Exception { ... }
// PUT /netconf/id/{id} — connect a device
@PutMapping(path = "/id/{netconfDeviceId}")
public ResponseEntity connectNetconfDevice(
@PathVariable String netconfDeviceId,
@RequestBody NetconfDeviceRequest deviceInfo) throws Exception { ... }
// DELETE /netconf/id/{id} — disconnect a device
@DeleteMapping(path = "/id/{netconfDeviceId}")
public ResponseEntity disconnectNetconfDevice(
@PathVariable String netconfDeviceId) throws Exception { ... }
}
Connect a NETCONF Device
curl -X PUT http://localhost:8080/netconf/id/testDevice \
-H 'Content-Type: application/json' \
-d '{
"username": "admin",
"password": "admin",
"address": "127.0.0.1",
"port": "17830"
}'
List Connected Devices
curl -X GET http://localhost:8080/netconf/list -H 'Accept: application/json'
On success:
[
{
"nodeId": "testDevice",
"connectionStatus": "Connected",
"darknessFactor": 1000
}
]
darknessFactor field is read directly from the NETCONF device via its MountPoint using the toaster YANG model. This demonstrates how lighty.io bridges NETCONF device data into a Spring REST API with no extra serialization code.
Key Benefits
- All ODL services (DataBroker, MountPointService, RpcService, etc.) available as Spring beans
- Use Spring's full ecosystem: Spring Security, Spring Data, Spring Web alongside your SDN controller
- Write integration tests using Spring Boot Test — all components run in a single JVM
- No Karaf, no OSGi — pure Spring Boot application packaging (executable JAR or Docker image)