[jboss-cvs] JBossAS SVN: r71215 - trunk/console/src/main/org/jboss/console/twiddle/command.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 24 19:05:31 EDT 2008


Author: dimitris at jboss.org
Date: 2008-03-24 19:05:31 -0400 (Mon, 24 Mar 2008)
New Revision: 71215

Modified:
   trunk/console/src/main/org/jboss/console/twiddle/command/InvokeCommand.java
Log:
JBAS-5108, print out 'invoke' results, even when no property editor is found.

Modified: trunk/console/src/main/org/jboss/console/twiddle/command/InvokeCommand.java
===================================================================
--- trunk/console/src/main/org/jboss/console/twiddle/command/InvokeCommand.java	2008-03-24 23:00:44 UTC (rev 71214)
+++ trunk/console/src/main/org/jboss/console/twiddle/command/InvokeCommand.java	2008-03-24 23:05:31 UTC (rev 71215)
@@ -1,45 +1,38 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.console.twiddle.command;
 
+import java.beans.PropertyEditor;
 import java.io.PrintWriter;
-
-import java.util.List;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Collections;
-
-import java.beans.PropertyEditor;
-
-import javax.management.ObjectName;
+import java.util.List;
 import javax.management.MBeanInfo;
 import javax.management.MBeanOperationInfo;
 import javax.management.MBeanServerConnection;
-import javax.management.MBeanParameterInfo;
+import javax.management.ObjectName;
 
 import gnu.getopt.Getopt;
 import gnu.getopt.LongOpt;
-
 import org.jboss.util.Strings;
 import org.jboss.util.propertyeditor.PropertyEditors;
 
@@ -47,7 +40,8 @@
  * Invoke an operation on an MBean.
  *
  * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  * @version <tt>$Revision$</tt>
  */
 public class InvokeCommand
@@ -193,7 +187,7 @@
       {
          MBeanOperationInfo opInfo = ops[i];
          MBeanOp op = new MBeanOp(opInfo.getName(), opInfo.getSignature());
-         if( inputOp.equals(op) == true )
+         if (inputOp.equals(op) == true)
          {
             matchOp = op;
             break;
@@ -207,24 +201,24 @@
          OpCountComparator comparator = new OpCountComparator();
          Collections.sort(opList, comparator);
          int match = Collections.binarySearch(opList, inputOp, comparator);
-         if( match >= 0 )
+         if (match >= 0)
          {
             // Validate that the match op equates to the input op
             matchOp = (MBeanOp) opList.get(match);
             match = comparator.compare(matchOp, inputOp);
-            if( match != 0 )
+            if (match != 0)
             {
                throw new CommandException("MBean has no such operation named '" +
-                  opName + "' with signature compatible with: "+opArgs);
+                  opName + "' with signature compatible with: " + opArgs);
             }
          }
          else
          {
             throw new CommandException("MBean has no such operation named '" +
-               opName + "' with signature compatible with: "+opArgs);
+               opName + "' with signature compatible with: " + opArgs);
          }
       }
-
+      
       // convert parameters with PropertyEditor
       int count = matchOp.getArgCount();
       Object[] params = new Object[count];
@@ -236,7 +230,7 @@
          params[i] = editor.getValue();
       }
       log.debug("Using params: " + Strings.join(params, ","));
-
+      
       // invoke the operation
       Object result = server.invoke(name, opName, params, matchOp.getSignature());
       log.debug("Raw result: " + result);
@@ -248,10 +242,18 @@
 
          if (result != null)
          {
-            PropertyEditor editor = PropertyEditors.getEditor(result.getClass());
-            editor.setValue(result);
-            resultText = editor.getAsText();
-            log.debug("Converted result: " + resultText);
+            try
+            {
+               PropertyEditor editor = PropertyEditors.getEditor(result.getClass());
+               editor.setValue(result);
+               resultText = editor.getAsText();
+               log.debug("Converted result: " + resultText);
+            }
+            catch (RuntimeException e)
+            {
+               // No property editor found or some conversion problem
+               resultText = result.toString();
+            }
          }
          else
          {




More information about the jboss-cvs-commits mailing list