Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Execution event is a semantic event which indicates that a Java delegation action occurred in the process flow. This high-level event is generated when a business logic either needs to be executed or evaluated via Spring Bean. The class that implements the com.adeptia.indigo.api.custom.ScriptExecutor interface gets this ExecutionEvent object whenever a Java delegation occurs in the process flow.

You create a Custom plugin activity using Spring Bean approach and develop a class that provides a business logic as a part of implementation of pre-defined functional interface com.adeptia.indigo.api.custom.ScriptExecutor. This implementation is executed during process execution. The ScriptExecutor interface has a execute method that accepts executionEvent object as a argument.


The definition of ScriptExecutor interface is given below.

ScriptExecutor Interface
package com.adeptia.indigo.api.custom;

@FunctionalInterface
public interface ScriptExecutor {

	public void execute(ExecutionEvent executionEvent);

}

The definition of ExecutionEvent class is given below

ExecutionEvent.java
package com.adeptia.indigo.api.custom;

import java.io.InputStream;
import java.io.OutputStream;

import com.adeptia.indigo.logging.Logger;
import com.adeptia.indigo.services.Service;
import com.adeptia.indigo.services.transform.ScriptedService;
import com.adeptia.indigo.system.Context;
import com.adeptia.indigo.transaction.Transaction;

public class ExecutionEvent {

	private Service service;

	private Transaction transaction;

	private InputStream inputStream;

	private OutputStream outputStream;

	private Logger logger;

	private Exception exception;
	
	private Context context;

	public Service getService() {
		return service;
	}

	public ExecutionEvent setService(Service service) {
		this.service = service;
		return this;
	}

	public Transaction getTransaction() {
		return transaction;
	}

	public ExecutionEvent setTransaction(Transaction transaction) {
		this.transaction = transaction;
		return this;
	}

	public InputStream getInputStream() {
		return inputStream;
	}

	public ExecutionEvent setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
		return this;
	}

	public OutputStream getOutputStream() {
		return outputStream;
	}

	public ExecutionEvent setOutputStream(OutputStream outputStream) {
		this.outputStream = outputStream;
		return this;
	}

	public Logger getLogger() {
		return logger;
	}

	public ExecutionEvent setLogger(Logger logger) {
		this.logger = logger;
		return this;
	}

	public Exception getException() {
		return exception;
	}

	public ExecutionEvent setException(Exception exception) {
		this.exception = exception;
		return this;
	}
	
	public Context getContext() {
		return context;
	}
	
	public ExecutionEvent setContext(Context context) {
		this.context = context;
		return this;
	}

}


ExecutionEvent Class Description

The execution event class contains below fields:


Field NameField Description
1service

The service field is the instance of Custom Plugin Service. Internally Custom Plugin Service is called as ScriptedService so this object can be casted to ScriptedService object as below.

import com.adeptia.indigo.services.transform.ScriptedService;

ScriptedService service = (ScriptedService) executionEvent.getService();

2transactionDenotes the Transaction/Process Flow instance currently being executed
3inputStreamA java.io.InputStream object; the data stream received from previous activity (if "Consume Stream" property is enabled)
4loggerThe service logger object for logging; any statement logged with this object can be viewed under Process Flow Diagnostics logs
5exceptionA java.lang.Exception object; available only in case of exception handler scripts
6contextThe process flow context


Methods of ExecutionEvent class

The class contains the getter and setter methods for each field. The implementer classes has to deal with getter methods only to get the required objects and has nothing to do with setter methods. The anything set through setter methods will not reflect outside of execute method scope.

The below table lists the behavior of getter methods in case of different delegation situations.


MethodWhen delegation action occurred through a Service. Ex: Custom Plugin Service (Scripted Service)When delegation action occurred through an Action. Ex: Gateway ConditionWhen delegation action occurred through an Exception Script. Ex: Service Exception Script
1getServicereturns the Service Objectreturns nullreturns the Service Object
2getTransactionreturns nullreturns the underlying Transaction Objectreturns null
3getInputStreamreturns the inputStream object, the output generated by previously executed activityreturns nullreturns null
4getOutputStreamreturns nullreturns nullreturns null
5getLoggerreturns the service logger object.returns the service logger object.returns the service logger object.
6getExceptionreturns nullreturns nullreturns the exception object. The exception object that triggered the exception script execution.
7getContextreturn the underlying Process flow Contextreturn the underlying Process flow Contextreturn the underlying Process flow Context

Usage Examples when delegation action occurred through a Service. Example:- Custom Plugin Service (Scripted Service)


UsageExample
1Get Default Input StreamInputStream inputStream = executionEvent.getInputStream();
2Get Default Output stream

ScriptedService service = (ScriptedService) executionEvent.getService();

OutputStream defaultOutputStream = service.getOutputStream();

3Get Named Input StreamInputStream stream = service.getSourceStream(inputStreamName);
4Get Named Output Stream

ScriptedService service = (ScriptedService) executionEvent.getService();

OutputStream outputStream = service.getOutputStream(outputStreamName)

5Get Name of activity as defined in Process flow

ScriptedService scriptedService = (ScriptedService) executionEvent.getService();

String name = scriptedService .getName();

6Get Name of activity as defined in Custom Plugin definition

ScriptedService scriptedService = (ScriptedService) executionEvent.getService();

String entityName = scriptedService .getEntityName();

7Get Service Logger & log messages

ScriptedService scriptedService = (ScriptedService) executionEvent.getService();

Logger logger = service.getLogger();

logger.debug("Debug Statement");

logger.info("Info Statement");

logger.error("Error Statement");

8Get Character set encodingString encoding = service.getCharacterSetEncoding();
9Get Context and Context variables

Context context = executionEvent.getContext();
Object contextVar1 = context.get("contextvar1");
String contextVar2 = (String)context.get("contextvar2");

  • No labels