[SPR-5859] @ManagedOperation can now be used on getters/setters
This commit is contained in:
@@ -87,11 +87,6 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource {
|
||||
}
|
||||
|
||||
public ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException {
|
||||
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
|
||||
if (pd != null) {
|
||||
throw new InvalidMetadataException(
|
||||
"The ManagedOperation attribute is not valid for JavaBean properties. Use ManagedAttribute instead.");
|
||||
}
|
||||
Annotation ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedOperation.class);
|
||||
if (ann == null) {
|
||||
return null;
|
||||
|
||||
@@ -355,7 +355,9 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
|
||||
info.setDescriptor(desc);
|
||||
}
|
||||
}
|
||||
else if (includeOperation(method, beanKey)) {
|
||||
|
||||
// allow getters and setters to be marked as operations directly
|
||||
if (info == null && includeOperation(method, beanKey)) {
|
||||
info = createModelMBeanOperationInfo(method, method.getName(), beanKey);
|
||||
Descriptor desc = info.getDescriptor();
|
||||
desc.setField(FIELD_ROLE, ROLE_OPERATION);
|
||||
|
||||
@@ -156,11 +156,11 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
||||
protected boolean includeOperation(Method method, String beanKey) {
|
||||
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
|
||||
if (pd != null) {
|
||||
return hasManagedAttribute(method);
|
||||
}
|
||||
else {
|
||||
return hasManagedOperation(method);
|
||||
if(hasManagedAttribute(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return hasManagedOperation(method);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user