Prevent non public bean to be exposed to JMX

Previously, a package private `@ManagedResource` annotated bean was
registered to the JMX domain even if any attempt to invoke an operation
on it will fail since it has to be public.

This commit validates that any `@ManagedResource` annotated bean is
public and throws an InvalidMetadataException otherwise. Note that the
actual bean type does not have to be public as long as the class
annotated with `@ManagedResource` in the hierarchy is pubic and no extra
operations or attributes are defined on the child.

Issue: SPR-14042
This commit is contained in:
Stephane Nicoll
2016-03-15 09:51:11 +01:00
parent 582864802e
commit 33a4e9e57f
4 changed files with 179 additions and 74 deletions

View File

@@ -3508,6 +3508,9 @@ be marked with the `ManagedAttribute` annotation. When marking properties you ca
either the annotation of the getter or the setter to create a write-only or read-only
attribute respectively.
NOTE: A `ManagedResource` annotated bean must be public as well as the methods exposing
an operation or an attribute.
The example below shows the annotated version of the `JmxTestBean` class that you saw
earlier: