Skip to content

Toro Cloud Dev Center


Quick start tutorial: Writing a service

Estimated time to complete: 4-5 minutes

With your Martini package ready, you can start creating services for your application. Applications are typically a chain of services invoked upon certain conditions, and services are where you specify executable logic.

This page will describe how to write a hello service. This service will accept a name, then return, and print Hello, ${name} to the console when invoked. To do this, follow the instructions (grouped by topic) below in order.

Create a new service

Create a new Gloop service using these steps:

Creating a service in Martini Desktop

Creating a service in Martini Online

  1. Expand the package you've just created.
  2. Right click on your package's code directory, and then select New > Service.
  3. Provide a name for your service.
  4. Click Finish.
Quickly open views, menus, preferences, and others

If you want to open a view that is not currently displayed on screen, you can use the Quick Access bar in Martini Desktop to swiftly search and open your desired view. You can use this feature to re-open interfaces closed accidentally.

Using the Quick Access bar to open interfaces

Add a name input property

The Greet service will be accepting an input called name. To add an input property called name to your service, follow these steps:

Adding a `name` input property

Adding a `name` input property

  1. If the Greet service isn't open, double-click on it in the Navigator.
  2. At the bottom of the window, select the Input/Output tab.
  3. This tab's content is split into two sections: Input and Output. In the Input half, (which is on the left-hand side) click the green, '+'-labeled button on the toolbar, and then select Add String.
  4. A new string property will be added in the Input half of the tab. Set this property's name to name while in edit mode, and then press . If the property name isn't editable, click on it then press either or to make the name editable.
I messed up Martini's layout. How do I reset it?

Missing views and menus, jumbled layout - has this ever happened to you? Fortunately, Martini Desktop makes it easy to go back to the default perspective. At the top right hand side of Martini Desktop's window:

  1. Right click on the active perspective icon.
  2. From the appearing context menu, select Reset.
  3. A dialog will appear to confirm your action; select Reset.

Resetting Martini's current perspective

Declaring a new input or output the ninja way

If you prefer to use a keyboard instead of a mouse or touchpad whilst developing, you can also declare properties using content-assist. You can learn more about content-assist here.

Add a greeting output property

The service will also be producing an output called greeting. This is the Hello, ${name} string the Greet service will be returning when invoked. To specify service outputs, output properties must be added. To add an output property named greeting to your service, follow these steps:

Adding a `greeting` output property

Adding a `greeting` output property

  1. If the Greet service isn't open, double click on it in the Navigator.
  2. At the bottom of the window, select the Input/Output tab.
  3. This tab's content is split into two sections: Input and Output. In the Output half, (which is on the right-hand side) click the green, '+'-labeled button on the toolbar, and then select Add String.
  4. A new String property will be added in the Output half of the tab. Set this property's name to greeting while in edit mode, and then press . If the property name isn't editable, click on it then press either or to make the name editable.

Set greeting's value

The greeting property value will now be set to Hello, ${name}, where name will be substituted by the value of the name input property at runtime.

To set the greeting property's value:

Setting `greeting`'s value using a set expression

Setting `greeting`'s value using a set expression

  1. If the Greet service isn't open, double click on it in the Navigator.
  2. Click the step editor to shift focus to it.
  3. Click the green, '+'-labeled button on the toolbar, and then select Add Map.
  4. Double click the newly added map step to open the Mapper view.
  5. Double click the greeting property in the Mapper view. The Set Expression dialog will appear.
  6. Enable script evaluation by selecting Groovy from the Language dropdown.
  7. In the dialog's editor, provide the following expression:

    1
    "Hello, ${name}"
    
  8. Click OK.

Log greeting to the console

To log greeting to the console, you need to add an invoke step that calls LoggerMethods.println(String). To do this:

Logging `greeting` to the console

Logging `greeting` to the console

  1. If the Greet service isn't open, double click on it in the Navigator.
  2. Click the step editor to shift focus to it.
  3. Press the key to trigger content-assist.
  4. Search for LoggerMethods.println(String).
  5. Use the and keys to select the method, then press to add it to the service (or double-click on it).
  6. While the newly added invoke step is selected, open the Mapper view.
  7. In the Mapper view, create a map line from greeting to message.

Test your service by running it

After saving your changes, you can run your Gloop service in order to test if it works as expected. To do this, open the service in the editor and then click the run button on the toolbar.

When you run the service, you will be asked to provide a value for the name input property. Upon finalizing your inputs, the Console view will also open, and the service will execute.

Running the 'hello' service

Running the 'hello' service

After running, you will see the Hello, ${name} message printed on the Console view. If you entered Bob as the name, then you will see a Hello, Bob message.

When the service terminates, you'll see these messages at the end of the Console view:

1
2
<Gloop Service Completed>
<Click here to see output>

Click the <Click here to see output> link to see the greeting output returned by your service, which should be Hello, ${name}.