1 16 package org.jmanage.cmdui.commands; 17 18 import org.jmanage.cmdui.CommandHandler; 19 import org.jmanage.cmdui.HandlerContext; 20 import org.jmanage.cmdui.util.Out; 21 import org.jmanage.core.services.ConfigurationService; 22 import org.jmanage.core.services.ServiceFactory; 23 import org.jmanage.core.data.ApplicationConfigData; 24 25 import java.util.List ; 26 import java.util.Iterator ; 27 28 33 public class ListApplicationsHandler implements CommandHandler { 34 35 public boolean execute(HandlerContext context) { 36 37 ConfigurationService configService = 38 ServiceFactory.getConfigurationService(); 39 List appConfigList = configService.getAllApplications( 40 context.getServiceContext()); 41 for(Iterator it=appConfigList.iterator(); it.hasNext();){ 42 ApplicationConfigData appConfig = (ApplicationConfigData)it.next(); 43 if(appConfig.isCluster()){ 44 Out.println(appConfig.getName() + " [cluster]"); 45 for(Iterator it2=appConfig.getChildApplications().iterator();it2.hasNext();){ 46 Out.print("+ "); 47 printApplication((ApplicationConfigData)it2.next()); 48 } 49 }else{ 50 printApplication(appConfig); 51 } 52 } 53 return true; 54 } 55 56 private void printApplication(ApplicationConfigData appConfig){ 57 assert !appConfig.isCluster(); 58 Out.print(appConfig.getName()); 59 Out.println(" [" + appConfig.getType() + "]" + 60 "\t" + appConfig.getURL() + 61 "\t" + appConfig.getUsername()); 62 } 63 64 public String getShortHelp() { 65 return "Lists all configured applications in jManage"; 66 } 67 68 public void help() { 69 Out.println(getShortHelp()); 70 } 71 } 72 | Popular Tags |