commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-commons/modeler/src/java/org/apache/commons/modeler/ant JmxInvoke.java
Date Thu, 26 Dec 2002 18:07:04 GMT
costin      2002/12/26 10:07:04

  Modified:    modeler/src/java/org/apache/commons/modeler/ant
                        JmxInvoke.java
  Log:
  Better names ( more consistent with jmx )
  
  Add support for parameters for the <jmx-invoke> task.
  
  Revision  Changes    Path
  1.2       +23 -9     jakarta-commons/modeler/src/java/org/apache/commons/modeler/ant/JmxInvoke.java
  
  Index: JmxInvoke.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/ant/JmxInvoke.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JmxInvoke.java	12 Nov 2002 22:46:09 -0000	1.1
  +++ JmxInvoke.java	26 Dec 2002 18:07:04 -0000	1.2
  @@ -58,30 +58,30 @@
   import javax.management.*;
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  +import java.util.Vector;
   
   /**
    * Set mbean properties.
    *
    */
   public class JmxInvoke extends Task {
  -    String name;
  +    String objectName;
   
       String method;
  +    Vector args;
   
       public JmxInvoke() {
   
       }
   
  -
  -    public void setName(String name) {
  -        this.name = name;
  +    public void setObjectName(String name) {
  +        this.objectName = name;
       }
   
  -    public void setMethod(String method) {
  +    public void setOperation(String method) {
               this.method = method;
       }
   
  -
       public void execute() {
           try {
               MBeanServer server=(MBeanServer)project.getReference("jmx.server");
  @@ -96,10 +96,24 @@
                   project.addReference("jmx.server", server);
               }
   
  -            ObjectName oname=new ObjectName(name);
  -
  -            server.invoke(oname, method, null, null);
  +            ObjectName oname=new ObjectName(objectName);
   
  +            if( args==null ) {
  +                server.invoke(oname, method, null, null);
  +            } else {
  +                // XXX Use the loader ref, if any
  +                Object argsA[]=new Object[ args.size()];
  +                String sigA[]=new String[args.size()];
  +                for( int i=0; i<args.size(); i++ ) {
  +                    Arg arg=(Arg)args.elementAt(i);
  +                    if( arg.type==null )
  +                        arg.type="java.lang.String";
  +                    sigA[i]=arg.getType();
  +                    argsA[i]=arg.getValue();
  +                    // XXX Deal with not string types - IntrospectionUtils
  +                }
  +                server.invoke(oname, method, argsA, sigA);
  +            }
           } catch(Exception ex) {
               ex.printStackTrace();
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message