Contact Us 1-800-596-4880

DevKit Shortcut to Success

This document quickly walks you through the decisions to make and the steps to take to get an Anypoint Connector development project started, get the connector working, and enhance it with the functionality you need. You can use this as a roadmap for your connector development effort.

Assumptions

This document assumes you have met all the assumptions detailed in Anypoint Connector DevKit.

Outline of the Connector Development Process

When you develop a connector using DevKit, your use case drives a series of decisions about authentication, connectivity, and how to call operations on your target and pass data to the external application or other resource. These choices, in turn, drive what you develop. Where a choice presents itself, this document provides information to help you make a decision and provides links to the get more details.

Step 1 Setting Up a Development Environment

  1. Select, then install a Java Integration Development Environment (IDE), such as Eclipse, IntelliJ or Mule Studio with m2eclipse.

  2. Install JDK7.

  3. Install Maven.

  4. Install Mule Studio, so as to be able to test your connector.

Refer to Setting Up a DevKit Development Environment for detailed instructions.

Step 2 Preparing API Access and a Sandbox Environment

  1. Prepare a test environment for your connector. Details vary greatly based on the target system.

    1. SaaS – For some SaaS applications, the sandbox may be a separate account from the production account, or may answer at a different endpoint

    2. On-premise – For some on-premise systems or Web services, you may simply have a separate standalone installation with dummy data instead of production data.

  2. Acquire any existing documentation for your target system, such as API documentation.

Refer to Preparing API Access or a Sandbox Environment for representative examples.

Step 3 Creating a Connector Project

  1. Follow the process in Creating a Connector Project to start a connector development project in your development environment.

  2. Read the connector development cycle. As you must carry out this process repeatedly as you work on your connector, it’s worth understanding the build-install-test cycle connector development follows.

  3. To your Maven project, add any required Java libraries for your target system, such as client libraries or class libraries provided for the target system.

When finished, you should have a skeleton project, containing a Java class with the most basic functionality for a connector in place.

Step 4 Implementing Connectivity and Authentication

For connectors to Web services that require authentication, you must identify the authentication methods you want your connector to support.

  1. Based on your use case, select an authentication method from the table below. For more details, read Authentication and Connection Management which introduces all of the supported methods.

    Authentication Method Full Documentation Notes

    OAuth 1, OAuth 2 or other OAuth variants

    More common with RESTful Web services and cloud applications.

    Basic Authentication (username/password)

    Implementing Connection Management

    The simplest mode of authentication, often used with SOAP web services.

    Other authentication protocols (SAML, NTLM)

    Implementing Connection Management

    Similar to basic authentication, (relies on the same annotations.) You may have to implement some supplemental logic.

  2. You may want to add an attribute to your connector that specifies the endpoint to which to connect.

Refer to Defining Configurable Connector Attributes for detailed instructions.

Step 5 Adding Operations and Attributes

Most of the Java code you write for your connector relates to how you call operations on your target and how the connector must pass data between those operations and Mule. This is the area that varies most among connectors, based on the API, the operations and passed data for the Web service.

  1. Use the table below to select an approach for building your connector based upon the style of Web service to which you need to connect.

    Web Service Style Recommended Approach Notes

    Pre-built Java Client Library

    Client Library

    If an official or well-known third party library is available, this is generally the simplest connector style to implement, and is recommended. Most client libraries are actually wrappers for SOAP or RESTful APIs.

    SOAP API

    Apache CXF

    The de facto standard library for building and consuming SOAP Web services, this style handles client logic and Java object mapping to XML.

    RESTful API

    Jersey Client

    Flexible enough to address virtually any RESTful API.

    RESTCall Annotations

    DevKit’s built-in client for RESTful APIs. Useful for very cleanly designed RESTful APIs; Jersey Client usually preferred if there are corner cases.

  2. To improve the usability of your connector, consider customizing the appearance of the connector property dialog, text prompts, and connector icons.

Read more about customizing connector usability in Customizing Connector Integration with ESB and Studio.

Step 6 Building Unit and Functional Tests

Any production-ready connector must have a suite of unit and functional tests; connectors use the standard JUnit framework. In practice, you should build your unit tests as you implement your connector’s operations. Most successful connector implementations have used a test-driven approach to development.

  1. Develop one or more Mule flows that use the connector.

  2. Create an instance of FunctionalTestCase that runs the test. For DevKit testing, you run Mule inside a JUnit test case. Each test case you build will extend the class FunctionalTestCase (a subclass of JUnit). The test case manages the lifecycle of a Mule runtime instance and calls flows to carry out the test.

  3. Programmatically examine the results of the test case to determine success or failure.

Before the connector can be released to the world, you must run a thorough test suite that covers all operations and exercises each major code path. The Maven-generated project contains one sample test case under the src/test/java directory to get you started.

Refer to Developing DevKit Connector Tests for details on how to implement connector test cases using JUnit.

Step 7 Documenting Your Connector

A full-featured connector must have documentation. DevKit enables – and enforces – the creation of complete reference documentation including code samples.

  1. Each time you add an operation to the connector (Step 3, above), DevKit adds sample XML code snippets in comments in the source code. These snippets appear in the auto-generated connector documentation.

  2. Review the auto-generated documentation to determine if you wan to expand upon it, offering more than information than the simple documentation of individual operations.

Refer to Creating DevKit Connector Documentation for further details.

Step 8 Packaging and Releasing Your Connector

  1. Before releasing a connector, ensure your license agreement is in place.

  2. If your connector is intended only for internal use, you can share it as an Eclipse update site.

  3. To share your connector with the community, go to www.mulesoft.org/connectors.

Refer to Packaging Your Connector for Release for full details.

See Also

  • NEXT: Understand the Anypoint Connector DevKit concepts.