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 https://github.com/ideas-into-software/automated-linguistic-analysis; 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 https://github.com/ideas-into-software/automated-linguistic-analysis/tree/master/rest-common, the software.into.ala.rest.common.SinglePageApp 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 software.into.ala.rest.common.JsonConverter<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)
@JaxrsExtension
@JaxrsMediaType(APPLICATION_JSON)
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 https://github.com/ideas-into-software/automated-linguistic-analysis/tree/master/rest-voiceanalysis you will find software.into.ala.rest.voiceanalysis.VoiceAnalysisRestController 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.:

(…) 
@JaxrsResource
@Produces(MediaType.APPLICATION_JSON)
@JSONRequired
public class VoiceAnalysisRestController {
 (…) 
}

6. The other of the two REST controllers you will find in the rest-status module https://github.com/ideas-into-software/automated-linguistic-analysis/tree/master/rest-status, i.e. software.into.ala.rest.status.StatusUpdatesRestController 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 software.into.ala.rest.voiceanalysis.VoiceAnalysisRestController



  1. “OSGi Enterprise R7 HTTP Whiteboard Specification“ https://osgi.org/specification/osgi.enterprise/7.0.0/service.http.whiteboard.html 

  2. “OSGi Enterprise R7 JAX-RS Whiteboard Specification“ https://osgi.org/specification/osgi.enterprise/7.0.0/service.jaxrs.html 

  3. “OSGi Compendium R7 Converter Specification“ https://osgi.org/specification/osgi.cmpn/7.0.0/util.converter.html