blob: 17ad48cf3699340f8a8eb0cd6ee22ab37a2c5278 [file] [log] [blame]
Jonathan Hart3d7730a2013-02-22 11:51:17 -08001package net.onrc.onos.registry.controller;
2
3import java.util.HashMap;
4import java.util.List;
5import java.util.Map;
6
7import org.restlet.resource.Get;
8import org.restlet.resource.ServerResource;
9import org.slf4j.Logger;
10import org.slf4j.LoggerFactory;
11
12public 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}