ISM Manual
  • Overview
  • Features
  • Components
  • Directory Structure
  • Startup/Shutdown
  • ISM Admin UI
    • Dashboard
    • Flow
    • Job
      • Schedule
    • Channel
      • AMQP
      • Mqtt
      • sFTP
    • Interface
      • System
      • Data Structure
      • Field Group
      • Field
    • Web Service
    • Utility
    • Admin
    • Result
  • Tasks
    • Control Task
      • Route
      • Split/Join
      • Mapping
    • FTP
      • FTP Input
      • FTP Output
      • FTP Transfer
    • DB
      • SQL Executor
      • SQL Batch Executor
    • File
      • File Input
      • File Output
      • File Validator
      • Record Extractor
    • Excel
      • Excel Reader
      • Excel Writer
    • Flow
      • Flow Execution
      • Wait Sub
    • Web Service
      • REST Client
      • Web service Client
    • PGP
      • Encrypt
      • Decrypt
    • Cloud
      • SharePoint
      • Amazon S3
      • Google Cloud Storage
    • Others
      • Email Sender
      • LDAP Client
      • Function
      • Script
      • Java Class
  • REST Service
  • Trouble Shooting
  • Logging Configuration
  • Implementing a Task
  • Custom Class
  • Frequently Asked Questions (FAQ)
    • What is XNARUM Integration Service Mastery (ISM)?
    • What is the purpose of XNARUM?
    • Can XNARUM be customized to specific integration requirements?
    • Is XNARUM scalable?
    • Does XNARUM provide support and maintenance?
Powered by GitBook
On this page
  • Input
  • Output
  • Example
  1. Tasks
  2. Others

Java Class

PreviousScriptNextREST Service

Last updated 1 year ago

This component executes a java class which has execute() method. The java class should be located under custom directory.

If the execution throws Throwable(Exception), that error is escalated to the caller and that execution is treated as failed. The return value of the method is added to the output data of this component.

Input

Attribute
Description

Class name

Class name with full path - ex) com.xnarum.custom.SampleJava

Timeout

Execution timeout in seconds.

Output

Attribute
Description

ResultValue

Return value from the method execution

Example

This example generates a new parameter and return to the caller.

package com.xnarum.custom;
                        
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
                        
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
                        
public class SampleJavaClassTask {
                        
    private static Logger logger = LoggerFactory.getLogger(SampleJavaClassTask.class);
    public Map execute(Map map, Properties props) {
                                
        logger.info("Received parameters map = {}, props = {}", map, props);
        HashMap newMap = new HashMap();
        newMap.put("Hello", "world");
        try {
            String timeout = props.getProperty("Timeout");
            Thread.sleep(Integer.parseInt(timeout)*1000);
        }catch( Exception ex ) {
            logger.error("Failed to sleep", ex);
        }
        return newMap; 
    }
}