简体   繁体   中英

How to reuse existing data models when using rest.li


We have a few existing data model classes but don't have a REST interface to these. If we wish to use linkedin's rest.li framework, is it possible to reuse existing models without regenerating new model Java classes that extend RecordTemplate? Otherwise for every model we have along with nested associations, we might end up having one rest.li specific model class. It will also help if there is a link to pegasus plugin or the kind of customizations possible with this plugin, but I couldn't find one nor figure out after many attempts at project skeleton generation to try to customize this. Any pointers will be of great help.

Thanks,
Padmanabhan

Rest.li is tightly coupled with its data layer. There is no trivial way to use an arbitrary data model with Rest.li. However, it is possible to come up with some conversion logic between Rest.li data and your existing data model. Whether or not this conversion logic is lossy, complicated or not depends on the nature of your data model.

For example, the fundamental structures in Rest.li data is DataMap and DataList , which represents JSON object and array. All DataMap keys must be string, and string is the only allowed data type in JSON object. If your existing data model is compatible with JSON, and you have some form of schema, this conversion could be lossless. Otherwise, it could be nontrivial to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM