REST Services for my Model Framework

Fri Jun 06 09:55:01 EDT 2014

Tags: framework

Recently, I've been refactoring out my framework code from XPages Scaffolding into an OSGi plugin. Part of this is just to help with code reuse and versioning: having a whole bunch of framework classes in each NSF is a drag, both from a perspective of having a bunch of extra stuff in the NSF and for having to worry about keeping them up to date (a template would work, but eh...). But another part is that it lets me work on some new features I've been itching to try.

One of those is adding REST services for model objects. Having access to your data via REST+JSON is pretty important, whether you're using Angular.JS, iOS, or miscellaneous. The Data service in the ExtLib does a great job of exposing document and view data directly, but it runs into the same problem that the standard data sources in XPages do: it doesn't have any provisions for your specific domain models. On the XPage side, I've solved this for myself by making a model framework that has done a fine job so far of covering my needs for accessing and collecting data in a pretty friendly way, and now I'm working on building REST APIs "for free".

Using the DAS as an inspiration (both in a vague sense and in a "using the code" sense), I'm working on Wink services to provide access to the model objects defined in each DB in a way that uses all of the same getters/setters with almost no changes to the code. The only change required (at least so far) is an optional annotation to define which fields should be included when accessing the object via REST. I'm aiming to match the data formats used by DAS as much as makes sense, since they're well-thought-out for representing Domino-friendly data, though the URLs will be pretty different due to the nature of my model manager objects.

This has been going well so far, and I'm looking forward to having it fully fleshed out. It should allow me to continue defining my model objects the same way I have been for use in XPages/Java, but then also be able to access the data just as well from other front-end technologies - potentially having NSFs that contain just a set of model definitions to act as a headless API app for use with other clients. And hey, if I get around to adding non-Domino backends to the model framework, the NSF would turn into a platform-agnostic gateway for data access.

Commenter Photo

Mark Barton - Fri Jun 06 12:44:17 EDT 2014

Jesse sounds like just what I need / want.

Right now rolling my own XAgents to act as REST services is a little tiresome to say the least.

Do you think it will work with Swagger - https://helloreverb.com/developers/swagger ?

If i can help then please shout - my Java coding is no where nears yours but I can always do documentation / testing.

Mark

 

Commenter Photo

Jesse Gallagher - Fri Jun 06 13:09:27 EDT 2014

Hmm, it potentially could be. I'll take a look and see if it's something worth working in. Right now, I'm sort of just muddling forward with the formats, being roughly similar to DAS, but I wouldn't mind having some real sanity to them.

New Comment