The data payloads of the request and response messages that are sent or received by the Java client are in the form of a collection of Java objects.

You need to create a class for each Vocabulary entity that is used by the rules you want to call. We will create get and set methods within each class file. Then we will export the code to a JAR file, and place it in a location where it can be accessed by Corticon Server at run-time.

Switch to the Java Perspective in Corticon Studio

  1. Click on the Java option in the top right of your Corticon Studio screen.
    media/image4.png
    If you have not previously opened this perpective, choose:
    media/image5.png
  2. And then choose Java:
    media/image6.png

Create Java ‘get’ and ‘set’ methods in a library

You need to create a class for each Vocabulary entity that will be used by the rules you want to call. In this tutorial, we will create a class for just one entity – Cargo.

  1. Click File > New > Java Project.
  2. Name the project cargoLibrary.
  3. Accept all the default values, and click Finish.
  4. In the Package Explorer, expand cargoLibrary, right-click on src, and then choose New > Package. Name the package cargoLibrary.
  5. Right-click on the cargoLibrary package, and then choose New > Class. Name the package Cargo. (The class name and the entity name must match exactly, and they are case-sensitive.)The java editor opens, ready for your text.
  6. Declare the entity’s attributes as variables with the appropriate data type in get and set methods. (The variable and the attribute names must match exactly, and they are case-sensitive, as shown:
    package cargoLibrary;
    public class Cargo {
      public String container;
      public String manifestNumber;
      public Boolean needsRefrigeration;
      public long volume;
      public long weight;
    
      public String getContainer() {
        return container;
      }
    
      public void setContainer(String container) {
        this.container = container;
      }
    
      public String getManifestNumber() {
        return manifestNumber;
      }
    
      public void setManifestNumber(String manifestNumber) {
        this.manifestNumber = manifestNumber;
      }
      
      public Boolean getNeedsRefrigeration() {
        return needsRefrigeration;
      }
     
      public void setNeedsRefrigeration(Boolean needsRefrigeration) {
        this.needsRefrigeration = needsRefrigeration;
      }
    
      public long getVolume() {
        return volume;
      }
    
      public void setVolume(long volume) {
        this.volume = volume;
      }
     
      public long getWeight() {
        return weight;
      }
    
      public void setWeight(long weight) {
        this.weight = weight;
      }
    
    }
  7. Save the file.
  8. Select the project cargoLibrary.
  9. Choose File > Export, and then Java > JAR file.
  10. Select cargoLibrary and its related files
  11. Name the JAR file Cargo.
  12. Save the JAR file at a temporary location. It is a good idea to save it in the project.