|
|
# 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 |