Simple Extension

This extension is very simple, as it only utilizes an extension XML file. It does not contain any Java source code. The extension sets up the canonical data structure for your data processing.

Context

The XML that defines your data structures is the minimum requirement for a Data Hub extension. Package your extension into a JAR file, and place it in the Data Hub class path. Follow the steps here to create and load an extension jar file for your canonical data structure.

Procedure

  1. Create a folder named META-INF.
  2. Create your extension XML file in the META-INF directory and name it canonical-example-datahub-extension.xml. The following provides an example, but you may write your own, with as many items and attributes as you wish.
    <extension xmlns="http://www.hybris.com/schema/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://www.hybris.com/schema/ datahub-metadata-schema-1.0.0.xsd" name="canonical-example-datahub-extension.xml">
     
        <canonicalItems>
            <item>
                <type>CanonicalCustomer</type>
                <description>Canonical representation of the customer</description>
                <status />
                <!-- defaults to ACTIVE -->
                <attributes>
                    <attribute>
                        <name>customerId</name>
                        <model>
                            <localizable>false</localizable>
                            <collection>false</collection>
                            <type>String</type>
                            <primaryKey>true</primaryKey>
                        </model>
                    </attribute>
                    <attribute>
                        <name>name</name>
                        <model>
                            <localizable>false</localizable>
                            <collection>false</collection>
                            <type>String</type>
                            <primaryKey>false</primaryKey>
                        </model>
                    </attribute>
    		    </attributes>
            </item>
    	</canonicalItems>
    </extension>
  3. Data Hub extension files are named as follows: your_extension_name-datahub-extension.xml. This example extension is named canonical-example.
  4. cd into the directory where the META-INF folder is stored, and issue the following command from the command prompt: jar -cf canonicalExample.jar META-INF. Use the ls command to get a directory listing to ensure that the file was successfully created.
  5. Copy the jar file to /opt/datahub/extensions folder.

    Your extension loads whenever Data Hub starts.

  6. Start Data Hub by navigating to the <TOMCAT_HOME>/bin directory and issuing the command ./datahubserver.sh. If Data Hub is already running, stop it first with Ctrl-C.

    You should see the following two lines in the output from Data Hub when it starts up. This output appears towards the end of the startup cycle, and indicates that your extension is being loaded. Please verify that you see these log statements for your extension when the Data Hub starts up.

    016-06-29 16:58:45,412 [INFO] [c.h.d.e.l.i.DefaultExtensionLoaderService] Importing extension resource canonical-example-datahub-extension
    2016-06-29 16:58:45,413 [INFO] [c.h.d.e.l.i.DefaultExtensionImportService] Loading extension canonical-example-datahub-extension

    You should then see output similar to the following, as Data Hub creates the canonical items and attributes from your data model. Please verify that you see these log statements for your extension when the Data Hub starts up.

    2016-06-29 16:58:45,413 [DEBUG] [c.h.d.e.l.i.DefaultExtensionImportService] Loading canonical item Item{type='CanonicalCustomer', description='Canonical representation of the customer', status=ACTIVE, attributes=Attributes{attributeList=[Attribute{name='customerId', model=Model{localizable=false, collection=false, type='String', primaryKey=true, secured=false}, transformations=null}, Attribute{name='name', model=Model{localizable=false, collection=false, type='String', primaryKey=false, secured=false}, transformations=null}]}}
    2016-06-29 16:58:45,512 [DEBUG] [c.h.d.e.l.i.DefaultExtensionImportService] Loading canonical attribute Attribute{name='customerId', model=Model{localizable=false, collection=false, type='String', primaryKey=true, secured=false}, transformations=null}
    2016-06-29 16:58:47,949 [DEBUG] [c.h.d.e.l.i.DefaultExtensionImportService] Loading canonical attribute Attribute{name='name', model=Model{localizable=false, collection=false, type='String', primaryKey=false, secured=false}, transformations=null}