Skip to content

Creating Custom Components

gwilmer edited this page Jul 5, 2017 · 39 revisions

Creating Custom Components

Overview

Metl comes with a large set of prepackaged components. These components cover a broad set of functional capabilities commonly used in etl/elt and service based integration scenarios. However, if a unique need aries, custom components can be created to implement specialized needs. Building custom components is straight forward and done in the same manner as Metl’s prepackaged components. The basic steps to build a component are as follows:

  • Create a Java Project - The java project will contain the source code and related files for the custom component

  • Create the Component Definition - The component definition defines the basic aspects of the component including the name, description, type, source file, message and resource types, settings, etc.

  • Create the Component User Interface Definition - The user interface definition defines aspects of the user interface including icons, and if needed, custom ui java classes

  • Implement the Component Methods - Every component implements an interface that tells the component what to do on startup, when a message is received, and on shutdown

  • Package the component - Files in the java project are packaged into .jar files or .zip files for deployment

  • Deploy the Component - Provide the packaged component to Metl via uploading it directly to the running Metl instance or loading it into a maven repository accessible to that Metl instance.

Create a Java Project

The core Metl engine including its prepackaged projects are built in java. In order to create a custom component, first create a java project to hold the source code and related files for the component. The java project will need to have a dependency on the metl-core library which can be found in the JumpMind maven repository (http://maven.jumpmind.com/repo). Sample gradle and maven dependencies are as follows:

build.gradle

repositories {
    maven { url "http://maven.jumpmind.com/repo" }
}

dependencies {
    compileOnly 'org.jumpmind.metl:metl-core:2.0.6.r.65'
}

pom.xml

<repositories>
  <repository>
    <id>JumpMind</id>
    <name>JumpMind Repo</name>
    <url>http://maven.jumpmind.com/repo</url>
  </repository>
</repositories>

<dependencies>
  <dependency org="org.jumpmind.metl" name="metl-core" rev="2.0.6.r.65" />
</dependencies>

A typical Metl custom component project structure is depicted below.

Custom Component Project Structure

The project should contain the following parts:

  • plugin.xml - Used to create the component definition

  • ui.xml - Used to create the ui definition

  • One or more java class(es) that implements the component(s) - Used to implement the component methods

Create the Component Definition

The component definition is created by creating a plugin.xml file. This xml file must conform to the components.xsd which can be found here.

An example plugin.xml is shown below.

plugin.xml

<definitions>
  <component category='PROCESSOR'
             id='Pushover'
             inputMessageType='any'
             inputOutputModelsMatch='false'
             outputMessageType='any'
             supportsMultipleThreads='false'
             resourceCategory='none'>
    <name>Pushover Message</name>
    <className>org.jumpmind.metl.core.runtime.component.Pushover</className>
    <keywords>message,notification</keywords>
    <description></description>
    <settings>
    <setting id='run.when'
               required='false'
               type='choice'>
        <name>Run When</name>
        <defaultValue>PER UNIT OF WORK</defaultValue>
        <choices>
          <choice>PER UNIT OF WORK</choice>
          <choice>PER MESSAGE</choice>
        </choices>
      </setting>
      <setting id='token'
               required='true'
               type='text'>
        <name>Token</name>
      </setting>
      <setting id='user'
               required='true'
               type='text'>
        <name>User Key</name>
      </setting>
      <setting id='message'
               required='false'
               type='multiline_text'>
        <name>Message</name>
        <defaultValue>Message</defaultValue>
      </setting>
      <setting id='device'
               required='false'
               type='text'>
        <name>device</name>
      </setting>
      <setting id='title'
               required='false'
               type='text'>
        <name>Title</name>
      </setting>
      <setting id='url'
         required='false'
         type='text'>
         <name>URL</name>
      </setting>
      <setting id='url.title'
               required='false'
               type='text'>
        <name>URL title</name>
      </setting>
      <setting id='priority'
               required='false'
               type='choice'>
        <name>Priority</name>
        <defaultValue>1</defaultValue>
        <choices>
        	<choice>-2</choice>
        	<choice>-1</choice>
        	<choice>0</choice>
        	<choice>1</choice>
        	<choice>2</choice>
        </choices>
      </setting>
      <setting id='retry'
               required='false'
               type='text'>
        <name>Retry</name>
      </setting>
      <setting id='expire'
               required='false'
               type='text'>
        <name>Expire</name>
      </setting>
      <setting id='sound'
               required='false'
               type='choice'>
        <name>Sound</name>
        <defauldValue>pushover</defauldValue>
        <choices>
        	<choice>pushover</choice>
        	<choice>bike</choice>
        	<choice>bugle</choice>
        	<choice>cashregister</choice>
        	<choice>classical</choice>
        	<choice>cosmic</choice>
        	<choice>falling</choice>
        	<choice>gamelan</choice>
        	<choice>incoming</choice>
        	<choice>intermission</choice>
        	<choice>magic</choice>
        	<choice>mechanical</choice>
        	<choice>pianobar</choice>
        	<choice>siren</choice>
        	<choice>spacealarm</choice>
        	<choice>tugboat</choice>
        	<choice>alien</choice>
        	<choice>climb</choice>
        	<choice>persistent</choice>
        	<choice>echo</choice>
        	<choice>updown</choice>
        	<choice>none</choice>
        </choices>
      </setting>
    </settings>
  </component>
</definitions>
Create the Component User Interface Definition

The ui definition for the component including the icon used for the component as well as the component editor for the component is created by creating a ui.xml file. A custom component can use the standard Metl component ui which displays all settings defined in the plugin.xml, or it can create its own custom ui by implementing its own java ui class. Two sample ui.xml files are shown below, one using the standard metl component ui, and the other using a custom ui.

ui.xml (using standard Metl component UI)

<ui>
    <component-ui id="Pushover Message" componentId="Pushover">
        <iconImage>org/jumpmind/metl/core/runtime/component/Pushover.png</iconImage>
    </component-ui>
</ui>

ui.xml (using a custom UI)

<ui>
    <component-ui id="Mapping UI" componentId="Mapping">
        <iconImage>org/jumpmind/metl/core/runtime/component/metl-mapping-48x48-color.png</iconImage>
        <className>org.jumpmind.metl.ui.mapping.EditMappingPanel</className>
    </component-ui>
</ui>
Implement the Component Methods
Package the component
Deploy the Component
Clone this wiki locally