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
  • ExampleServer

ExampleServer · Changes

Page history
Create ExampleServer authored May 17, 2019 by Andreas Lauer's avatar Andreas Lauer
Hide whitespace changes
Inline Side-by-side
ExampleServer.md 0 → 100644
View page @ 9fc6bf3e
# Running the Example Server
There is an example server available. A Jetty-server is running the Delight server.
A bunch of Delight features are loaded. Online-documentation is incuded, too.
How to start?
```bash
git clone https://git.opendfki.de/delight/delight.git
#compile
cd delight/delight-root
mvn clean compile
#run the server
cd ../example-delight-server
mvn exec:java -Dexec.mainClass=de.dfki.delight.example.ExampleEmbeddedServer
```
This fires up the server on port 8080.
Here's the code
```java
public class ExampleEmbeddedServer
{
public static void main(String[] args) throws Exception
{
DelightConfig cfg = DelightConfigFinder.getDefaultConfigBuilder()
.setOption("STRICT_SAME_ORIGIN_POLICY", false)
.setOption("mvn-micro-repo.groupId", "dfki.sds.delight" )
.setOption("mvn-micro-repo.artifactId", "example" )
.setOption("mvn-micro-repo.version", "0.1-alpha-fluent-SNAPSHOT")
.setOption("mvn-micro-repo.delightVersion" , "4.0-SNAPSHOT")
.setOption("stats.logInterval", 10)
.usePresentFeatures(true)
.build();
DelightServer server = new DelightServer(cfg)
.port( 8080 )
.path( "/example-delight-webapp/delight" )
.asyncTimeout(5, TimeUnit.MINUTES)
.init( backend -> {
backend.addHandlerByClass("myHandler", ExampleHandler.class);
backend.addHandlerByClass("abstract", HandlerForAbstractInterface.class);
backend.addHandlerByClass("sse", SseHandler.class);
backend.addHandlerByClass(ServiceWithPredfinedHandlerName.class);
});
server.start();
server.waitForShutdown();
}
}
```
This server does a bunch of things:
* Load the default configuration from the classpath
* Fetch Delight features from the classpath and add them to the server
* Modify the config as needed
* Allow Cross Site Scripting Access
* Set options for various features (here `mvn-micro-repo` and `stats`)
* Create the server
* Set port and path
* Adjust async timeout (used when the Server-Sent Events feature is active)
* Add handler classes
* Start the server
Clone repository
  • DocuFeature
  • ExampleServer
  • ExampleWebApp
  • Home
  • ServerSentEventsFeature
  • StatsFeature
  • people
  • xmlrpc
    • Documentation
    • ExampleUsingConverterRegistry
    • ExampleUsingOwnConceteTypes
    • ExampleUsingOwnInterfaceTypes
    • ExampleUsingThirdPartyTypes
    • ExampleUsingXmlRpcBeans
    • ExampleUsingXmlRpcCompliantTypes

Legal Notice, Imprint, Privacy Policy