Naoki Shiota | b32edf5 | 2013-12-12 14:09:36 -0800 | [diff] [blame^] | 1 | package net.onrc.onos.registry.controller.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 | |
Naoki Shiota | b32edf5 | 2013-12-12 14:09:36 -0800 | [diff] [blame^] | 7 | import net.onrc.onos.registry.controller.ControllerRegistryEntry; |
| 8 | import net.onrc.onos.registry.controller.IControllerRegistryService; |
| 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 { |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [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 | |
Jonathan Hart | 3d7730a | 2013-02-22 11:51:17 -0800 | [diff] [blame] | 28 | return switches; |
| 29 | } |
| 30 | } |