Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.registry.web; |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 2 | |
| 3 | import java.util.HashMap; |
| 4 | import java.util.List; |
| 5 | import java.util.Map; |
| 6 | |
Jonathan Hart | deda0ba | 2014-04-03 11:14:12 -0700 | [diff] [blame] | 7 | import net.onrc.onos.core.registry.ControllerRegistryEntry; |
| 8 | import net.onrc.onos.core.registry.IControllerRegistryService; |
Naoki Shiota | b32edf5 | 2013-12-12 14:09:36 -0800 | [diff] [blame] | 9 | |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 10 | import org.restlet.resource.Get; |
| 11 | import org.restlet.resource.ServerResource; |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 12 | |
| 13 | public class SwitchRegistryResource extends ServerResource { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 14 | |
| 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 Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 30 | } |