Go to primary content
Oracle® Retail Integration Cloud Service Implementation Guide
Release 19.1.000
F31983-04
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

A 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 certified application server here but provided injector service war should work on any standard app server.

Important Notes

  • Provided rib-injector-service war (inside RibExtConnectorServiceIm-plPak19.1.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 Chapter 16, "Integration with External Applications".

  • The external application has to write their own implementation logic for the injectors. However, an implementation jar (injector-sample-impl-19.1.000.jar) is provided for reference. Customers can write custom implementation logic inside injector-sample-impl-19.1.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. In case of full stack Java EE app server such as weblogic this step is not required.

    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-19.1.000.jar is added with jersey zip in order to make this available inside <tomcat>/lib. This jar contains request/response business object and needed for injector service to work.

  2. Edit <tomcat>/conf/tomcat-users.xml to add the IntegrationRole and users. Only the users with 'IntegrationRole' has access to inject service.

    <role rolename="IntegrationRole"/>
        <user password="tomcat1" roles="manager-script,admin,IntegrationRole" username="tomcat"/>
    
  3. Deploy the rib-injector-services-light-web-19.1.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-19.1.000.war <tomcat>/webapps/rib-injector-services-web.war
    
  4. Start the application if not already started.

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

  6. 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
    
  7. Test inject call using a sample payload data. Create a file called app-message.data with the content 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>
    
  8. 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 for reference, message will get written to log file.

    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-19.1.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 map-ping 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 injector-sample-impl-19.1.000.jar/retail/injectors.xml for reference.

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

    Injectors.xml:

    <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 your implementation here
    System.out.println("Inject executed successfully...");
    }
    }
    
  4. Copy custom implementation jar in-side <tomcat-apache>\webapps\rib-injector-services-web\WEB-INF\lib for it to work.