Announcement Announcement Module
Collapse
No announcement yet.
Adding ResourceHandlers at runtime Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding ResourceHandlers at runtime

    Hello

    I have a Spring 3.1 MVC application with a multi-tenant design (multiple customers supported by one application). Each customer has their own ResourceHandler mapping for static resource paths (CSS files etc.). These ResourceHandlers are added programatically in a WebMvcConfigurerAdapter subclass (based on directories on disk), via addResourceHandlers(ResourceHandlerRegistry registry). This is all annotation driven.

    I would like to add support for updating the customer resource path mappings at runtime via an "admin" controller. The problem I have is that I'm not sure how to get access to the WebMvcConfigurerAdapter subclass instance in my controller, or how to access the ResourceHandlerRegistry instance in order to call addResourceHandlers.

    Any pointers much appreciated.
    Richard

  • #2
    Adding them to the registry is useless, this is only used at configuration time not at runtime. You would need to register your handler with the SimpleUrlHandlerMapping that is used to register the already available ResourceHandlers. The latter you can simply get injected.

    Comment


    • #3
      It would be better if you could figure out what resource mappings you need at startup.

      Comment

      Working...
      X