官术网_书友最值得收藏!

  • Learning Alfresco Web Scripts
  • Ramesh Chauhan
  • 413字
  • 2021-08-05 17:28:05

Behind the scenes of web script execution

Let's try to understand at a high level what happens on a web script being hit in different scenarios such as when a web script does not have a controller and when it does.

A web script without a controller

To execute the first web script we created without controller, we just hit the URL http://localhost:8080/alfresco/service/helloworld?name=Ramesh on a web browser, which is basically a HTTP GET request call.

All the incoming requests matching the URL pattern /alfresco/service/* are mapped to the web script request dispatcher servlet in the Alfresco web application configuration.

The servlet then passed the request to the Web Script Runtime to process the web script.

The Web Script Runtime passed the control to the Web Script Container. The Web Script Container internally identified which web script to execute based on the invoked web script URL, HTTP method, and the web script descriptor document helloworld.get.desc.xml.

We have not specified any response format explicitly in the descriptor document and have not explicitly mentioned one while executing the web script. Hence, the web script framework has rendered the HTML as the default format. Based on the naming conventions of a FreeMarker template, we recollect that we have created the FreeMarker template as helloworld.get.html.ftl. This generated the HTML response for the web script. The formatted response is then sent back to the web browser to display the HTML text in the web script response along with the value of the argument name.

A web script with a controller

You must have observed that in the first web script, we created the web script without the controller and then extended the web script to have the controller. The URL to invoke this web script remains the same. There isn't any difference in the URL. It was only a backend implementation that was additionally implemented to have a controller added in the web script implementation.

Behind the scenes when a web script with a controller is invoked, the web script framework in Alfresco will follow the same process as mentioned for a web script with no controller. The only difference would be before rendering the response, the web script framework in Alfresco would execute the controller implementation first. The controller will first complete the required business logic processing interacting with the Alfresco repository and generating the required data to be returned as a web script response. The controller will populate the model object to pass to the FreeMarker template.

主站蜘蛛池模板: 达拉特旗| 平凉市| 浮山县| 涞水县| 五峰| 竹山县| 兴海县| 鄱阳县| 东乡族自治县| 前郭尔| 漠河县| 深水埗区| 华蓥市| 嘉善县| 那坡县| 布尔津县| 桦川县| 黎川县| 特克斯县| 崇仁县| 公安县| 崇州市| 荔波县| 修文县| 锦屏县| 清镇市| 江川县| 韶山市| 汨罗市| 慈利县| 沾化县| 竹山县| 安平县| 赤水市| 方城县| 新竹县| 重庆市| 侯马市| 铜鼓县| 盐亭县| 密云县|