Anypoint Connector DevKit
karthik
0
Introduction
 The Anypoint Connector DevKit, or simply DevKit, enables the development of
Anypoint Connectors. An Anypoint Connector is an extension module to the
MuleSoft Anypoint Platform that facilitates communication between third-party
systems/APIs and Mule applications.
Developing with DevKit
 This is what you need to develop DevKit-based Anypoint Connectors on your system with your instance of Anypoint Studio.
 See detailed instructions here on how to install: Java JDK version 8, Apache Maven, Anypoint Studio, and Anypoint DevKit Plugin to build and test your connector. You can develop a connector using
Windows, Mac, or Linux.
 New Connector:
 Anypoint Connector Developer Guide - Set up Anypoint Studio and install the connector plugin.
 Existing Connector:
 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.
 See also Creating a SOAP Connector Creating a REST Connector Using Jersey.
 Determine resource access - Each resource has a different access method, such as REST, SOAP, FTP, or the Java SDK
features.
 Choose an authentication mechanism - Mule supports OAuth V1 or V2, and username and password authentication
(known as connection management), which can be used for protocols such as API Key, SAML, NTLM, Kerberos, or
LDAP.
 Choose the connector’s data model - Models can be static Java objects or dynamic objects. You can use DataSense -
Determine what information the target resource expects.
 Add connector @ attribute annotations - Create code for your connector containing the @ attributes that Mule uses
to designate the important parts of your connector.
 Code tests - Tests can be unit tests, functional tests, and Studio interoperability tests.
 Document your connector - MuleSoft provides a template that helps you fill in the blanks to create documentation to
help your staff and others understand the features and use of your connector.
 Package your connector.
DevKit Features Visual design and implementation using Anypoint Studio with an Eclipse-based interface that simplifies and speeds up
development.
 Maven support.
 Connector packaging tools.
 Authentication support for multiple types of authentication, including OAuth and username and password authentication.
 DataSense support to acquire remote metadata.
 Extensive testing capability.
 Examples, training, and support to simplify development startup.
 Batch, Query Pagination, and DataSense Query Language support.
What is a Connector?
 An Anypoint Connector is an extension module that eases the interaction between a
Mule application and external resources, such as a databases or APIs, through REST,
SOAP, or the Java SDK.
 As reusable components that hide API complexity from the integration developer,
custom connectors facilitate integration with SaaS and on-premise web services,
applications, and data sources. Connectors built using Anypoint DevKit in Anypoint
Studio, running Mule runtime environments, act as extensions of Mule Anypoint
Platform.
Connector Architecture
 Connectors operate within Mule applications, which are built up from Mule
Flows, and external resources, which are the targeted resources.
 A Mule connector has two operational sides. The Mule-facing side
communicates with a resource’s target-facing client side to enable content to
travel between the Mule applications, and the external target-facing resource.
Mule-Facing Functionality
 From the Mule-facing side, a connector consists of:
 Main Java class. Java code that you annotate with the @Connector attribute. See the
Anypoint DevKit API Reference for information about Anypoint Connector DevKit annotations.
See Java annotations for information on how annotations work.
 Connector attributes. Properties of the @Connector class that you annotate with the
@Configurable attribute.
 Methods. Functionality that you annotate with the @Processor attribute.
 Additional annotations define authentication-related functionality, such as connection
management. Annotations allow you to control the layout of the Anypoint Studio
dialogues for the connector as well. The data model and exceptions that either raise or
propagate are also Mule-facing classes.
 DevKit generates a scaffold connector when you create your Anypoint Connector
project in Studio. This scaffold connector includes the @Connector class, the
@Configurable attributes, the @Processor methods, and authentication logic to build
out your connector.
Target-Facing Functionality
 The target facing or client facing side of a connector depends on the client
technology that enables access to the resource. This functionality consists of a class
library and one or more classes that @Connector classes use to access client
functionality. This functionality is called the client class.
 The client class in turn generally depends on other classes to actually implement calls
to the targeted resource. Depending on your target, some of these classes may be
generated or provided for you. For example, if you have a Java client library, or are
working with a SOAP or REST services, most of the client code is implemented there.
In other cases, you have to write the code yourself.
Coding a Connector
 DevKit lets you build connectors from scratch. Before creating your own
connector, check the Anypoint Exchange for available connectors. The
connectors page also lists Community open source connectors that let you
contribute to the growing community of public connector development.
Connector Data Model
 The data model for the connector consists of the objects passed into and out of
the exposed operations. While many Web services accept and return XML or
JSON data, a proper Mule connector must translate the data format the client
uses into Java objects – either POJOs or key-value maps which represent the
data objects sent to, and returned from, the target. (Returning raw XML or JSON
responses to Mule is one marker for an immature, improperly implemented
connector.)
REST Versus SOAP
 REST simplifies access to HTTP using POST, GET, PUT, and DELETE calls to provide access to
creating, getting, putting, and deleting information on a resource.
 DevKit currently provides a strategy for Creating a Connector for a RESTful API Using Jersey to
build a REST API-supported connector.
 SOAP is a traditional means of communicating with a resource and requires a WSDL file, which is
an XML file that specifies all aspects of a Java class’s structure, methods, properties, and
documentation. SOAP is an industry standard with tools for governance, building, and schema
information. DevKit provides a tools that helps building a connector using a WSDL file.
DevKit 3.8 Example Default Connector
 The following is an example of the starting @Connector and @Configuration
classes that DevKit 3.8 create

Anypointconnectordevkit 160816041722

  • 1.
  • 2.
    Introduction  The AnypointConnector DevKit, or simply DevKit, enables the development of Anypoint Connectors. An Anypoint Connector is an extension module to the MuleSoft Anypoint Platform that facilitates communication between third-party systems/APIs and Mule applications.
  • 3.
    Developing with DevKit This is what you need to develop DevKit-based Anypoint Connectors on your system with your instance of Anypoint Studio.  See detailed instructions here on how to install: Java JDK version 8, Apache Maven, Anypoint Studio, and Anypoint DevKit Plugin to build and test your connector. You can develop a connector using Windows, Mac, or Linux.  New Connector:  Anypoint Connector Developer Guide - Set up Anypoint Studio and install the connector plugin.  Existing Connector:  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.  See also Creating a SOAP Connector Creating a REST Connector Using Jersey.
  • 4.
     Determine resourceaccess - Each resource has a different access method, such as REST, SOAP, FTP, or the Java SDK features.  Choose an authentication mechanism - Mule supports OAuth V1 or V2, and username and password authentication (known as connection management), which can be used for protocols such as API Key, SAML, NTLM, Kerberos, or LDAP.  Choose the connector’s data model - Models can be static Java objects or dynamic objects. You can use DataSense - Determine what information the target resource expects.  Add connector @ attribute annotations - Create code for your connector containing the @ attributes that Mule uses to designate the important parts of your connector.  Code tests - Tests can be unit tests, functional tests, and Studio interoperability tests.  Document your connector - MuleSoft provides a template that helps you fill in the blanks to create documentation to help your staff and others understand the features and use of your connector.  Package your connector.
  • 5.
    DevKit Features Visualdesign and implementation using Anypoint Studio with an Eclipse-based interface that simplifies and speeds up development.  Maven support.  Connector packaging tools.  Authentication support for multiple types of authentication, including OAuth and username and password authentication.  DataSense support to acquire remote metadata.  Extensive testing capability.  Examples, training, and support to simplify development startup.  Batch, Query Pagination, and DataSense Query Language support.
  • 6.
    What is aConnector?  An Anypoint Connector is an extension module that eases the interaction between a Mule application and external resources, such as a databases or APIs, through REST, SOAP, or the Java SDK.  As reusable components that hide API complexity from the integration developer, custom connectors facilitate integration with SaaS and on-premise web services, applications, and data sources. Connectors built using Anypoint DevKit in Anypoint Studio, running Mule runtime environments, act as extensions of Mule Anypoint Platform.
  • 7.
    Connector Architecture  Connectorsoperate within Mule applications, which are built up from Mule Flows, and external resources, which are the targeted resources.  A Mule connector has two operational sides. The Mule-facing side communicates with a resource’s target-facing client side to enable content to travel between the Mule applications, and the external target-facing resource.
  • 8.
    Mule-Facing Functionality  Fromthe Mule-facing side, a connector consists of:  Main Java class. Java code that you annotate with the @Connector attribute. See the Anypoint DevKit API Reference for information about Anypoint Connector DevKit annotations. See Java annotations for information on how annotations work.  Connector attributes. Properties of the @Connector class that you annotate with the @Configurable attribute.  Methods. Functionality that you annotate with the @Processor attribute.
  • 9.
     Additional annotationsdefine authentication-related functionality, such as connection management. Annotations allow you to control the layout of the Anypoint Studio dialogues for the connector as well. The data model and exceptions that either raise or propagate are also Mule-facing classes.  DevKit generates a scaffold connector when you create your Anypoint Connector project in Studio. This scaffold connector includes the @Connector class, the @Configurable attributes, the @Processor methods, and authentication logic to build out your connector.
  • 10.
    Target-Facing Functionality  Thetarget facing or client facing side of a connector depends on the client technology that enables access to the resource. This functionality consists of a class library and one or more classes that @Connector classes use to access client functionality. This functionality is called the client class.  The client class in turn generally depends on other classes to actually implement calls to the targeted resource. Depending on your target, some of these classes may be generated or provided for you. For example, if you have a Java client library, or are working with a SOAP or REST services, most of the client code is implemented there. In other cases, you have to write the code yourself.
  • 11.
    Coding a Connector DevKit lets you build connectors from scratch. Before creating your own connector, check the Anypoint Exchange for available connectors. The connectors page also lists Community open source connectors that let you contribute to the growing community of public connector development.
  • 12.
    Connector Data Model The data model for the connector consists of the objects passed into and out of the exposed operations. While many Web services accept and return XML or JSON data, a proper Mule connector must translate the data format the client uses into Java objects – either POJOs or key-value maps which represent the data objects sent to, and returned from, the target. (Returning raw XML or JSON responses to Mule is one marker for an immature, improperly implemented connector.)
  • 13.
    REST Versus SOAP REST simplifies access to HTTP using POST, GET, PUT, and DELETE calls to provide access to creating, getting, putting, and deleting information on a resource.  DevKit currently provides a strategy for Creating a Connector for a RESTful API Using Jersey to build a REST API-supported connector.  SOAP is a traditional means of communicating with a resource and requires a WSDL file, which is an XML file that specifies all aspects of a Java class’s structure, methods, properties, and documentation. SOAP is an industry standard with tools for governance, building, and schema information. DevKit provides a tools that helps building a connector using a WSDL file.
  • 14.
    DevKit 3.8 ExampleDefault Connector  The following is an example of the starting @Connector and @Configuration classes that DevKit 3.8 create