Design Suggestion for integrating Ember App inside java web app 2020

I am working a project which uses java string buffers to contain html code. I am planning on shifting the code to ember and to make it run on port 8080. Any idea how to integrate ember in java. I do not want to use ember islands for this.

I’m not very familiar with Java servers but assuming this means you want a server-rendered app I think you must use ember-islands or at least something like it (I’m not aware of anything else for SSR other than stuff like fastboot, empress and prember).

Exactly how you integrate Ember into a Java application depends on the Java framework you are using. I have a procedure scripted for Play Framework that has been working well. These general steps should also work for other frameworks. This integrates Ember into your Java application build so that Ember is launched directly from the Java application; It does not provide any server-side rendering.

  1. Run ember build with output-path set to a subdirectory of the static assets directory for your framework. For Play, this could be public/ember.

  2. Replace the main view template in your Java application with the index.html created by Ember. For Play, this would mean copying public/ember/index.html to app/views/index.scala.html.

  3. Do a series of search-and-replaces to convert the Ember-generated HTML to the type of template in use. For Play, this is a Twirl template. An example would be this, which converts the Ember generated asset URLs to use the Play asset finder.

sed --in-place 's~/assets\([^"]*\)~@assetsFinder.path("ember/assets\1")~' app/views/index.scala.html

  1. Give all the routes served by the Java application a special path prefix (e.g., /api) that is not used by the Ember application.

  2. Set up a default route so that all other routes launch the Ember application. In Play this default route looks like this.

GET /*path controllers.ApplicationController.index(path:String)

You do need to be careful about your image URLs in Ember so that they match what they will be when deployed in the server application. Then you just build your application as normal and the Ember app will be loaded for any route not served by the Java application.