
docs._configurations.30_dispatcher_config.md Maven / Gradle / Ivy
---
layout: page
title: Dispatcher Configuration
permalink: /configuration/dispatcher_config
---
## Configuring Web Layer
The Web Layer can be configured by Spring MVC controllers served by a dispatcher servlet
(configured in `web.xml`). Configuration includes content negotiation, serialization config,
and Web controller injections.
### Dispatcher Servlet
This describes an example configuration via Spring. There are lots of variants and
alternatives which may end in the same result. This example splits Spring configuration
files into two main files:
* `/WEB-INF/spring/dispatcher-servlet.xml` contains Web controllers and views
* `/WEB-INF/spring/application-context.xml` contains SPI implementations
However, everything starts by adding Spring's `DispatcherServlet` within the `web.xml`,
put both configuration files, and relate it to some context path like so:
```xml
api-dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/spring/dispatcher-servlet.xml,/WEB-INF/spring/application-context.xml
1
api-dispatcher
/api/*
```
### Content Negotiation
To support proper content negotiation and JSON serialization the following should be
added to the `/WEB-INF/spring/dispatcher-servlet.xml`:
```xml
```
### Web Controller injections
A Web controller serves an endpoint and behaves like described in the [Web API]({{site.baseurl}}/api.html). It
performs [I/O operations]({{site.baseurl}}/io.html) (graph rendering, generalization, etc.) if neccessary.
{:.n52-callout .n52-callout-info}
A Web controller delegates data request to the actual SPI implementation so it has to be
referenced here. SPI implementors have to use these references to make sure the right
backend service is called.
```xml
```
{::options parse_block_html="true" /}
{:.n52-callout .n52-callout-info}
Known application properties are
Some things to note:
* `${external.url}` and `${request.interval.restriction}` are property placeholders defined in
an extra application properties file
* `org.n52.web.ctrl.ParameterBackwardsCompatibilityAdapter` is a backwards compatibility wrapper
* `metadataExtensions` list contains extensions which adds further metadata to `//extras`
### General Properties
Configurable properties are
* `requestIntervalRestriction`: sets the maximum time period a clients can query data for, e.g. `P380D`
* `externalUrl`: sets the external URL under which the API can be accessed by clients, e.g. (`https://example.com/my-api/`)
## Extensions
See [Extension section]({{site.baseurl}}/extensions.html) for how to configure extensions in detail.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy