ApiServer: Fix apidiscovery fail case, fix comment

Signed-off-by: Rohit Yadav <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/765504c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/765504c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/765504c0

Branch: refs/heads/javelin
Commit: 765504c070919cd8e6ee53e23985a37c9a7ecdf6
Parents: ef89793
Author: Rohit Yadav <[email protected]>
Authored: Wed Jan 9 04:15:19 2013 -0800
Committer: Rohit Yadav <[email protected]>
Committed: Wed Jan 9 04:18:35 2013 -0800

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiServer.java |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/765504c0/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java 
b/server/src/com/cloud/api/ApiServer.java
index 8d304e0..56cef12 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -168,9 +168,7 @@ public class ApiServer implements HttpRequestHandler {
 
     public static void initApiServer(String[] apiConfig) {
         if (s_instance == null) {
-            //Injecting will create ApiServer object with all its
-            //vars injected as well, no need to do the following:
-            //s_instance = new ApiServer();
+            //Injection will create ApiServer and all its fields which have 
@Inject
             s_instance = ComponentLocator.inject(ApiServer.class);
             s_instance.init(apiConfig);
         }
@@ -178,7 +176,6 @@ public class ApiServer implements HttpRequestHandler {
 
     public static ApiServer getInstance() {
         // Assumption: CloudStartupServlet would initialize ApiServer
-        // initApiServer(null);
         if (s_instance == null) {
             s_logger.fatal("ApiServer instance failed to initialize");
         }
@@ -210,6 +207,11 @@ public class ApiServer implements HttpRequestHandler {
             
_apiNameCmdClassMap.putAll(discoveryService.getApiNameCmdClassMapping());
         }
 
+        if (_apiNameCmdClassMap.size() == 0) {
+            s_logger.fatal("ApiServer failed to generate apiname, cmd class 
mappings."
+                         + "Please check and enable at least one ApiDiscovery 
adapter.");
+        }
+
         encodeApiResponse = 
Boolean.valueOf(configDao.getValue(Config.EncodeApiResponse.key()));
         String jsonType = 
configDao.getValue(Config.JavaScriptDefaultContentType.key());
         if (jsonType != null) {

Reply via email to