Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
Servlet mapping specifies which servlet should be invoked when the client requests a particular URL. In Magnolia, servlet mappings are typically configured in
/server/filters/servlets. This is a static way. While creating a component (Java class or Freemarker script), the path to a servlet is hard-coded. When the mapping changes, the hard-coded string literal must be changed too and the software must be re-deployed. To work around this limitation, use dynamic servlet mapping. Magnolia 5.3+
Dynamic mapping with SelfMappingServlet
The SelfMappingServlet interface makes dynamic servlet mapping possible. The interface has one method:
Implement the interface in your own servlet. Instead of returning a hard-coded literal, return something originating in a configuration. Any other Java class such as a model class used in a Freemarker script can then read the value.
Other components in the system may need to know about servlet mappings. This is the case when generating links for the DAM servlet.
DamDownloadServlet implements the
getSelfMappingPath() method returns a value which comes from the
DamCoreConfiguration - which could be injected into any other class, too.
DamCoreConfiguration#getDownloadPath() is also used in
JcrAssetProvider to construct paths for links:
If for whatever reason the mapped path to the
DamDownloadServlet must be changed, there is only one place where the path is adapted:
/modules/dam/config/downloadPath in module configuration. The code of
JcrAssetProvider remain the same. This means you don't need to re-deploy the application. You only need to change configuration on the running system.
You won't find anything at
DamCoreConfiguration#getDownloadPath() has a default value.