1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.*; 27 import javax.management.MBeanServerConnection ; 28 import com.sun.appserv.management.client.ProxyFactory; 29 import com.sun.appserv.management.DomainRoot; 30 import com.sun.appserv.management.base.XTypes; 31 import com.sun.appserv.management.config.J2EEApplicationConfig; 32 import com.sun.appserv.management.config.WebServiceEndpointConfig; 33 import com.sun.appserv.management.config.WebServiceEndpointConfigKeys; 34 import java.util.StringTokenizer ; 35 import java.util.Iterator ; 36 import java.util.Set ; 37 import java.util.Map ; 38 import java.util.HashMap ; 39 40 public class ConfigureWebServiceCommand extends BaseTransformationRuleCommand 41 { 42 private static final String MONITORING_OPTION = "monitoring"; 43 private static final String MAX_HISTORY_SIZE_OPTION = "maxhistorysize"; 44 45 49 public void runCommand() throws CommandException, CommandValidationException 50 { 51 validateOptions(); 52 try 53 { 54 MBeanServerConnection mbsc = getMBeanServerConnection(getHost(), getPort(), 55 getUser(), getPassword()); 56 DomainRoot domainRoot = ProxyFactory.getInstance(mbsc).getDomainRoot(); 57 String webServiceName = (String ) getOperands().get(0); 59 validateWebServiceName(webServiceName, true); 60 WebServiceEndpointConfig wsc = 61 getWebServiceEndpointConfig(mbsc, webServiceName, true); 62 if (wsc == null) 63 throw new CommandException(getLocalizedString("CannotFindWebservice")); 64 65 String maxHistorySize = getOption(MAX_HISTORY_SIZE_OPTION); 66 String monitoring = getOption(MONITORING_OPTION); 67 if (maxHistorySize != null) 68 { 69 wsc.setMaxHistorySize(maxHistorySize); 70 } 71 if (monitoring != null) 72 { 73 wsc.setMonitoringLevel(monitoring); 74 } 75 CLILogger.getInstance().printDetailMessage(getLocalizedString( 76 "CommandSuccessful", 77 new Object [] {name})); 78 } 79 catch(Exception e) 80 { 81 displayExceptionMessage(e); 82 } 83 84 } 85 86 87 92 private String getWebServiceName() throws CommandException 93 { 94 String operand = (String ) getOperands().get(0); 95 StringTokenizer paramsTokenizer = new StringTokenizer (operand, "#"); 96 int size = paramsTokenizer.countTokens(); 97 if (size != 3) 98 throw new CommandException(getLocalizedString("InvalidWebServiceEndpoint")); 99 return paramsTokenizer.nextToken(); 100 } 101 102 103 107 private String getWebServiceEndPoint() throws CommandException 108 { 109 String operand = (String ) getOperands().get(0); 110 int index = operand.indexOf("#"); 111 return operand.substring(index+1); 112 } 113 114 115 119 private Map getOptionMap() throws CommandException 120 { 121 HashMap map = new HashMap (); 122 String maxHistorySize = getOption(MAX_HISTORY_SIZE_OPTION); 123 String monitoring = getOption(MONITORING_OPTION); 124 map.put(WebServiceEndpointConfigKeys.MONITORING_LEVEL_KEY, monitoring); 125 map.put(WebServiceEndpointConfigKeys.MAX_HISTORY_SIZE_KEY, maxHistorySize); 126 return map; 127 } 128 } 129 | Popular Tags |