Continuing on the GUI thread, it’s a good time to provide more information regarding the single page application tying together all the user-facing functionality, briefly touched upon in the previous article “Implementing efficient monitoring of long running operations with OSGi R7 Push Stream and Server Sent Events”. As a reminder, all of the code is available in public repository; you can clone, configure and deploy the application yourself–all steps are documented.

1. On the back-end, you will find implementations of OSGi R7 specs such as HTTP Whiteboard1, JAX-RS Whiteboard2, and Converter3 utilized. On the front-end, you will find the single page application built with HTML5, CSS3, JavaScript and SVG.

2. Specifically, in the rest-common module, the class registers static resources to be served with the HTTP Whiteboard using the org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardResource annotation, i.e.:

@HttpWhiteboardResource(pattern = "/spa/*", prefix = "static")

3. The above will result in picking up all of the files which comprise our single page application (i.e. HTML, CSS, JavaScript, font and icon files), source residing in src/main/resources/static folder in the rest-common module, and serving them via http://IP:PORT/spa/index.html in a running application.

4. In the same rest-common module, you will also find<T> class which provides conversion to and from JSON for our REST controllers, registering itself as a JAX-RS Whiteboard Extension using the org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsExtension and declaring support for application/json media type using the org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsMediaType annotation, i.e.:

@Component(scope = PROTOTYPE)
public class JsonConverter<T> implements MessageBodyReader<T>, MessageBodyWriter<T> {

5. Now, we move on to the REST controllers, of which there are two in this particular application. In the rest-voiceanalysis module you will find class, which is responsible for submitting audio file for analysis and retrieving transcript and analysis when ready. It registers itself as a service with the JAX-RS Whiteboard using the org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource annotation, declaring its JSON support requirement using the org.osgi.service.jaxrs.whiteboard.propertytypes.JSONRequired annotation, i.e.:

public class VoiceAnalysisRestController {

6. The other of the two REST controllers you will find in the rest-status module, i.e. class; we discussed its responsibilities in more detail in the previous article “Implementing efficient monitoring of long running operations with OSGi R7 Push Stream and Server Sent Events”–it provides processing status updates utilizing OSGi R7 Push Stream and Server Sent Events. This one uses JAX-RS Whiteboard as well, registering itself as a service via the same annotations as mentioned for

  1. “OSGi Enterprise R7 HTTP Whiteboard Specification“ 

  2. “OSGi Enterprise R7 JAX-RS Whiteboard Specification“ 

  3. “OSGi Compendium R7 Converter Specification“