Chapter 36. HowTo - Extend OpenEngSB Console

36.1. Goal

This tutorial shows how to extend the OpenEngSB console.

36.2. Time to Complete

To read this tutorial and get add a first command should not take more than 10 minutes

36.3. Prerequisites

This HowTo assumes you already have downloaded the OpenEngSB.

36.4. Start the console

It is not much needed to get the OpenEngSB console started. Just type in a shell "mvn openengsb:provision" or execute the corresponding shell script (etc/scripts/run.sh)

36.5. Adding new commands

This section describes how to add new commands. The project is located in core/console. To add a new command not much is needed. For a finished example have a look at the class org.openengsb.core.console.OpenEngSBInfo. Here a short description:

        import org.apache.felix.gogo.commands.Command;
        import org.apache.karaf.shell.console.OsgiCommandSupport;

        @Command(scope = "openengsb", name = "info", description = "Prints out some information")
        public class OpenEngSBInfo extends OsgiCommandSupport {

            @Override
            protected Object doExecute() throws Exception {
                System.out.println("Here is the information");
                return null;
            }
        }
      

There is just one single other step which has to be done: Go into the core/console/src/main/resources/OSGI-INF/bluepring/shell-config.xml and add the following lines:

        
        <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
          <command name="openengsb/info">
            <action class="org.openengsb.core.console.OpenEngSBInfo"/>
OpenEngSBInfo
        </command-bundle>
      
      

This will lead to following command "openengsb:info". To execute this command, start the OpenengSB console in a shell as described above and type in openengsb:info, this will print out the text "Here is the information"