You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Injecting custom restrictor into JolokiaServletRegistration #823
Originally posted by vbeilin April 6, 2025
Hi,
I wonder if there is am idiomatic way to use a custom restrictor defined in my Spring context with the Spring Boot /actuator/jolokia endpoint. AgentServlet accepts Restrictor as a constructor parameter, but JolokiaServletRegistration does not use this constructor. ServletConfig, which could be used to find the application context, is not passed to a custom restrictor constructor.
This seems to leave either replacing JolokiaServletRegistration with a copy that would create an AgentServlet instance with a given restrictor, or making current application context in creation visible in a thread local, or creating a detached application context inside the restrictor class.
Is there anything I'm missing?
I added simple ApplicationContext query, so org.jolokia.server.core.service.api.Restrictor instances are looked up in Spring context (or parents in case of separate main and management contexts). Here's the log:
10:51:58 INFO {http-nio-8181-exec-1} [org.apache.juli.logging.DirectJDKLog] (DirectJDKLog.java:173) : jolokia: Using registered restrictor "customRestrictor".
in this simple application:
@SpringBootApplicationpublicclassApplication {
publicstaticvoidmain(String[] args) {
SpringApplication.run(Application.class);
}
/** * This {@link Restrictor} will be available in Spring's context and used later in * {@link org.jolokia.server.core.http.AgentServlet}. * @return */@BeanpublicRestrictorcustomRestrictor() {
returnnewRestrictor() {
@OverridepublicbooleanisHttpMethodAllowed(HttpMethodpMethod) {
returntrue;
}
...
Activity
tadayosi commentedon Apr 9, 2025
@grgrzybek Hawtio has extended AgentServlet to support configuration via system properties.
https://hawt.io/docs/configuration.html#_configuring_jolokia_through_system_properties
I think that's something that should be ported to Jolokia itself. We can also make configuration possible via Spring Boot and Quarkus' application properties. That should solve the original issue, too.
grgrzybek commentedon Apr 28, 2025
I added simple ApplicationContext query, so
org.jolokia.server.core.service.api.Restrictorinstances are looked up in Spring context (or parents in case of separate main and management contexts). Here's the log:in this simple application:
vbeilin commentedon May 16, 2025
Thank you!
[Fixes jolokia#823] Allow custom Restrictor to be registered as Spring …