features icon

Writing Your Own Feature

Version: 17.07

Developer Guide

Overview

Project-X Framework exposes a set of utility functionalities as features. These features are managed and initialized via feature repository of the framework. Feature can be accessed easily from any connector or processing element easily by using the "@FeatureRef" as below,

    @FeatureRef
    private ClusteringFeature clusteringFeature;

Once you have declared your feature as above within your processor/connector, that feature will be automatically initialized and assigned by the framework at the initialization of your project.

If you want to write your own feature to expose some utility functionality to make sure that it’s easily accessible from your connectors and processors, Project-X framework provides that ability for you. This section of the documentation describe step by step guide on how to write your custom feature and expose some utility functionalities to your processors and connectors.

Writing a Custom Feature

You can write your custom feature using the UltraStudio by going through the following steps,

  1. First add following dependencies for your pom.xml. x-api and x-annotations are required dependencies for a feature implementation. x-base also will be required if you are expecting to implement complex functionalities within your feature.

        <dependency>
            <groupId>org.adroitlogic.x</groupId>
            <artifactId>x-api</artifactId>
            <version>${project-x.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.adroitlogic.x</groupId>
            <artifactId>x-annotations</artifactId>
            <version>${project-x.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.adroitlogic.x</groupId>
            <artifactId>x-base</artifactId>
            <version>${project-x.version}</version>
            <scope>provided</scope>
        </dependency>
  1. Then create a java class for you custom feature and extend that class from the org.adroitlogic.x.api.AbstractIntegrationFeature class

  2. Annotate your class from the org.adroitlogic.x.annotation.feature.IntegrationFeature annotation and fill the name and clazz parameters of the annotation. name parameter is just an identifier for your feature. clazz parameter should be the type of the Class that you are going to use your feature within the connectors and processors. If your custom feature class implements some interface and you want to use your feature using the type that interface, then clazz parameter should be the class type of the interface. If you want to use your feature directly using the implementation class type, then the clazz parameter should be the class type of your implementation class. As an example, if you have feature class with name CustomFeatureImpl which implements the CustomFeature interface, then if you want to use your feature within your processors and connectors from the type of CustomFeature, then your feature class would be like below,

     @IntegrationFeature(clazz = CustomFeature.class, name = "custom-feature")
     public class CustomFeatureImpl extends AbstractIntegrationFeature implements CustomFeature {

     }
  1. If you want to do some initialization tasks within your feature, you can override the init method and implement your initialization tasks there. For that method you will get the application context and you can access all required configuration beans and do your feature initialization.

    @Override
    public void init(ApplicationContext context) {
        // initialize your feature here
    }
  1. Now you have declared your custom class as a feature, then you can implement your feature functionalities. As per the above CustomFeature example, from your connectors and processors you can access your feature as below. If you have multiple features, you can access each other in the same way within your feature class as well.

    @FeatureRef
    private CustomFeature customFeature;
In this topic
In this topic
Contact Us