• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to define sig[] and args[] in invoke() method in JMX?

 
sam joe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody know how to define args[] and sig[] for the following situation.

If I have

public void upload(String filename, byte[] data);
public int add(int a, int b);

in the mbean,

how should I define args[] and sig[] for them?

Thanks for your help.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For

public void upload(String filename, byte[] data);

args or param will look something like below

String strType;
byte[] byteArrayType;
Object[] params = new Object[]{strType, byteArrayType};
String[] signature = new String[] { "java.lang.String","[B"}

"[B" is internal representation for byte array.
and for

public int add(int a, int b);


Object[] params = new Object[]{new Integer(5), new Integer(10)};
String signature = new String[] {"int", "int"};

Should work.

But it's better to consider using MBeanServerInvocationHandler.newProxyInstance method to get MBean Proxy and work with that.
 
Sudharsan Govindarajan
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But it's better to consider using MBeanServerInvocationHandler.newProxyInstance method to get MBean Proxy and work with that.


Thanks for the this tip Purushothoman, it helped me out of a frustrating issue!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic