[jboss-cvs] JBossAS SVN: r57269 - branches/Branch_4_0/console/src/main/org/jboss/console/twiddle/command

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 28 14:01:46 EDT 2006


Author: ssambasivam at jboss.com
Date: 2006-09-28 14:01:43 -0400 (Thu, 28 Sep 2006)
New Revision: 57269

Modified:
   branches/Branch_4_0/console/src/main/org/jboss/console/twiddle/command/SetCommand.java
Log:
JIRA-JBAS-3454

When we try to set MBean attribute using SetCommand class, the arguments are filtered by the Getopt utility class used in the SetCommand class. But, the validity 
of the arguments should (can) be checked by the corresponding MBeans instead of the GetOpt class. 

Modified: branches/Branch_4_0/console/src/main/org/jboss/console/twiddle/command/SetCommand.java
===================================================================
--- branches/Branch_4_0/console/src/main/org/jboss/console/twiddle/command/SetCommand.java	2006-09-28 18:00:42 UTC (rev 57268)
+++ branches/Branch_4_0/console/src/main/org/jboss/console/twiddle/command/SetCommand.java	2006-09-28 18:01:43 UTC (rev 57269)
@@ -105,9 +105,16 @@
 						("Option requires an argument: " + args[getopt.getOptind() - 1]);
 
 				case '?':
-					throw new CommandException
-						("Invalid (or ambiguous) option: " + args[getopt.getOptind() - 1]);
+            	{
+					String arg = args[getopt.getOptind() - 1];
 
+					argidx=setArgValues(argidx,arg);
+
+					break;
+
+					
+            	}
+
 				case 0x1000:
 					prefix = false;
 					break;
@@ -116,26 +123,20 @@
 				case 1:
 					{
 						String arg = getopt.getOptarg();
+						
+						argidx=setArgValues(argidx,arg);
 
-						switch (argidx++)
-						{
-							case 0:
-								objectName = createObjectName(arg);
-								log.debug("mbean name: " + objectName);
-								break;
-
-							default:
-								log.debug("adding attribute name: " + arg);
-								attributeNames.add(arg);
-								break;
-						}
 						break;
 					}
 			}
+			
+			
 		}
 
 		return true;
 	}
+	
+	
    
 
    public void execute(String[] args) throws Exception
@@ -161,6 +162,8 @@
 		MBeanAttributeInfo[] attrs = info.getAttributes();
 		
 		MBeanAttributeInfo attr=null;
+		
+//		System.out.println("I am here shak's msg");
 
 		boolean found = false;
 		for (int i=0;i < attrs.length ; i++ ) 
@@ -201,7 +204,28 @@
 		
 
    }
+   
+   //Channge is made to set all possible arguments to MBean
+   
+   private int setArgValues(int argdixValue, String argValue) throws CommandException{
+	   
+	   switch (argdixValue++)
+		{
+			case 0:
+				objectName = createObjectName(argValue);
+				log.debug("mbean name: " + objectName);
+				break;
 
+			default:
+				log.debug("adding attribute name: " + argValue);
+				attributeNames.add(argValue);
+				break;
+		}
+	   
+	   return argdixValue;
+	   
+   }
+
 	/**
 	 * Convert val into an Object of type type
 	 * @param val The given value




More information about the jboss-cvs-commits mailing list