Class G2ConfigJNI

    • Constructor Summary

      Constructors 
      Constructor Description
      G2ConfigJNI()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addDataSource​(long configHandle, String inputJson, StringBuffer response)
      Adds a data source described by the specified JSON to the in-memory configuration associated with the specified config handle.
      void clearLastException()
      Clears the information about the last error the system received.
      int close​(long configHandle)
      Closes the in-memory configuration associated with the specified config handle and cleans up system resources.
      int create​(Result<Long> configHandle)
      Creates a new in-memory configuration using the default template and sets the specified Result parameter with the value of the configuration handle for working with it.
      int deleteDataSource​(long configHandle, String inputJson)
      Deletes the data source described by the specified JSON from the in-memory configuration associated with the specified config handle.
      int destroy()
      Uninitializes the G2 config API and cleans up system resources.
      String getLastException()
      Returns a string about the last error the system received.
      int getLastExceptionCode()
      Returns the exception code of the last error the system received.
      int init​(String moduleName, String iniParams, boolean verboseLogging)
      Initializes the G2 config API with the specified module name, init parameters and flag indicating verbose logging.
      int listDataSources​(long configHandle, StringBuffer response)
      Extracts the data sources from the in-memory configuration associated with the specified config handle and writes JSON text to the specified StringBuffer describing the data sources from the configuration.
      int load​(String jsonConfig, Result<Long> configHandle)
      Creates a new in-memory configuration using the specified JSON text and sets the specified Result parameter with the value of the configuration handle for working with it.
      int save​(long configHandle, StringBuffer response)
      Writes the JSON text for the configuration associated with the specified configuration handle to the specified StringBuffer.
    • Constructor Detail

      • G2ConfigJNI

        public G2ConfigJNI()
    • Method Detail

      • init

        public int init​(String moduleName,
                        String iniParams,
                        boolean verboseLogging)
        Initializes the G2 config API with the specified module name, init parameters and flag indicating verbose logging.
        Specified by:
        init in interface G2Config
        Parameters:
        moduleName - A short name given to this instance of the diagnostic object.
        iniParams - A JSON string containing configuration parameters.
        verboseLogging - Enable diagnostic logging which will print a massive amount of information to stdout.
        Returns:
        Zero (0) on success and non-zero on failure.
      • destroy

        public int destroy()
        Uninitializes the G2 config API and cleans up system resources.
        Specified by:
        destroy in interface G2Config
        Returns:
        Zero (0) on success and non-zero on failure.
      • create

        public int create​(Result<Long> configHandle)
        Creates a new in-memory configuration using the default template and sets the specified Result parameter with the value of the configuration handle for working with it.
        Specified by:
        create in interface G2Config
        Parameters:
        configHandle - The Result object on which to set the value of the configuration handle.
        Returns:
        Zero (0) on success and non-zero on failure.
      • load

        public int load​(String jsonConfig,
                        Result<Long> configHandle)
        Creates a new in-memory configuration using the specified JSON text and sets the specified Result parameter with the value of the configuration handle for working with it.
        Specified by:
        load in interface G2Config
        Parameters:
        jsonConfig - The JSON text for the config.
        configHandle - The Result object on which to set the value of the configuration handle.
        Returns:
        Zero (0) on success and non-zero on failure.
      • save

        public int save​(long configHandle,
                        StringBuffer response)
        Writes the JSON text for the configuration associated with the specified configuration handle to the specified StringBuffer.
        Specified by:
        save in interface G2Config
        Parameters:
        configHandle - The configuration handle to export the JSON text from.
        response - The StringBuffer to write the JSON text to.
        Returns:
        Zero (0) on success and non-zero on failure.
      • close

        public int close​(long configHandle)
        Closes the in-memory configuration associated with the specified config handle and cleans up system resources. After calling this method, the configuration handle can no longer be used and becomes invalid.
        Specified by:
        close in interface G2Config
        Parameters:
        configHandle - The config handle identifying the in-memory configuration to close.
        Returns:
        Zero (0) on success and non-zero on failure.
      • listDataSources

        public int listDataSources​(long configHandle,
                                   StringBuffer response)
        Extracts the data sources from the in-memory configuration associated with the specified config handle and writes JSON text to the specified StringBuffer describing the data sources from the configuration. The format of the JSON response is as follows:
         {
                "DATA_SOURCES": [
            {
                                "DSRC_ID": 1,
                                "DSRC_CODE": "TEST"
            },
            {
                                "DSRC_ID": 2,
                                "DSRC_CODE": "SEARCH"
            }
                ]
         }
         
        Specified by:
        listDataSources in interface G2Config
        Parameters:
        configHandle - The config handle identifying the in-memory configuration to close.
        response - The StringBuffer to write the JSON response to.
        Returns:
        Zero (0) on success and non-zero on failure.
      • addDataSource

        public int addDataSource​(long configHandle,
                                 String inputJson,
                                 StringBuffer response)
        Adds a data source described by the specified JSON to the in-memory configuration associated with the specified config handle. The response JSON is written to the specified StringBuffer. The input JSON has the following format:
           {
             "DSRC_CODE": "CUSTOMERS"
           }
         
        Optionally, you can specify the data source ID:
           {
             "DSRC_CODE": "CUSTOMERS",
             "DSRC_ID": 410
           }
         

        The response JSON provides the data source ID of the created data source, which is especially useful if the data source ID was not specified in the input:

           {
             "DSRC_ID": 410
           }
         
        Specified by:
        addDataSource in interface G2Config
        Parameters:
        configHandle - The config handle identifying the in-memory configuration to close.
        inputJson - The JSON text describing the data source to create.
        response - The StringBuffer to write the JSON response to.
        Returns:
        Zero (0) on success and non-zero on failure.
      • deleteDataSource

        public int deleteDataSource​(long configHandle,
                                    String inputJson)
        Deletes the data source described by the specified JSON from the in-memory configuration associated with the specified config handle. The input JSON has the following format:
           {
             "DSRC_CODE": "CUSTOMERS"
           }
         
        Specified by:
        deleteDataSource in interface G2Config
        Parameters:
        configHandle - The config handle identifying the in-memory configuration to close.
        inputJson - The JSON text describing the data source to delete.
        Returns:
        Zero (0) on success and non-zero on failure.
      • getLastException

        public String getLastException()
        Returns a string about the last error the system received. This is most commonly called after an API function returns an error code (non-zero or NULL)
        Specified by:
        getLastException in interface G2Fallible
        Returns:
        An error message
      • getLastExceptionCode

        public int getLastExceptionCode()
        Returns the exception code of the last error the system received. This is most commonly called after an API function returns an error code (non-zero or NULL)
        Specified by:
        getLastExceptionCode in interface G2Fallible
        Returns:
        An error code
      • clearLastException

        public void clearLastException()
        Clears the information about the last error the system received.
        Specified by:
        clearLastException in interface G2Fallible