To add real time capability with Java, what you can do is through Comet (CometD Framework) or Jetty Continuations, however, these technologies had outdated, made worse performance. And currently most web server framework is based on thread-based, and thread-based does not scale when introducing in real time.
This post introduced us to build another separate server running Node.JS WebSockets, and using Redis to bridge Java and Node.JS based on publish/subscribe model, to plug in real time capability to Java. Java can push the data to Redis, when Node.JS subscribed to Redis, whenever got new data, it broadcasts the data to the WebSockets clients.
Links: