<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nicolas Chabanoles</title>
    <description>The latest articles on DEV Community by Nicolas Chabanoles (@chabanoles).</description>
    <link>https://dev.to/chabanoles</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F136029%2F1a6535a8-3cc0-43ef-aa47-d02219257a0b.jpg</url>
      <title>DEV Community: Nicolas Chabanoles</title>
      <link>https://dev.to/chabanoles</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chabanoles"/>
    <language>en</language>
    <item>
      <title>3 simple ways to create connectors for the Bonita Platform</title>
      <dc:creator>Nicolas Chabanoles</dc:creator>
      <pubDate>Wed, 10 Jun 2020 15:20:38 +0000</pubDate>
      <link>https://dev.to/chabanoles/3-simple-ways-to-create-connectors-for-the-bonita-platform-54ip</link>
      <guid>https://dev.to/chabanoles/3-simple-ways-to-create-connectors-for-the-bonita-platform-54ip</guid>
      <description>&lt;p&gt;When using the Bonita platform to develop an application or process, connectors are a means to interact with your information system (IS) to read or write data. A connector is merely a piece of Java code that connects to the IS to execute an operation (read or write). &lt;/p&gt;

&lt;p&gt;Bonita comes natively with 50+ connectors to fit the most generic use cases. Among the most frequently used connector family, you have the REST connectors, e-mail connector, and the database connectors (data source / JDBC). Chances are that you will find the connector you need directly from the provided library.&lt;/p&gt;

&lt;p&gt;If that is not the case, no worries, the Bonita platform lets you define new connectors to meet your needs!&lt;/p&gt;

&lt;p&gt;In this article, I will explain 3 simple ways to create a connector. But before we dive into the tutorial, I think it is important to introduce 2 notions: connector definition VS connector implementation.&lt;/p&gt;

&lt;h1&gt;
  
  
  Connector definition
&lt;/h1&gt;

&lt;p&gt;A connector definition is a contract (described in an XML file) that the connector will fulfill, i.e. the list of input parameters with their type, the list of output parameters with their type, and the description of the UI to provide to the user so they can configure the connector from Bonita Studio.&lt;/p&gt;

&lt;p&gt;For instance, a Slack connector definition may contain the following inputs.&lt;/p&gt;

&lt;p&gt;Input 1&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Name:&lt;/em&gt; channel&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Type:&lt;/em&gt; Text&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Widget:&lt;/em&gt; TextInput
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Input 2&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Name:&lt;/em&gt; message&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Type:&lt;/em&gt; Text&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Widget:&lt;/em&gt; TextArea (for long text)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Input 3&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Name:&lt;/em&gt; slackServer&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Type:&lt;/em&gt; URL&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Widget:&lt;/em&gt; TextInput
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And as output:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Name:&lt;/em&gt; responseCode&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Type:&lt;/em&gt; Number&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this example, responseCode will provide a hint about whether the message has been sent or queued by the server.&lt;/p&gt;

&lt;h1&gt;
  
  
  Connector implementation
&lt;/h1&gt;

&lt;p&gt;The connector implementation is the Java class that respects the connector definition and also extends the Java &lt;a href="https://documentation.bonitasoft.com/javadoc/api/7.10/org/bonitasoft/engine/connector/AbstractConnector.html" rel="noopener noreferrer"&gt;AbstractConnector&lt;/a&gt; class.&lt;/p&gt;

&lt;p&gt;To simplify, it is a Java class with connect(), executeBusinessLogic(), and disconnect() methods that will be called in sequence by the Bonita platform.&lt;/p&gt;

&lt;p&gt;If we continue with our Slack connector example, the connect() method will use the slackServer input parameter value to connect to the service. The executeBusinessLogic() method will use the other input parameters to compose the message and send it to the right channel.&lt;/p&gt;

&lt;p&gt;In this article, we will see how to create both the definition and the implementation of a connector in Bonita.&lt;/p&gt;

&lt;h1&gt;
  
  
  Using Bonita Studio
&lt;/h1&gt;

&lt;p&gt;The simplest way to create a connector (especially the definition) is to use Bonita Studio directly. It provides graphical wizards to build the definition. &lt;/p&gt;

&lt;h2&gt;
  
  
  Connector Definition
&lt;/h2&gt;

&lt;p&gt;From the Development menu, select Connectors and New definition…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frz6pb3n1kxl0vpvn7u3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frz6pb3n1kxl0vpvn7u3t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fur420ljkqq7reoc5600f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fur420ljkqq7reoc5600f.png" alt="Wizard to create UI for a Bonita connector"&gt;&lt;/a&gt;&lt;br&gt;Create UI for connector definition
  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; you will also have the opportunity to translate the generated UI for your connector configuration. This allows developers to configure your connector in their language.&lt;/p&gt;

&lt;p&gt;Once you have completed the definition, you can start using the connector in your process model. You do not need the implementation to model a process that will call your connector - but you will need the implementation when you execute the process. &lt;/p&gt;

