blob: 1db2560cb25cfded467c1010ba7d64d8caea72c5 [file] [log] [blame]
Jonathan Hartdeda0ba2014-04-03 11:14:12 -07001package net.onrc.onos.core.registry.web;
Jonathan Hart3d7730a2013-02-22 11:51:17 -08002
3import java.util.HashMap;
4import java.util.List;
5import java.util.Map;
6
Jonathan Hartdeda0ba2014-04-03 11:14:12 -07007import net.onrc.onos.core.registry.ControllerRegistryEntry;
8import net.onrc.onos.core.registry.IControllerRegistryService;
Naoki Shiotab32edf52013-12-12 14:09:36 -08009
Jonathan Hart3d7730a2013-02-22 11:51:17 -080010import org.restlet.resource.Get;
11import org.restlet.resource.ServerResource;
Jonathan Hart3d7730a2013-02-22 11:51:17 -080012
13public class SwitchRegistryResource extends ServerResource {
Ray Milkey269ffb92014-04-03 14:43:30 -070014
15 @Get("json")
16 public Map<String, List<ControllerRegistryEntry>> getAllControllers() {
17 IControllerRegistryService registry =
18 (IControllerRegistryService) getContext().getAttributes().
19 get(IControllerRegistryService.class.getCanonicalName());
20
21 Map<String, List<ControllerRegistryEntry>> switches = null;
22 switches = registry.getAllSwitches();
23
24 if (switches == null) {
25 switches = new HashMap<String, List<ControllerRegistryEntry>>();
26 }
27
28 return switches;
29 }
Jonathan Hart3d7730a2013-02-22 11:51:17 -080030}