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; |
| 9 | import org.slf4j.Logger; |
| 10 | import org.slf4j.LoggerFactory; |
| 11 | |
| 12 | public class SwitchRegistryResource extends ServerResource { |
| 13 | |
| 14 | protected static Logger log = LoggerFactory.getLogger(SwitchRegistryResource.class); |
| 15 | |
| 16 | @Get("json") |
| 17 | public Map<String, List<ControllerRegistryEntry>> getAllControllers(){ |
| 18 | IControllerRegistryService registry = |
| 19 | (IControllerRegistryService) getContext().getAttributes(). |
| 20 | get(IControllerRegistryService.class.getCanonicalName()); |
| 21 | |
| 22 | Map<String, List<ControllerRegistryEntry>> switches = null; |
| 23 | switches = registry.getAllSwitches(); |
| 24 | |
| 25 | if (switches == null){ |
| 26 | switches = new HashMap<String, List<ControllerRegistryEntry>>(); |
| 27 | } |
| 28 | |
| 29 | log.debug("GETTING ALL CONTROLLERS"); |
| 30 | |
| 31 | for (List<ControllerRegistryEntry> list: switches.values()){ |
| 32 | for (ControllerRegistryEntry en : list) { |
| 33 | log.debug("Controller id {}", en.getControllerId()); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | |
| 38 | return switches; |
| 39 | } |
| 40 | } |