2727
2828import org .apache .log4j .Logger ;
2929
30- import com .cloud .agent .AgentManager ;
31- import com .cloud .async .AsyncJobManager ;
3230import com .cloud .configuration .ConfigurationService ;
33- import com .cloud .consoleproxy .ConsoleProxyManager ;
31+ import com .cloud .consoleproxy .ConsoleProxyService ;
32+ import com .cloud .dao .EntityManager ;
3433import com .cloud .exception .ConcurrentOperationException ;
3534import com .cloud .exception .InsufficientCapacityException ;
3635import com .cloud .exception .ResourceUnavailableException ;
3736import com .cloud .network .DomainRouterService ;
38- import com .cloud .network .NetworkManager ;
39- import com .cloud .network .security .NetworkGroupManager ;
40- import com .cloud .server .ManagementServer ;
41- import com .cloud .storage .StorageManager ;
42- import com .cloud .storage .snapshot .SnapshotManager ;
43- import com .cloud .template .TemplateManager ;
37+ import com .cloud .network .NetworkService ;
38+ import com .cloud .network .security .NetworkGroupService ;
39+ import com .cloud .resource .ResourceService ;
40+ import com .cloud .server .ManagementService ;
41+ import com .cloud .storage .StorageService ;
42+ import com .cloud .storage .snapshot .SnapshotService ;
43+ import com .cloud .template .TemplateService ;
4444import com .cloud .user .Account ;
4545import com .cloud .user .AccountService ;
4646import com .cloud .utils .Pair ;
@@ -89,33 +89,35 @@ public enum CommandType {
8989 public static ConfigurationService _configService ;
9090 public static AccountService _accountService ;
9191 public static UserVmService _userVmService ;
92- public static ManagementServer _mgr ;
93- public static AsyncJobManager _asyncMgr ;
94- public static StorageManager _storageMgr ;
95- public static AgentManager _agentMgr ;
96- public static NetworkManager _networkMgr ;
97- public static TemplateManager _templateMgr ;
98- public static NetworkGroupManager _networkGroupMgr ;
99- public static SnapshotManager _snapshotMgr ;
100- public static ConsoleProxyManager _consoleProxyMgr ;
101- public static DomainRouterService _routerMgr ;
92+ public static ManagementService _mgr ;
93+ public static StorageService _storageMgr ;
94+ public static ResourceService _resourceService ;
95+ public static NetworkService _networkService ;
96+ public static TemplateService _templateService ;
97+ public static NetworkGroupService _networkGroupMgr ;
98+ public static SnapshotService _snapshotMgr ;
99+ public static ConsoleProxyService _consoleProxyMgr ;
100+ public static DomainRouterService _routerService ;
101+ public static ResponseGenerator _responseGenerator ;
102+ public static EntityManager _entityMgr ;
102103
103104
104- static void setComponents (){
105- ComponentLocator locator = ComponentLocator .getLocator (ManagementServer .Name );
105+ static void setComponents (ResponseGenerator generator ){
106+ ComponentLocator locator = ComponentLocator .getLocator (ManagementService .Name );
107+ _mgr = (ManagementService )ComponentLocator .getComponent (ManagementService .Name );
106108 _accountService = locator .getManager (AccountService .class );
107109 _configService = locator .getManager (ConfigurationService .class );
108110 _userVmService = locator .getManager (UserVmService .class );
109- _mgr = ( ManagementServer ) locator .getComponent ( "management-server" );
110- _asyncMgr = locator .getManager (AsyncJobManager .class );
111- _storageMgr = locator .getManager (StorageManager .class );
112- _agentMgr = locator .getManager (AgentManager .class );
113- _networkMgr = locator .getManager (NetworkManager .class );
114- _templateMgr = locator .getManager (TemplateManager .class );
115- _networkGroupMgr = locator .getManager (NetworkGroupManager .class );
116- _snapshotMgr = locator .getManager (SnapshotManager .class );
117- _consoleProxyMgr = locator .getManager (ConsoleProxyManager .class );
118- _routerMgr = locator . getManager ( DomainRouterService . class ) ;
111+ _storageMgr = locator .getManager ( StorageService . class );
112+ _resourceService = locator .getManager (ResourceService .class );
113+ _networkService = locator .getManager (NetworkService .class );
114+ _templateService = locator .getManager (TemplateService .class );
115+ _networkGroupMgr = locator .getManager (NetworkGroupService .class );
116+ _snapshotMgr = locator .getManager (SnapshotService .class );
117+ _consoleProxyMgr = locator .getManager (ConsoleProxyService .class );
118+ _routerService = locator .getManager (DomainRouterService .class );
119+ _entityMgr = locator .getManager (EntityManager .class );
120+ _responseGenerator = generator ;
119121 }
120122
121123 public abstract void execute () throws ResourceUnavailableException , InsufficientCapacityException , ServerApiException , ConcurrentOperationException ;
@@ -334,14 +336,14 @@ public String buildResponse(ServerApiException apiException, String responseType
334336 StringBuffer sb = new StringBuffer ();
335337 if (RESPONSE_TYPE_JSON .equalsIgnoreCase (responseType )) {
336338 // JSON response
337- sb .append ("{ \" " + getName () + "\" : { " + "\" @attributes\" :{\" cloud-stack-version\" :\" " +ApiDBUtils .getVersion ()+"\" }," );
339+ sb .append ("{ \" " + getName () + "\" : { " + "\" @attributes\" :{\" cloud-stack-version\" :\" " +_mgr .getVersion ()+"\" }," );
338340 sb .append ("\" errorcode\" : \" " + apiException .getErrorCode () + "\" , \" description\" : \" " + apiException .getDescription () + "\" } }" );
339341 } else {
340342 sb .append ("<?xml version=\" 1.0\" encoding=\" ISO-8859-1\" ?>" );
341343 sb .append ("<" + getName () + ">" );
342344 sb .append ("<errorcode>" + apiException .getErrorCode () + "</errorcode>" );
343345 sb .append ("<description>" + escapeXml (apiException .getDescription ()) + "</description>" );
344- sb .append ("</" + getName () + " cloud-stack-version=\" " +ApiDBUtils .getVersion ()+ "\" >" );
346+ sb .append ("</" + getName () + " cloud-stack-version=\" " +_mgr .getVersion ()+ "\" >" );
345347 }
346348 return sb .toString ();
347349 }
@@ -352,10 +354,10 @@ public String buildResponse(List<Pair<String, Object>> tagList, String responseT
352354
353355 // set up the return value with the name of the response
354356 if (RESPONSE_TYPE_JSON .equalsIgnoreCase (responseType )) {
355- prefixSb .append ("{ \" " + getName () + "\" : { \" @attributes\" :{\" cloud-stack-version\" :\" " +ApiDBUtils .getVersion ()+"\" }," );
357+ prefixSb .append ("{ \" " + getName () + "\" : { \" @attributes\" :{\" cloud-stack-version\" :\" " + _mgr .getVersion ()+"\" }," );
356358 } else {
357359 prefixSb .append ("<?xml version=\" 1.0\" encoding=\" ISO-8859-1\" ?>" );
358- prefixSb .append ("<" + getName () + " cloud-stack-version=\" " +ApiDBUtils .getVersion ()+ "\" >" );
360+ prefixSb .append ("<" + getName () + " cloud-stack-version=\" " +_mgr .getVersion ()+ "\" >" );
359361 }
360362
361363 int i = 0 ;
0 commit comments