Skip to content

Latest commit

 

History

History
126 lines (90 loc) · 5.17 KB

component-registering.adoc

File metadata and controls

126 lines (90 loc) · 5.17 KB

Registering components

Before implementing a component logic and configuration, you need to specify the family and the category it belongs to, the component type and name, as well as its name and a few other generic parameters. This set of metadata, and more particularly the family, categories and component type, is mandatory to recognize and load the component to Talend Studio or Cloud applications.

Some of these parameters are handled at the project generation using the starter, but can still be accessed and updated later on.

Component family and categories

The family and category of a component is automatically written in the package-info.java file of the component package, using the @Components annotation. By default, these parameters are already configured in this file when you import your project in your IDE. Their value correspond to what was defined during the project definition with the starter.

Multiple components can share the same family and category value, but the family + name pair must be unique for the system.

A component can belong to one family only and to one or several categories. If not specified, the category defaults to Misc.

The package-info.java file also defines the component family icon, which is different from the component icon. You can learn how to customize this icon in this section.

Here is a sample package-info.java:

@Components(name = "my_component_family", categories = "My Category")
package org.talend.sdk.component.sample;

import org.talend.sdk.component.api.component.Components;

Another example with an existing component:

@Components(name = "Salesforce", categories = {"Business", "Cloud"})
package org.talend.sdk.component.sample;

import org.talend.sdk.component.api.component.Components;

Component icon and version

Components can require metadata to be integrated in Talend Studio or Cloud platforms. Metadata is set on the component class and belongs to the org.talend.sdk.component.api.component package.

When you generate your project and import it in your IDE, icon and version both come with a default value.

  • @Icon: Sets an icon key used to represent the component. You can use a custom key with the custom() method but the icon may not be rendered properly. The icon defaults to Check.
    Replace it with a custom icon, as described in this section.

  • @Version: Sets the component version. 1 by default.
    Learn how to manage different versions and migrations between your component versions in this section.

For example:

@Version(1)
@Icon(FILE_XML_O)
@PartitionMapper(name = "jaxbInput")
public class JaxbPartitionMapper implements Serializable {
    // ...
}

Component type and name

The component type is declared in the component class. When you import your project generated from the starter in your IDE, the component type is already defined.

Input components can be:

  • A partition mapper. @PartitionMapper is the default for input components.

  • An emitter. @Emitter is a shortcut for @PartitionMapper when you don’t support distribution. It enforces an implicit partition mapper execution with an assessor size of 1 and a split returning itself.

Processor/Output components can be:

  • A processor. @Processor is the default for output components. A method decorated with @Processor is considered as a producer factory.

  • Combiners are not supported by the framework. Combiners allow to aggregate results in a single partition.

The name of the component is defined there as well as a parameter of the component type.

Once the component type is defined, you can start implementing its specific logic:

Partition mapper example:

@PartitionMapper(name = "my_mapper")
public class MyMapper {
}

Emitter example:

@Emitter(name = "my_input")
public class MyInput {
}

Processor example:

@Processor(name = "my_processor")
public class MyProcessor {
}