Contact Us 1-800-596-4880

Creating an Anypoint Connector Project

DevKit is compatible only with Studio 6 and Mule 3. To build Mule 4 connectors, see the Mule SDK documentation.

Prerequisites

The DevKit documentation assumes you have:

  1. A working knowledge of Mule, Anypoint Studio and Java development in general.

  2. Explored the existing connectors.

  3. Access to a sandbox environment for the target system or source, and documentation of the Web service it exposes.

  4. A general familiarity with the Java language, specifically the use of Java annotations. DevKit’s functionality is exposed to connector developers through Java annotations that inject code into your connector classes. The injected code provides the interface between the connector and Mule that would otherwise require each connector developer to include extensive boilerplate code. This documentation explains each DevKit-specific annotation in the context of examples. If you are not familiar with annotations, refer to a brief explanation of Java annotations.

Important: To build connector projects, you must first install the Anypoint Connector DevKit Plugin into Anypoint Studio.

Viewing the Connector Structure

This Anypoint Connector DevKit module includes an Eclipse perspective that displays all of the DevKit classes, properties, methods, processors, and configurable fields from all your connectors inside the selected project.

To configure DevKit View:

  1. Click the Add View icon in the upper right of the screen and click Other.

    The Other button selected
  2. Click Devkit and OK to open the DevKit Perspective.

    The Devkit option selected
  3. Click any item in the Devkit perspective to display the code which defines it, for example:

    The Devkit view

The DevKit view lets you:

  • Double-click a Configurable field or a method to easily navigate to the line of code where it is defined.

  • Check the name with which your operation is exposed in the XML.

  • Double-click an XSD name to see examples in the sample doc file.

  • Filter to find elements in your connector.

Using Auto-Completion

When editing your connector’s main Java file, the auto-complete function provides a scaffold structure for several common methods that you may want to add. These structures come with rudimentary Javadoc documentation, which you should populate so that your project passes build tests successfully and your connector’s users can access reference material about your connector.

With your cursor on the @Connector class or any other @ annotation, type CTRL + spacebar to view a list of suggested entries:

Autocomplete function to help you create your connector project

For more information on @Connector and other Anypoint Connector DevKit annotations, see the Anypoint DevKit API Reference.

Using Code Templates

Templates are customizable pieces of code that you can add to your connector, and which provide a basic structure for elements you commonly use. Type the name or part of it and press [ Command | Ctrl ] + space to insert the template into the current Connector Class.

Example of a code template for a field name

Available DevKit Templates

configurable

Add a configurable field.

datasense

Add a DataSense operation.

processor

Add a processor to your connector. There are several options with different templates.

transformer

Add a transformer method. Transformers convert one input to another.

restconfig

Add a configurable element to a REST-based connector, such as URI params, query params, or header params.

restprocessor

@RestCall processor deprecated from 3.9.0 onward. REST-based connectors insert the @RestCall parameter when you create an Anypoint Connector Project.

Installing or Updating Your Connector in Anypoint Studio

After coding your connector, you can install it in Anypoint Studio and give it a test drive. Once installed, you can use your connector in a Mule Project and verify that it works as you intended.

  1. In the package explorer of Anypoint Studio, right-click your project root.

  2. Select Anypoint Connector > Install or Update:

    Dropdown menu to install or update your connector
  3. At Check the items you wish to install, click Next.

  4. At Review the items to be installed, click Next.

  5. At Review Licenses, click I accept the terms of the license agreement, and click Finish.

  6. Restart Anypoint Studio.

Test Drive Your Connector

To try your connector out:

  1. Create a new project by clicking New > Mule Project.

  2. Add an HTTP connector to the canvas.

  3. Search for your connector by name and add it to the flow.

    For example:

    Custom connector added to the list of connectors

Importing An Existing Connector Project

To import an existing connector project, click File > Import > Anypoint Studio > Anypoint Connector Project from External Location, choose a URL or a .zip file, and complete the wizard to locate and import the project.

Window that shows how to import an existing project

Exporting a Compressed Project File

To create a compressed file of your project:

  1. In Anypoint Studio, right-click your project name in the Package Explorer, and click Export.

  2. Click General > Archive File with these settings. Choose whether you want a TAR file (for Linux or Mac) or a ZIP file for Mac or Windows. (Windows users can also uncompress TAR files using third-party software such as 7zip.)
    IMPORTANT: Uncheck the target folder.

    Window for exporting resources to an archive file on the local file system
  3. Click the down arrow next to your project name and unclick target:

    Folder structure with the target folder unselected
  4. Click Browse in To archive file and choose the name and location of the zip or tar file.

  5. Click Finish to create the compressed file.

See Also