When using @ManagedOperation on a method, allow overriding methods in that subclass,to be exposed as an operation. [SPR-5813] #10483
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Kaz Chehresa opened SPR-5813 and commented
When I use
@ManagedOperation
on a method, and then a subclass overrides that method, the method is not exposed as an operation anymore.Here is an example:
<code>
@ManagedResource
class A implements SelfNaming {
@ManagedOperation
public void doSomething() {System.out.println("Doesn't do anything");}
public ObjectName getName() {return new ObjectName("someName-that is derived dynamically, for eg via BeanNameAware or smth");}
}
@ManagedResource
class B {
public void doSomething() {System.out.println("Does something useful!");}
}
</code>
When I expose an instance of B, the method doSomething is not exposed as an operation.
To solve the issue, I have to do this:
<code>
@ManagedResource
class B {
@ManagedOperation
public void doSomething() {System.out.println("Does something useful!");}
}
</code>
which is a bit redundant, given I already mentioned that I want to expose that method as an operation in the main class.
I think this is especially important for people who extend classes from infrastructure libraries, because they will likely not see that this method was being exposed, and will forget to put the annotation again in their own subclass.
Referenced from: commits 8f6a42b
The text was updated successfully, but these errors were encountered: