... | ... | @@ -15,7 +15,47 @@ mvn clean compile |
|
|
cd ../example-delight-webapp
|
|
|
mvn cargo:run
|
|
|
```
|
|
|
This fires up the server on port 8080.
|
|
|
Browse to <http://localhost:8080/example-delight-webapp/delight> to read the online documentation.
|
|
|
This fires up an Apache Tomcat server on port 8080.
|
|
|
Browse to <http://localhost:8080/example-delight-webapp/> to read the online documentation.
|
|
|
|
|
|
Here is the code:
|
|
|
```java
|
|
|
@WebServlet(urlPatterns = { "/*" }, loadOnStartup = 1, asyncSupported=true)
|
|
|
@MultipartConfig(fileSizeThreshold = 1024 * 1024 * 10)
|
|
|
final public class ExampleDispatcherServlet extends AbstractDelightDispatcherServlet {
|
|
|
private static final long serialVersionUID = 9150648409043641572L;
|
|
|
|
|
|
@Override
|
|
|
protected DelightConfigBuilder getDelightConfigBuilder() throws DelightException {
|
|
|
return super.getDelightConfigBuilder()
|
|
|
.setOption(JsonOverHttpServletRequestHandler.Option.STRICT_SAME_ORIGIN_POLICY, false)
|
|
|
|
|
|
.setOption(MvnMicroRepoFeature.Option.MICRO_MVN_GROUP_ID, "dfki.sds.delight")
|
|
|
.setOption(MvnMicroRepoFeature.Option.MICRO_MVN_ARTIFACT_ID, "example")
|
|
|
.setOption(MvnMicroRepoFeature.Option.MICRO_MVN_VERSION, "0.1-alpha-fluent-SNAPSHOT")
|
|
|
.setOption(MvnMicroRepoFeature.Option.MICRO_MVN_DELIGHT_VERSION, "4.0-SNAPSHOT")
|
|
|
|
|
|
.setOption(StatsFeature.Option.LOG_INTERVAL, 10)
|
|
|
|
|
|
.usePresentFeatures(true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public InitFunction<DelightBackend> getBackendInitializer() {
|
|
|
return backend -> {
|
|
|
backend.addHandlerByClass("myHandler", ExampleHandler.class);
|
|
|
backend.addHandlerByClass("abstract", HandlerForAbstractInterface.class);
|
|
|
backend.addHandlerByClass("sse", SseHandler.class);
|
|
|
backend.addHandlerByClass(ServiceWithPredfinedHandlerName.class);
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
This defines a servlat that dispatches request to the Delight backend.
|
|
|
|
|
|
* Requests are directly mapped to the web-application context. The request URL-pattern is then `http://<HOST>:<PORT>/<WEBCONTEXT>/<HANDLERNAME>/<METHODNAME>?<PARAMNAME>=<VALUE>...`
|
|
|
* `asyncSupported` must be set for the Server-Sent Events feature to work
|
|
|
* `fileSizeThreshold` defines the maximum size of sent parameter values (e.g., though InputStream parameters)
|
|
|
* (Optional) Override the `getDelightConfigBuilder()` method to modify the default Delight config for your needs
|
|
|
* (Required) Override `getBackendInitializer()` to add handlers to the Delight backend |
|
|
\ No newline at end of file |