blob: 21b0c0978c06338587573ff623e571791493e632 [file] [log] [blame]
Naoki Shiotab32edf52013-12-12 14:09:36 -08001package net.onrc.onos.registry.controller.web;
Jonathan Hart3d7730a2013-02-22 11:51:17 -08002
3import java.util.HashMap;
4import java.util.List;
5import java.util.Map;
6
Naoki Shiotab32edf52013-12-12 14:09:36 -08007import net.onrc.onos.registry.controller.ControllerRegistryEntry;
8import net.onrc.onos.registry.controller.IControllerRegistryService;
9
Jonathan Hart3d7730a2013-02-22 11:51:17 -080010import org.restlet.resource.Get;
11import org.restlet.resource.ServerResource;
Jonathan Hart3d7730a2013-02-22 11:51:17 -080012
13public class SwitchRegistryResource extends ServerResource {
Jonathan Hart3d7730a2013-02-22 11:51:17 -080014
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 Hart3d7730a2013-02-22 11:51:17 -080028 return switches;
29 }
30}