This content has been marked as final.
Show 3 replies
-
1. Re: How to access TreeCache from MBean ?
brian.stansberry Mar 27, 2007 11:34 AM (in response to raameshwar)You're in luck in that a JBoss utility class for simplifying dealing with JMX happens to be in a jar that JBC depends on. So, assuming your cache was somehow created and registered in MBeanServer 'server' under ObjectName 'name':
TreeCacheMBean cache = (TreeCacheMBean) org.jboss.mx.util.MBeanProxyExt.create(TreeCacheMBean.class, name.getCanonicalName(), server); // Only do this if whatever bound your cache in JMX didn't start it!!! cache.startService(); cache.put("/a/b/c", map);
What you're doing here is creating a proxy that delegates calls to the JMX server, which routes them to your mbean. -
2. Re: How to access TreeCache from MBean ?
genman Mar 27, 2007 2:12 PM (in response to raameshwar)I don't know why you guys suggest that class, and not the standard one:
http://java.sun.com/j2se/1.5.0/docs/api/javax/management/MBeanServerInvocationHandler.htmlIf you have an MBean server mbs containing an MBean with ObjectName name, and if the MBean's management interface is described by the Java interface Intf, you can construct a proxy for the MBean like this: Intf proxy = (Intf) MBeanServerInvocationHandler.newProxyInstance(mbs, name, Intf.class, false); Suppose, for example, Intf looks like this: public interface Intf { public String getSomeAttribute(); public void setSomeAttribute(String value); public void someOperation(String param1, int param2); }
-
3. Re: How to access TreeCache from MBean ?
brian.stansberry Mar 27, 2007 2:37 PM (in response to raameshwar)Because I looked for a standard one in the JDK 5 Javadoc for 10 mins and didn't find one, and that was my time budget for responding to the post. :-)
Thanks for pointing it out.