A connector is a collection of that define operations that call the APIs of a Cloud-based service like Twitter and JIRA. There are several default connectors provided with the ESB, but you can also create your own. Creating a connector involves the following high-level tasks:
- Research the APIs provided by the service for which you want to create a connector.
- Decide which API you are going to use to write the connector. For example, JIRA provides a REST API and Java API. If you choose the REST API, you can create your connector and operations entirely from XML configuration files. If you choose a Java API, you create XML configuration files that define your connector and point to your Java classes that define the operations.
- Use the connector core libraries to write your connector.
- After you create the files, you package them in a ZIP file, which you can then add to an ESB instance.
This page describes the structure of the configuration files you create for your connector, and best practices for creating connectors.
Creating the configuration files
Use your IDE to create a Maven project, and create a directory structure similar to the following:
Following is a description on the required files shown above.
pom.xml- Contains the required dependencies for the connector core libraries and relevant Synapse libraries, as well as Maven repositories for the specific connector (such as JIRA Maven repositories for a JIRA connector).
assemble-connector.xml- Contains the instructions to create the connector archive (ZIP) file.
connector.xml- Defines the connector name, package, and the different categories of operations that will be exposed for the connector. For example, the JIRA connector's connector.xml file looks like this:
For each of the categories you specify, you create a corresponding directory (as shown above in the directory tree), each of which contains a
component.xml- Contains information about the operations in this category. For example, in the
component.xmlfile looks like this:
Each operation is specified as a separate sub-component of the operation group.
<operation-name>.xml- Contains the actual API calling configuration. This file contains the steps necessary to call the API exposed by the service. For example, the
createFilteroperation defined above points to the file
createFilter.xml, which uses templates to define the configuration: