Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • delight delight
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Commits
Collapse sidebar
  • delight
  • delightdelight
  • Wiki
  • ExampleWebApp

ExampleWebApp · Changes

Page history
Update ExampleWebApp authored May 24, 2019 by Andreas Lauer's avatar Andreas Lauer
Hide whitespace changes
Inline Side-by-side
ExampleWebApp.md
View page @ 70aebc5c
......@@ -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
Clone repository
  • DocuFeature
  • ExampleServer
  • ExampleWebApp
  • Home
  • ServerSentEventsFeature
  • StatsFeature
  • people
  • xmlrpc
    • Documentation
    • ExampleUsingConverterRegistry
    • ExampleUsingOwnConceteTypes
    • ExampleUsingOwnInterfaceTypes
    • ExampleUsingThirdPartyTypes
    • ExampleUsingXmlRpcBeans
    • ExampleUsingXmlRpcCompliantTypes

Legal Notice, Imprint, Privacy Policy