Skip to content

ManagedOperation can not be used on getter [SPR-5859] #10528

Closed
@spring-projects-issues

Description

@spring-projects-issues

tomliliu opened SPR-5859 and commented

Hi,

I'd like to understand why @ManagedOperation can not be used on getter.

I want some expensive metrics not exposed as attribute but retrieved by explicitly invoking the getter operation.
Ideally, I'd like to put @ManagedOperation on top of the getter method to do that.

Here is a use case:

@ManagedResource
public class Resource {
@ManagedOperation
public ExpensiveMetric getExpensiveMetric() {
//collecting the expensive metrics
....
return ...;
}
}

Because the computation is expensive, we want to avoid unnecessary computations. If we expose it as ManagedAttribute then a lot of unnecessary compuations will happen because visualvm will retrieve all attribute values even if the user is not interested in the expensive metrics at that moment. So that's the reason why we want to expose getExpensiveMetric as operation instead of attribute. And also, I am reluctant to change api only for the sake of exposing it as operation.

Thanks,
Tom


Affects: 2.5.6

Issue Links:

Referenced from: commits aa08c11

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions