blob: 866068844414ae408265691a8ac52369af2c0f78 [file] [log] [blame]
Jonathan Hart3d7730a2013-02-22 11:51:17 -08001package net.onrc.onos.registry.controller;
2
3import java.util.ArrayList;
4import java.util.Collection;
5
6import org.restlet.resource.Get;
7import org.restlet.resource.ServerResource;
8import org.slf4j.Logger;
9import org.slf4j.LoggerFactory;
10
11public class ControllerRegistryResource extends ServerResource {
12
Yuta HIGUCHI6ac8d182013-10-22 15:24:56 -070013 protected final static Logger log = LoggerFactory.getLogger(ControllerRegistryResource.class);
Jonathan Hart3d7730a2013-02-22 11:51:17 -080014
15 @Get("json")
16 public Collection<String> getControllers() {
17 IControllerRegistryService registry =
18 (IControllerRegistryService) getContext().getAttributes().
19 get(IControllerRegistryService.class.getCanonicalName());
20
21 Collection<String> controllers = null;
22 try {
23 controllers = registry.getAllControllers();
24 } catch (RegistryException e) {
25 log.warn("Error retrieving controller list: {}", e.getMessage());
26 }
27
28 if (controllers == null){
29 controllers = new ArrayList<String>();
30 }
31
32 return controllers;
33 }
34
35}