in Activiti

How to extend Activiti REST

Activiti includes a REST API to the activiti engine that can be installed deploying activiti-rest.war application to your server ( for instance Tomcat ), activiti-rest can also be a part of your own application and in that way exposing REST services to the world.

We will focus on stand alone application deployment for now, and see how to extend the application and add new services that can be called.

Creating the project

Open eclipse and create new maven project

Create new maven project

Create new maven project

After clicking Next dialog for typing Group Id and  Artifact Id will appear, entering your domain name and project name like demonstrated in the next picture.

Entering Group Id and Artifact Id

Entering Group Id and Artifact Id

Clicking Finish will create the project.

Sorting out maven dependencies and plugins

In the created project we have pom.xml file located in the root of the project, lets open it . In the next listing we have what is to be put in this file.


<project xmlns="" xmlns:xsi=""






We have two dependences junit and activiti-rest that we will require for writing tests and extending activiti-rest it self. Current activiti-rest version is 5.15.1 that was lastest at the time of writing this post.

Creating new REST service

Activiti has plenty of REST services already created and ready for use, they all extend class SecuredResource that allow developer to :

  • Retrieve attribute using
    public String getAttribute(String name)
  • Retrieve query parameter as specified Type
  • Check for authentication
    protected boolean authenticate()

    Most of REST services are allowed only to authenticated users, this this method should be called before anything else is done in our service.

Many more things is allowed for this you should check source of the class.

Our new REST service will be simple Hello World service that returns “Hello World” when called.


import org.restlet.resource.Get;

public class TestResource extends SecuredResource {
 public String test(){
   if (!authenticate()) {
     return null;
 return "Hello World";

We have created a class called TestResource that extends SecuredResource previously explained . Adding a method with annotation @Get means that this method will be called after HTTP GET request to specified address .

HTTP request that can be used are:

  • GET
  • POST
  • PUT

Now lets put this resource to certain path.

Putting resource to specified path

Activiti-rest has one class that is called ActivitiRestServicesApplication, that holds things together and sets up. We can find code of this class here. We need to extend it and attach our Resource to the Router.

package com.alfrescoblog.activitirestedit;

import org.restlet.Restlet;
import org.restlet.routing.Router;


public class AlfrescoBlogApplication extends ActivitiRestServicesApplication{
 public synchronized Restlet createInboundRoot() {
 ChallengeAuthenticator restlet = (ChallengeAuthenticator) super.createInboundRoot();
 Router router = (Router) ((JsonpFilter)restlet.getNext()).getNext();
 router.attach("/alfrescoblog/test", TestResource.class);
 return restlet;

Class AlfrescoBlogApplication extends ActivitiRestServicesApplication, gets defatuls Router and attaches the TestResource on path /alfrescoblog/test .

Overriding ActivitiRestServicesApplication

We need to explain activiti-rest that our Application Class is star in this game. Lets observe web.xml of activiti-rest web application

  <display-name>Activiti REST</display-name>
 <!-- Restlet adapter --> 
 <!-- Application class name -->

It is easy to see that instead of ActivitiRestServicesApplication we must put our Application class currently called AlfrescoBlogApplication.

 <!-- Application class name -->

Deploy REST service

Using maven command

mvn package

will result in building this project into jar file that we specified into our pom.xml file previously. Adding this jar to activiti-rest.war and modifying web.xml file as we explained will result in adding our REST service to desired path.

This REST service is located in localhost:8080/activiti-rest/service/



We have learned so far on

  • How to create maven project
  • How to add Resource
  • How to put Resource on desired path
  • How to override activitiApplication class

This concludes this article more will come in the future on how to use activiti services…

Don't be shellfish...Tweet about this on TwitterShare on LinkedInShare on Google+Share on RedditShare on Facebook

Leave a Reply to himani Cancel reply

  1. Hi, This was a great blog. Please can you provide similar steps for activiti 5.17 which uses spring mvc as the rest framework

    • Hello Himani,
      thank you!

      Extending Activiti-rest by adding more controllers is simple as 1 2 3.

      1: you need to create java project :)
      2: just add one class like this one to this package or add some spring config …


      public class MyNewRestApi {

      private static Logger logger = Logger.getLogger(MyNewRestApi.class);

      private ManagementService managementService;

      @RequestMapping(value = "/mynewuri/getmehere", method = RequestMethod.GET)
      public String isUserActive( principal) {
      return "Hello world";

      3: Share the :)