- Java EE 8 High Performance
- Romain Manni Bucau
- 303字
- 2021-06-30 19:14:28
Marshalling
(Un)Marshalling is what will (read/)write a Java object to a communication format. It is commonly the part converting an object to a XML or JSON payload but can really be any format, including binary formats.
This conversion is normally synchronous in the implementation and can be costly depending on the model you use and the serializer that is activated. Compared with the servlet API, where you yourself serialize the payload you want to read/return, here, the task is done by the framework and is, therefore, a bit hidden.
A crucial point at this stage is to make sure that the manipulated object has almost no logic and is fast to initialize/read. If you don't respect this point, you may end up holding the HTTP stream for too long which would badly impact your scalability and on a more general practice, you would risk to have some lazy loading of data with JPA which can fail or imply an unexpected connection usage depending the JPA provider and configuration. Another bad case would be to start writing and, then, compute some costly value before continuing to write and therefore force the marshalling process to pause and delay the write after having started it. This not only has a direct impact on the request thread pool but also on the HTTP I/O.
In the same spirit as the algorithm used to match a method to invoke (see the previous part), the JAX-RS runtime must resolve the provider to use (MessageBodyReader or MessageBodyWriter depending on whether you read or write) in order to make the link with the Java model. Here again, this resolution depends on the incoming request (or the response being built) and media type headers and is not as flat as expected even if it is cacheable and generally fast.
- Linux系統(tǒng)文件安全實(shí)戰(zhàn)全攻略
- 每天5分鐘玩轉(zhuǎn)Kubernetes
- Designing Purpose:Built Drones for Ardupilot Pixhawk 2.1
- 從零開始寫Linux內(nèi)核:一書學(xué)透核心原理與實(shí)現(xiàn)
- FreeRTOS實(shí)時(shí)內(nèi)核應(yīng)用指南
- Windows Phone 7.5 Data Cookbook
- 嵌入式應(yīng)用程序設(shè)計(jì)綜合教程(微課版)
- Python基礎(chǔ)教程(第3版)
- Application Development in iOS 7
- 跟老男孩學(xué)Linux運(yùn)維:Shell編程實(shí)戰(zhàn)
- INSTANT Galleria Howto
- Hadoop Real-World Solutions Cookbook
- OpenHarmony開發(fā)與實(shí)踐:基于紅莓RK2206開發(fā)板
- Linux系統(tǒng)安全:縱深防御、安全掃描與入侵檢測
- 計(jì)算機(jī)操作系統(tǒng)(第3版)(微課版)