Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

In progress for 5.3

In progress with MAGNOLIA-5708 - Getting issue details... STATUS - some of the ideas below are being worked on, such that this page isn't exactly up to date.


The Problem

Servlet mappings are currently configured under /filters/servlets. Often times, other components in the system need to know about those mappings. A simple example: generating links for the DAM servlet.


Make it possible for arbitrary components to know how/where a servlet is mapped.

Use Cases

  • Generating DAM links
  • Generating links to Imaging module
  • Links to REST APIs
  • essentially anything exposed via a Servlet where we need to generate links to.

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, ...)




Introduce a subclass for ServletDispatchingFilter (which uses a specific impl of  info.magnolia.cms.filters.Mapping).

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

Implementation example:

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

        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 MyModule.getFooPath(), and MyModule would be @injected in said filter.


Screenshots should be speaking enough:

Current servet mapping:


1) Path (mapping) in the module:

2) Different configuration for the servlet node:


I have a POC working in my local DAM branch.

I would suggest having this (the abstract) in core.

I can update this concept with proposed naming.

Additionally, might make sense to change the package of these new classes (from info.magnolia.cms.filters to info.magnolia.servlets and/or info.magnolia.filters.servlets)


  • No labels