1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 28 import javax.management.ObjectName ; 29 import javax.management.MBeanServerConnection ; 30 import com.sun.enterprise.admin.common.ObjectNames; 31 32 import java.util.ArrayList ; 34 import java.util.Iterator ; 35 36 public class AddResourcesCommand extends GenericCommand{ 37 38 39 43 public void runCommand()throws CommandException, CommandValidationException{ 44 if (!validateOptions()) 45 throw new CommandValidationException("Validation failed"); 46 47 String objectName = getObjectName(); 48 Object [] params = getParamsInfo(); 49 String operationName = getOperationName(); 50 String [] types = getTypesInfo(); 51 52 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 53 getUser(), getPassword()); 54 try { 55 ArrayList returnValue =(ArrayList ) mbsc.invoke(new ObjectName (objectName), 56 operationName, params, types); 57 Iterator iterator= returnValue.iterator(); 58 while (iterator.hasNext()){ 59 String resource = (String ) iterator.next(); 60 CLILogger.getInstance().printMessage(" ========================="); 61 CLILogger.getInstance().printMessage(resource); 62 63 } 64 CLILogger.getInstance().printDetailMessage(getLocalizedString( 65 "CommandSuccessful", 66 new Object [] {name})); 67 }catch(Exception e){ 68 if (e.getLocalizedMessage() != null) 69 CLILogger.getInstance().printDetailMessage(e.getLocalizedMessage()); 70 throw new CommandException(getLocalizedString("CommandUnSuccessful", 71 new Object [] {name} ), e); 72 } 73 } 74 75 public boolean validateOptions() throws CommandValidationException { 76 return super.validateOptions(); 77 } 78 } 79 | Popular Tags |