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.
This document assumes you have met all the assumptions detailed in Anypoint Connector DevKit.
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.
Select, then install a Java Integration Development Environment (IDE), such as Eclipse, IntelliJ or Mule Studio with m2eclipse.
Install Mule Studio, so as to be able to test your connector.
Refer to Setting Up a DevKit Development Environment for detailed instructions.
Prepare a test environment for your connector. Details vary greatly based on the target system.
SaaS – For some SaaS applications, the sandbox may be a separate account from the production account, or may answer at a different endpoint
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.
Acquire any existing documentation for your target system, such as API documentation.
Refer to Preparing API Access or a Sandbox Environment for representative examples.
Follow the process in Creating a Connector Project to start a connector development project in your development environment.
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.
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.
For connectors to Web services that require authentication, you must identify the authentication methods you want your connector to support.
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)
The simplest mode of authentication, often used with SOAP web services.
Other authentication protocols (SAML, NTLM)
Similar to basic authentication, (relies on the same annotations.) You may have to implement some supplemental logic.
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.
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.
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
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.
The de facto standard library for building and consuming SOAP Web services, this style handles client logic and Java object mapping to XML.
Flexible enough to address virtually any RESTful API.
DevKit’s built-in client for RESTful APIs. Useful for very cleanly designed RESTful APIs; Jersey Client usually preferred if there are corner cases.
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.
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.
Develop one or more Mule flows that use the connector.
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.
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.
A full-featured connector must have documentation. DevKit enables – and enforces – the creation of complete reference documentation including code samples.
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.
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.
Before releasing a connector, ensure your license agreement is in place.
If your connector is intended only for internal use, you can share it as an Eclipse update site.
To share your connector with the community, go to http://www.mulesoft.org/connectors[www.mulesoft.org/connectors].
Refer to Packaging Your Connector for Release for full details.
NEXT: Understand the Anypoint Connector DevKit concepts.