&lt;p&gt;It is very easy to forget an input or to misconfigure the UI widget at this stage. In my opinion, the best way to check that a connector definition is conceived properly is to use the connector in a process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv7gk8d5vvv5b0htfpujq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fv7gk8d5vvv5b0htfpujq.png" alt="Select a connector to call on a human task"&gt;&lt;/a&gt;&lt;br&gt;Select a connector to call on a human task
  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhin9drs877pq4g6i2ijg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhin9drs877pq4g6i2ijg.png" alt="Configure the connector to send a Slack notification when a task is available"&gt;&lt;/a&gt;&lt;br&gt;Configure the connector to send a Slack notification when a task is available
  &lt;/p&gt;

&lt;p&gt;If you spot any mistakes you can edit the definition and make all the changes that seem relevant to you. And by doing this before implementing the connector, you save time on the implementation impacts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connector Implementation
&lt;/h2&gt;

&lt;p&gt;Now that your definition is complete and you have quickly validated that it fits your needs by using it in a process, we can dive into the Java coding.&lt;/p&gt;

&lt;p&gt;From the Development menu select Connectors and New implementation…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo3kvm6syzeoi4bv8y562.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo3kvm6syzeoi4bv8y562.png" alt="Select a connector definition to implement"&gt;&lt;/a&gt;&lt;br&gt;Select a connector definition to implement
  &lt;/p&gt;

&lt;p&gt;Select the connector definition you want to create an implementation for (Slack in our example). Go through the wizard page by page and adapt the values to your situation or leave them as is. At the end of the wizard, you will be directed to the connector Java editor where you will implement the 3 Java methods that define the connector behavior.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzajjwxy26xv2lo4s4ct5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzajjwxy26xv2lo4s4ct5.png" alt="Connector Implementation in Java"&gt;&lt;/a&gt;&lt;br&gt;Connector Implementation in Java
  &lt;/p&gt;

&lt;p&gt;Once you have implemented the connector, you can run your process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; How to create a SlackClient is out of scope of this article. You can find some good implementations on Maven Central.&lt;/p&gt;

&lt;h1&gt;
  
  
  Using your IDE
&lt;/h1&gt;

&lt;p&gt;We are going to create a new project from a Maven archetype that will generate the project structure for both the connector definition and implementation.&lt;br&gt;
I use IntelliJ IDEA, but you can do the same with your favorite IDE (e.g Eclipse, Visual Studio, etc).&lt;/p&gt;

&lt;p&gt;You may have to add the Maven archetype the first time you will use it: New project &amp;gt; Maven &amp;gt; Create from archetype &amp;gt; Add Archetype...&lt;/p&gt;


  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbiy346mergesjmql7n0q.png" alt="IntelliJ IDEA Add Maven Archetype"&gt;Add Maven Archetype
  


&lt;p&gt;The information you have to specify is:&lt;br&gt;
&lt;em&gt;GroupId:&lt;/em&gt; org.bonitasoft.archetypes&lt;br&gt;
&lt;em&gt;ArtifactId:&lt;/em&gt; bonita-connector-archetype&lt;br&gt;
&lt;em&gt;Version:&lt;/em&gt; 1.1.0&lt;/p&gt;

&lt;p&gt;Next time you’ll just need to select the archetype from the list.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcn0kabn438jlf425eeji.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcn0kabn438jlf425eeji.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure to specify the parameters required by the archetype:&lt;/p&gt;


  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fe4o5yzdxlqerjqyddvhg.png" alt="IntelliJ IDEA Kotlin Bonita Connector"&gt;Create a Kotlin project for your connector
  


&lt;p&gt;&lt;em&gt;className:&lt;/em&gt; SlackConnector  (The Java class containing the business logic)&lt;br&gt;
&lt;em&gt;language:&lt;/em&gt; kotlin (possible values: java, groovy, kotlin)&lt;br&gt;
&lt;em&gt;bonitaVersion:&lt;/em&gt; 7.10.4 (any version of Bonita platform)&lt;/p&gt;

&lt;p&gt;You now have a Maven project in your favorite IDE and are free to implement your connector and edit its definition from the generated files! For more information, you can refer to the Bonita documentation: &lt;a href="https://documentation.bonitasoft.com/bonita/latest/connector-archetype" rel="noopener noreferrer"&gt;https://documentation.bonitasoft.com/bonita/latest/connector-archetype&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Using the CLI
&lt;/h1&gt;

&lt;p&gt;If you usually use a terminal to create your projects, then you can use the Maven archetype directly from the command line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mvn archetype:generate -DarchetypeGroupId=org.bonitasoft.archetypes -DarchetypeArtifactId=bonita-connector-archetype -DarchetypeVersion=1.1.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll then have to interactively specify the properties of your project.&lt;/p&gt;

&lt;p&gt;There is a comprehensive README.md file in the GitHub repository of the project for more information: &lt;a href="https://github.com/bonitasoft/bonita-connector-archetype" rel="noopener noreferrer"&gt;https://github.com/bonitasoft/bonita-connector-archetype&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Now you have seen 3 simple ways to create connectors for the Bonita platform. I invite you to create your own and share them with the Bonita community here: &lt;a href="https://community.bonitasoft.com/" rel="noopener noreferrer"&gt;https://community.bonitasoft.com/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bpm</category>
      <category>bonita</category>
      <category>java</category>
      <category>kotlin</category>
    </item>
  </channel>
</rss>
