AnsweredAssumed Answered

REST revisited (JAX-RS and JAXB)

Question asked by tstephen on May 3, 2013
Latest reply on May 22, 2013 by jbarrez
I realise that last year the feeling was that there were more important things to work on that a revised REST implementation but I wondered if now might be a good time to revisit that?

First a bit about motivations. I think there would be benefits in terms of more seamlessly and automatically generating a RESTful API from the existing Activiti API (RepositoryService, RuntimeService etc.) as well as other advantages in terms of generating documentation

Another motivation, or perhaps just a different way of saying the same one, is to make Activiti 'natively' RESTful. In other words, presentation as XML / JSON for machine consumption or HTML for human consumption is orthogonal to the resource being requested. Thus concerns are separated and transport is transparent. In practical terms it would be possible to have a single webapp instead of activiti-webapp-explorer2 and activiti-webapp-rest2

This would require that the *Service classes are annotated and the various model beans (Deployment, ProcessDefinition, ProcessInstance etc.) are serialisable as JSON and / or XML (more annotations). I recognise that the model beans contain quite a lot of behaviour that may make simply annotating them quite painful in practice but let's leave that aside for now.

I think the basic set of resources looks like this (new methods are marked with a *):

Method    Path                                           POJO                      Method
PUT         /repository/{resourceName}       RepositoryService  * deploy(String resourceName, String text)
GET         /repository/deployment/{id}        RepositoryService  getDeploymentResourceNames
DELETE   /repository/deployment/{id}        RepositoryService  deleteDeployment

Well you get the idea… The basic set is available in my github fork: https://github.com/tstephen/Activiti

You'll notice this is not the full set of public methods on the service classes. In some (few, I think) cases there are methods that don't lend themselves well to REST patterns but for the most part I just chose a minimal subset to get started with and to see what other people think about the idea.

The new behaviour does not work yet but you can explore the source code impact. All previous behaviour should be completely unchanged but I have done no regression testing at this point.

I look forward to your ideas.
Tim

Outcomes