Time for action – integrating Activiti with Apache Karaf

Apache Karaf is a small OSGi bundle with a lightweight container and is capable of deploying various applications and components. To deploy Activiti as an OSGi, we have to carry out the following steps:

  1. To start the integration of Activiti with Karaf, there are some prerequisite installations to be done on our system. JDK should be installed with Version 1.5 or higher and Maven 3.0.3 should be configured in your system.
  2. We need to download Activiti Karaf from http://code.google.com/p/activiti-karaf/downloads/list. This link contains files for both Linux and Windows operating systems, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  3. You can download the files corresponding to the operating system you are using. As we are working with a Linux system, we will download the Linux distribution file.
    Time for action – integrating Activiti with Apache Karaf
  4. Now, we will extract the file from a specific path. To use Activiti with Karaf, we need to do some configuration. You can browse to the ../activity-karaf-dist-1.0.0-SNAPSHOT/sources/activity-bpmn-archtype folder; there will be only an src folder and a pom.xml file, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  5. As this archetype is currently not available in the public Maven repository, we need to install it in the public repository by executing the mvn install command from the command prompt, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  6. The mvn install command will start installing the activiti-bpmn-archetype in the local repository. The installation process will take some time. Once the installation is completed, you should get a BUILD SUCCESS message as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  7. After the successful installation of activiti-bpmn-archetype, we can create a bpmn project using activiti-bpmn-archtype.
  8. To create the project, browse to the sources folder of your activiti-karaf-dist-1.0.0-SNAPSHOT path and type the following command:
    mvn archetype:generate -B -DarchetypeGroupId=org.activiti.karaf.archetypes -DarchetypeArtifactId=activiti-bpmn-archetype -DarchetypeVersion=1.0.0-SNAPSHOT -DgroupId=com.book.activiti.OSGi -DartifactId=activiti-OSGi -Dversion=1.0.0-SNAPSHOT
  9. On the successful execution of the preceding command, you will get a BUILD SUCCESSFULL message on the console, as shown in the following screenshot, and a project will be created in your sources folder:
    Time for action – integrating Activiti with Apache Karaf
  10. Our project activiti-OSGi will be created in the sources folder of activiti-karaf-dist-1.0.0-SNAPSHOT. You can browse to ../activiti-karaf-dist-1.0.0-SNAPSHOT/sources and you should have folders mentioned in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  11. Now, we need to modify the pom.xml file of our activiti-OSGi project. The pom.xml file is located at the ../activiti-karaf-dist-1.0.0-SNAPSHOT/sources/activiti-OSGi path.
  12. We need to make changes in the <parent></parent> element of the pom.xml file with the given code snippet:
    <parent>
    
        <groupId>org.activiti.karaf</groupId>
    
        <artifactId>activiti-karaf-parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    
        <relativePath>../activiti-karaf-parent</relativePath>
    
      </parent>
  13. By providing the previous groupId and artifactId, our project becomes an OSGi Activiti project and we can run it on the OSGi container.
  14. In your ../activiti-karaf-dist-1.0.0-SNAPSHOT/sources/activiti-OSGi/src/main/process path, you will find a bpmn file named activiti-OSGi.bpmn20.xml, which is created in the project by default.
  15. Now in order to execute our project, we need to create a package structure. To create a package structure, we have to type the mvn clean package command in our project folder path as mentioned in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  16. On the successful execution of the previous command, a target folder is created within ../activiti-karaf-dist-1.0.0-SNAPSHOT/sources/activiti-OSGi, which contains the activiti-OSGi-1.0.0-SNAPSHOT.jar file and various classes, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  17. Now, we will deploy our activiti-OSGi project on Activiti Karaf. To start activiti-karaf, we have to execute the ./karaf command from the command prompt by browsing to the ../activiti-karaf-dist-1.0.0-SNAPSHOT/bin path as viewed in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  18. On starting Activiti Karaf, we have started the Activiti OSGi engine.
  19. Now, open a web browser and type http://localhost:8181/activiti-explorer. This URL will open the Activiti engine and you will get the login page, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  20. You can log in with the user ID kermit and password kermit. Then, browse to the Manage | Deployments | Upload new link and upload the activiti-OSGi.bpmn20.xml file, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  21. When the file is uploaded successfully, it will be available in Manage | Deployments, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  22. To view the process diagram, you can browse to Process | Processs definitions | activiti-OSGi where you will see the graphical representation of your business process, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  23. As we have deployed the process on the Activiti engine, we will now go back to the command prompt and check the list of processes deployed by executing the act:list command on the command prompt; we should be able to view our activiti-OSGi process in the list, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf
  24. We can also start the process from the OSGi command prompt by executing the act:start [process definition id] command, as shown in the following screenshot:
    Time for action – integrating Activiti with Apache Karaf

What just happened?

In this section, we used an OSGi container called Apache Karaf to implement our Activiti business process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset