Using TreeCacheAop inside Jboss via MBean
peterox Mar 23, 2004 6:48 PMAs the title suggests, I have been trying to access a TreeCacheAop inside of a session EJB with absolutely no luck.
Please help!!!
First some background.
JBoss version 4.0.0DR3
JDK 1.4.2_04
I have successfully created a TreeCacheMBean, via the MBeanServerFactory.
public class TesterBean
implements SessionBean {
SessionContext sessionContext;
protected TreeCacheMBean cache=null;
protected MBeanServer server=null;
static final String cache_service="jboss.cache:service=TreeCacheAop";
protected ObjectName cacheService = null;
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
List servers=MBeanServerFactory.findMBeanServer(null);
if(servers == null || servers.size() == 0)
{
//throw new Exception("TreeCacheView.init(): no MBeanServers found");
}
else
{
server=(MBeanServer)servers.get(0);
try {
cacheService = new ObjectName(cache_service);
cache = (TreeCacheMBean) MBeanProxyExt.create
(TreeCacheMBean.class,
cache_service, server);
}
catch (MalformedObjectNameException ex) {
System.out.println(ex.getMessage());
}
}
}And I did add a node via the put methods.
....
cache.put("/aNode", "test", "foo");....
All well and good. After that I tried to add an AOP object and found that there is no putObject method in TreeCacheMBean. So I tried the following:
public void addSoemthing(int ID, String name) {
try {
Fqn fqn = new Fqn(new Integer(sportID));
Sport newSport = new Sport(sportID, name);
Object[] args = {fqn, newSport};
String[] sig = {String.class.getName(), Object.class.getName()};
server.invoke(cacheService, "putObject", args, sig);
}
catch (ReflectionException ex) {
System.out.println(ex);
}
catch (MBeanException ex) {
System.out.println(ex);
}
catch (InstanceNotFoundException ex) {
System.out.println(ex);
}
}And I get the reflection exception:
Cause: java.lang.IllegalArgumentException: Unable to find operation putObject(java.lang.String,java.lang.Object)
I have just downloaded the JBoss source code and I can't even find the code for TreeCacheMBean???
What am I missing???
Thanks in advance.