This sample shows the usage of the Dolphin Platform HTTP client.
The Dolphin Platform contains a HTTP client that can easily used to call endpoints on any server. The HTTP client has some big benefits againts other HTTP clients:
- It provides an easy to use fluent API
- The same API is used for all client toolkits and programming languages
- The API takes care about the UI thread and provides functionallity to do HTTP calls without blocking the UI thread
- The HTTP clients supports raw, String and JSON data by default
- The HTTP client automatically generates object instances based on JSON data
The given sample provides a JavaEE and a Spring server that both provide the same REST endpoints and some clients that makes use of the Dolphin Platform HTTP client to access those endpoints.
The sample is seperated in several modules. The following image shows the dependecies of the modules:
For all Java modules the model of the application is defined in the common
module. By doing so the module definition
can easily be shared between client and server modules.
The sample provide a JavaEE and a Spring based server. Only one of the servers can be started since both use the
same port. The server provides the application at http://localhost:8080/simple-rest
.
Once a server is running multiple instances of the clients can be started. All clients do HTTP calls to a server at
http://localhost:8080/simple-rest
.
All modules provide a Maven target to start the application.
To start the JavaEE server simply run mvn wildfly:run
from the server-javaee
folder. Next to this the server can
be deployed to any JavaEE 6 application server. To do so run mvn verify
from the server-javaee
folder. The created
process-monitor.war
in the target
folder can be deployed as JavaEE web application. The application must be reachable
under http://localhost:8080/simple-rest
.
To start the Spring Boot server simply run mvn spring-boot:run
from the server-spring
folder. Next to this the
server can be started by the com.canoo.dolphin.samples.rest.ServerApplication
class.
To start the Java client simply run mvn jfx:run
from the client-java
folder. Next to this the client can be
started by the com.canoo.dolphin.samples.rest.RestClient
class.
To start the JavaFX client simply run mvn jfx:run
from the client-javafx
folder. Next to this the client can be
started by the com.canoo.dolphin.samples.rest.RestClient
class.
The project is released as open source under the Apache License Version 2.0
About Canoo