Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Such a mapping could be configured in the module's own class - and therefore used by the servlet mapping AND other arbitrary components (URI2RepoMapping, Link API, templating functions, ...)

 

Proposal

Concept

A replacement/Introduce a subclass for ServletDispatchingFilter and  (which uses a specific impl of  info.magnolia.cms.filters.Mapping. A developer ).

Servlets can still be used with current mechanism, "configured mappings", or with the new one: a developer would need to subclass the that new Filter class replacement and implement a getDynamicMappinga getDynamicMapping() method.

Implementation example:

Code Block
languagejava
    public static class DamServletWrappingFilter extends ThatNewSubclassOfServletDFilter {
        private final DamCoreConfiguration damCfg;


        @Inject
        public Filter(DamCoreConfiguration configuration) {
            this.damCfg = configuration;
        }

        // This would be abstract in super class
        protected String getDynamicMapping() {
            return damCfg.getDownloadPath() + "/*";
        }
 
        // Optionally, we could do this; seems to make sense, would remove redundant config (this filter will always be coupled with this servlet, won't it)
        protected Class getServletClass() {
            return DamDownloadServlet.class;
        }
    }

This thus allows other components to use the same path, configured in one single place, for different purposes (typically to generate links)

(Where this method would delegate to MyModuleto MyModule.getFooPath(), and MyModule would be @injected and MyModule would be @injected in said filter.

Implementation

Screenshots should be speaking enough:

...