Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 1 | package net.onrc.onos.registry.controller; |
| 2 | |
| 3 | import java.util.HashMap; |
| 4 | import java.util.List; |
| 5 | import java.util.Map; |
| 6 | |
| 7 | import org.restlet.resource.Get; |
| 8 | import org.restlet.resource.ServerResource; |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 9 | |
| 10 | public class SwitchRegistryResource extends ServerResource { |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 11 | |
| 12 | @Get("json") |
| 13 | public Map<String, List<ControllerRegistryEntry>> getAllControllers(){ |
| 14 | IControllerRegistryService registry = |
| 15 | (IControllerRegistryService) getContext().getAttributes(). |
| 16 | get(IControllerRegistryService.class.getCanonicalName()); |
| 17 | |
| 18 | Map<String, List<ControllerRegistryEntry>> switches = null; |
| 19 | switches = registry.getAllSwitches(); |
| 20 | |
| 21 | if (switches == null){ |
| 22 | switches = new HashMap<String, List<ControllerRegistryEntry>>(); |
| 23 | } |
| 24 | |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 25 | return switches; |
| 26 | } |
| 27 | } |