From 179db40e3adfefbc4f5b77e260c6a8c7fe46b472 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 22 Jan 2013 14:26:02 -0800 Subject: [PATCH] ApiDiscovery: Fix response and service impl to make them test-able --- .../api/response/ApiDiscoveryResponse.java | 16 ++++++++++++++++ .../discovery/ApiDiscoveryServiceImpl.java | 12 +++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java index de6a9f93965..77484f0f7e7 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java @@ -57,18 +57,34 @@ public class ApiDiscoveryResponse extends BaseResponse { this.name = name; } + public String getName() { + return name; + } + public void setDescription(String description) { this.description = description; } + public String getDescription() { + return description; + } + public void setSince(String since) { this.since = since; } + public String getSince() { + return since; + } + public void setAsync(Boolean isAsync) { this.isAsync = isAsync; } + public boolean getAsync() { + return isAsync; + } + public String getRelated() { return related; } diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java index f06e2005552..5ac2281b84e 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java @@ -58,18 +58,16 @@ public class ApiDiscoveryServiceImpl implements ApiDiscoveryService { if (s_apiNameDiscoveryResponseMap == null) { long startTime = System.nanoTime(); s_apiNameDiscoveryResponseMap = new HashMap(); - cacheResponseMap(); + //TODO: Fix and use PluggableService to get the classes + Set> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class, + new String[]{"org.apache.cloudstack.api", "com.cloud.api"}); + cacheResponseMap(cmdClasses); long endTime = System.nanoTime(); s_logger.info("Api Discovery Service: Annotation, docstrings, api relation graph processed in " + (endTime - startTime) / 1000000.0 + " ms"); } } - private void cacheResponseMap() { - Set> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class, - new String[]{"org.apache.cloudstack.api", "com.cloud.api"}); - - //TODO: Fix and use PluggableService to get the classes - + protected void cacheResponseMap(Set> cmdClasses) { Map> responseApiNameListMap = new HashMap>(); for (Class cmdClass : cmdClasses) {