In this example you can explore how to integrate React in DataKernel projects. You can find full example sources on GitHub.
Here we will consider using HttpServerLauncher and AsyncServlet to set up the server that processes the requests. See how DataKernel makes this process extremely simple.
SimpleApplicationLauncher extends DataKernel HttpServerLauncher. HttpServerLauncher superclass takes care of setting up all the required configurations for the HTTP server:
First, we provide an executor for the AsyncServlet. Then, we provide an AsyncServlet to open the index.html of the provided path. Finally, we write down main() method to launch our app. Simple and efficient, isn’t it?
Provide AsyncServlet, which will open the index.html of the provided path.
Then write down main method, which will launch SimpleApplicationLauncher. And that’s it, no additional configurations are required.
If you want to run the example, clone DataKernel and import it as a Maven project. Check out branch v3.1. Before running the example, build the project (Ctrl + F9 for IntelliJ IDEA).
Then, run the following command in datakernel -> examples -> tutorials -> react-integration -> front
SimpleApplicationLauncher class and run its main() method.
Then open your favourite browser and go to localhost:8080.