blob: 676bcb3ff0ed5de94005c3a248086c47c5c79782 [file] [log] [blame]
package net.onrc.onos.registry.controller.web;
import java.util.ArrayList;
import java.util.Collection;
import net.onrc.onos.registry.controller.IControllerRegistryService;
import net.onrc.onos.registry.controller.RegistryException;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ControllerRegistryResource extends ServerResource {
protected final static Logger log = LoggerFactory.getLogger(ControllerRegistryResource.class);
@Get("json")
public Collection<String> getControllers() {
IControllerRegistryService registry =
(IControllerRegistryService) getContext().getAttributes().
get(IControllerRegistryService.class.getCanonicalName());
Collection<String> controllers = null;
try {
controllers = registry.getAllControllers();
} catch (RegistryException e) {
log.warn("Error retrieving controller list: {}", e.getMessage());
}
if (controllers == null){
controllers = new ArrayList<String>();
}
return controllers;
}
}