5 Reference Implementation of Injector Service Using Tomcat

Introduction

For an external application to consume the message from the RIB's JMS on cloud, it has to host the Injector Service. Subscriber adapters in rib-ext makes a ReST call to Injector service to send the message to the external application. This document contains detailed information that can be used for implementing Rest inject service.

Note:

Tomcat is the only certified application server here.

Important Notes

  • Provided rib-injector-service war (inside RibExtConnectorServiceIm-plPak24.0.000_eng_ga.zip) runs on tomcat and has all the dependencies for rib in order to consume the message as individual application using RIB-EXT flow.

  • No container-managed transaction capability is required.

  • Authentication and authorization will be adjusted by the consuming application by editing web.xml to match their own requirements.

  • rib-injector-services-light-web war works as an standalone utility, this war is provided as a reference implementation for injector service. After the war is deployed, injector service will be made available as ReST End Point. Service contract WADL should be accessible at http://<app-host>:<port>/ rib-injector-services-web/resources/application.wadl.

  • This pluggable war can be added in to the external application deployable file (for example, ext-app.ear/lib). After deployment, Injector service should be available for access at the following:

    http://<external-app-host>:<port>/ rib-injector-services-web/resources/injector/inject

  • The customer can choose to write their own injector service implementation without using rib-injector-services war as long as they adhere to the service contract for Injector. Detailed information is documented in How to implement Injector Service (Service Contract) using ReST.

  • The external application has to write their own implementation logic for the injectors. However, an implementation jar (injector-sample-impl-24.0.000.jar) is provided for reference. Customers can write custom implementation logic inside injector-sample-impl-24.0.000.jar or can choose to implement on their own.

Step-by-step Guide for Testing rib-injector-service war on Tomcat

  1. Copy jersey jars into <tomcat>/lib folder. App server used here is tomcat which is a web container and doesn't have Jersey libraries packaged inside.

    cp <ribExtConnectorPak>/Rest-Injector/rib-injector-services-web/jersey-jars <tomcat>/lib

    Note:

    Jersey jars are packaged inside zip.

    Note:

    Jars packaged here are for reference purpose. You may use different versions of Jersey jars that may be compatible with external application.

    Note:

    application-messages-bo-24.0.000.jar is added with jersey zip in order to make this available inside <tomcat>/lib. This jar contains request/response business object and is needed for injector service to work.

  2. Deploy the rib-injector-services-light-web-24.0.000.war into tomcat by using the following command.

    Note:

    Change the name to remove the version number and the word light.

    cp rib-injector-services-light-web-24.0.000.war <tomcat>/webapps/rib-injector-services-web.war
  3. Start the application if not already started.

  4. Copy injector-sample-impl-24.0.000.jar inside <tomcat-apache>\webapps\rib-injector-services-web\WEB-INF\lib

  5. Test ping. Ping should return response as "Got hello from server.".

      curl -ivl4 --user tomcat:tomcat1 http://localhost:8080/rib-injector-services-web/resources/injector/ping
  6. Test inject call using a sample payload data. Create a file called app-message.data with the con-tent as follows.

    <ApplicationMessage xmlns="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1"><family>WH</family><type>WHCRE</type><payloadXml>&lt;WHDesc xmlns=&quot;http://www.oracle.com/retail/integration/base/bo/WHDesc/v1&quot;&lt;wh&gt;10&lt;/wh&gt;&lt;wh_name&gt;g&lt;/wh_name&gt;&lt;/WHDesc&gt;</payloadXml></ApplicationMessage>
  7. Call inject with the above (app-message.data) data. For a successful inject call, response should be "Inject successful." With the implementation jar provided here, message will get written to log.

    curl -ivl4 --user tomcat:tomcat1 -H 'Content-Type: application/xml' -d @app-message.data http://localhost:8080/rib-injector-services-web/resources/injector/inject

Approach for Writing Custom Implementation for Injectors

injector-sample-impl-24.0.000.jar is provided as reference implementation for injector service however customer can choose to write their own custom implementation logic. Steps listed here will help customer to write their own injector classes.

  1. To start with implementation, create a file with name injectors.xml. This file contains mapping for the injector implementation class, which will be looked for the given family and msgType. InjectorFactory looks for the injectors.xml, this should be present in classpath. Look at injec-tor-sample-impl-24.0.000.jar/retail/injectors.xml for reference.

    Sample Code: For Diffs family and DiffCre message type, injector implementation class is Diffs

    <injector_config>
    <family name="Diffs">
    <injector class="oracle.retail.rib.javaee.api.stubs.injector.file.impl.Diffs">
    <type>DIFFCRE</type>
    </injector>
    <injector class="oracle.retail.rib.javaee.api.stubs.injector.file.impl.Diffs">
    <type>DIFFDEL</type>
    </injector>
    <injector class="oracle.retail.rib.javaee.api.stubs.injector.file.impl.Diffs">
    <type>DIFFMOD</type>
    </injector>
    </family>
    ..
    .
    </injector_config>
    
  2. In the given jar, all the injectors class extends SampleInjector. This is the class where logic for handling the payload will be written. You can write your own implementation class and Diffs can extend that class.

    Sample Code:

    public final class Diffs extends SampleInjector{
    ..
    }
    
  3. Custom Implementation class should implement injector interface (contract for inject method).

    Sample code:

    import oracle.retail.rib.common.exception.RetailBusinessException;
    import oracle.retail.rib.common.exception.RetailSystemException;
    import com.oracle.retail.integration.payload.Payload;
    import com.retek.rib.binding.injector.Injector;
    public class SampleInjector implements Injector {
     
     
    // dummy impl for Injector
    public void inject(String type, Payload payload)
    throws RetailBusinessException, RetailSystemException {
    // Write logic here
    System.out.println("Inject executed successfully...");
    LOG.info("Inject executed successfully...");
    }
    }
    
  4. Copy custom implementation jar in-side <tomcat-apache>\webapps\rib-injector-services-web\WEB-INF\lib for it to work.