The root of DOR applications

Marco Domenico Marino
Quick Code
Published in
3 min readNov 15, 2019

The role of the root REST service for the DOR applications

Photo by Teo Zac on Unsplash

Intro

In the phase of design of the framework for the architecture of the DOR applications an important role was covered by the root REST service.

The root REST service (abbreviate RRS) needs to be the only entry point of the DOR applications, in fact it serves all the requests sent by the web clients.

Now I’ll try to design (virtually) and explain to you the roles and the main actions managed by the RRS.

Let’s go!

The root REST service

The idea of the the RRS was moved by the need to have a unique entry point to serve all requests.

The RRS will manage the requests of HTML/CSS templating and the requests that will send data to an application. In details:

  • GET Template: the JavaScript framework that runs on the browser when has needed to display a page (or a part of this) for the first time or after an internal routing invokes the RRS to retrieve the information to present the page. Now this step is thought as a REST service invoked in GET mode and the JS framework provides to the server only the tag of the web component that intends to visualize extracted by inspection of the DOM.
  • POST data and events: web client, after present a page, remain in waiting to receive an input from the user. The information that can be managed by the browser are data, events or both. A click on a button or the action of putting a value into a text field will should be caught by the JavaScript framework and sent to the application invoking the RRS in POST mode.

In both cases, GET and POST mode, the response will need to be a well-formed HTML so that the JavaScript framework has only the role to replace the portion of the page that was being requested before. The responses of the RRS, probably, will be in JSON format.

The flow

The flow starts with the request of the first page by the browser; with the first request the browser receives the index page of the DOR application and the JavaScript framework.

The JavaScript framework will invoke the first time when the page load is completed; the role of the JavaScript will be to inspect the DOM received and, for every custom HTML element received, to invoke the GET method of the RRS to retrieve the HTML and the style CSS to present the Web Component.

The RRS will receive the request and collaborate with the Java framework to to get the Bean that represents the Web Component and will return in response to the information requested.

In the following picture there is a simplified representation of the layer stack:

A draft of the DOR architecture

At present the repository that I have realized contains the Java application, the Java framework and the JavaScript framework in a single Java project: the next step will be to separate the application and the framework in two different projects and start to use the framework as a Maven dependency.

Conclusion

In this story I have tried to imagine the role and the architecture of the Root REST service that will become the first layer (more external) of the DOR applications.

Surely I have caught many points to deep on:

  • The format and the structure of the GET/POST responses
  • The architecture of Javascript framework for manage the responses of the RRS
  • The way to inspect the DOM
  • The way to catch the user events

Thank you for your time!

Medium.com: an introduction to DOR applications

GitHub: an example of DOR application (repository)

--

--

Marco Domenico Marino
Quick Code

Software engineer and Architect @Accenture. Java is to JavaScript as Car is to Carpet…