Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Name for @ManagedOperation in Spring JMX

I used org.springframework.jmx.export.annotation.@ManagedOperation to expose a method as MBean.

I want the operation name different from the method name, but managed operation doesn't have any attribute for it.

For example:

@ManagedOperation
public synchronized void clearCache() 
{
   // do something
}

and I want this operation exposed with name = "ResetCache".

like image 930
Sam Avatar asked Dec 07 '22 17:12

Sam


1 Answers

I would just define another method that just delegates to clearCache(). We do this all of the time when the interface name is confusing. A description = "resets the cache" inside of the @ManagedOperation might also be a good idea.

@ManagedOperation(description = "resets the cache")
public void resetCache() {
   clearCache();
}
like image 118
Gray Avatar answered Dec 09 '22 07:12

Gray