You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/11 23:19:36 UTC

[2/3] git commit: api: Fix obj injections in ApiServer

api: Fix obj injections in ApiServer

- Inject classes using Inject annotation
- Don't misuse component locator

Signed-off-by: Rohit Yadav <bh...@apache.org>


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

Branch: refs/heads/api_refactoring
Commit: 79b54e6ac1eea7ccc6a76255be3770f4e8b03703
Parents: 6ce68b9
Author: Rohit Yadav <bh...@apache.org>
Authored: Tue Dec 11 14:16:25 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Tue Dec 11 14:16:25 2012 -0800

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


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/79b54e6a/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 8a41966..2719765 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -127,18 +127,19 @@ public class ApiServer implements HttpRequestHandler {
 
     public static boolean encodeApiResponse = false;
     public static String jsonContentType = "text/javascript";
-    private Properties _apiCommands = null;
     private ApiDispatcher _dispatcher;
-    private AccountManager _accountMgr = null;
-    private DomainManager _domainMgr = null;
-    private AsyncJobManager _asyncMgr = null;
+
+    @Inject private AccountManager _accountMgr = null;
+    @Inject private DomainManager _domainMgr = null;
+    @Inject private AsyncJobManager _asyncMgr = null;
+    @Inject(adapter = APIAccessChecker.class)
+    protected Adapters<APIAccessChecker> _apiAccessCheckers;
+
     private Account _systemAccount = null;
     private User _systemUser = null;
     private static int _workerCount = 0;
     private static ApiServer s_instance = null;
     private static final DateFormat _dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
-    @Inject(adapter = APIAccessChecker.class)
-    protected Adapters<APIAccessChecker> _apiAccessCheckers;
 
     private static ExecutorService _executor = new ThreadPoolExecutor(10, 150, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("ApiServer"));
 
@@ -169,15 +170,12 @@ public class ApiServer implements HttpRequestHandler {
         BaseCmd.setComponents(new ApiResponseHelper());
         BaseListCmd.configure();
 
-        ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
-        _accountMgr = locator.getManager(AccountManager.class);
-        _asyncMgr = locator.getManager(AsyncJobManager.class);
         _systemAccount = _accountMgr.getSystemAccount();
         _systemUser = _accountMgr.getSystemUser();
         _dispatcher = ApiDispatcher.getInstance();
-        _domainMgr = locator.getManager(DomainManager.class);
 
         Integer apiPort = null; // api port, null by default
+        ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
         ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
         SearchCriteria<ConfigurationVO> sc = configDao.createSearchCriteria();
         sc.addAnd("name", SearchCriteria.Op.EQ, "integration.api.port");