-
1. Re: AOP integration with JMX question
kabirkhan Jan 22, 2007 7:29 AM (in response to bossy)"bossy" wrote:
My question is - is it possible to do write an Ascpect XMBean and if so - where should I look for more details.
Not really, but it should be possible to have your plain aspect delegate onto an MBean that can be used to store/display the stats? -
2. Re: AOP integration with JMX question
bossy Jan 22, 2007 8:51 AM (in response to bossy)Thanks,
but could you be more specific about what you mean when you say:"... plain aspect delegate onto an MBean ..."
I tried the following:
In my aspect I make this call:server.invoke(statsMBean, "increaseCount", null,null);
, which works fine, but the problem is that in order to be able to call the increaseCountmethod from my aspect I need to expose it in the -xmbean.xml, which in turn makes it available to the user in the JMX console, i.e the user can increase the count from the JMX console. -
3. Re: AOP integration with JMX question
kabirkhan Jan 22, 2007 12:18 PM (in response to bossy)Hmm,
What you mention is a problem with JMX, there is no "proper" way to work around this.
One way to enforce that the values can only be set by your aspect would be to have your aspect set/clear a value in a ThreadLocal surrounding the call to invocation.invokeNext() and in the increaseCount() method of your MBean check for the exsistance of that value in the ThreadLocal. If called by the JMX console, i.e. not from the aspecy that ThreadLocal value will not exist, so it is a noop.
Alternatively, you could use the aspect instance as a parameter to the increaseCount method, which would make it impossible to invoke via the console. -
4. Re: AOP integration with JMX question
bossy Jan 22, 2007 3:08 PM (in response to bossy)I see.
I'll think about these two approaches.
Thanks.