jar-invoke

Elasticsearch plugin to invoke Java code

License

License

GroupId

GroupId

com.github.pukkaone
ArtifactId

ArtifactId

jar-invoke
Last Version

Last Version

6.5.4-1
Release Date

Release Date

Type

Type

zip
Description

Description

jar-invoke
Elasticsearch plugin to invoke Java code
Project URL

Project URL

https://github.com/pukkaone/jar-invoke
Source Code Management

Source Code Management

https://github.com/pukkaone/jar-invoke

Download jar-invoke

Dependencies

compile (3)

Group / Artifact Type Version
org.antlr : antlr4-runtime jar 4.7
org.jboss.shrinkwrap.resolver : shrinkwrap-resolver-impl-maven jar 2.2.6
org.glassfish.jaxb : jaxb-runtime jar 2.4.0-b180830.0438

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.9.0

Project Modules

There are no modules declared in this project.

Jar invoke Elasticsearch plugin  Maven Central

To execute custom code in Elasticsearch, you can write an Elasticsearch plugin. However, a plugin introduces an operational complication. To deploy a new version of an Elasticsearch plugin, you need to restart every node in the Elasticsearch cluster where the plugin is installed. This plugin loads Java code at runtime, so you can deploy new code without needing to restart the Elasticsearch nodes.

SECURITY WARNING

This plugin allows scripts to download and execute arbitrary code from the Internet. Installing it will make your information security officer cry.

Install

Install the plugin using the command:

elasticsearch-plugin install com.github.pukkaone:jar-invoke:VERSION

Usage

This plugin adds a script language named jar-invoke which implements statements to load and invoke Java code.

Require JAR file

Load JAR artifact from a Maven repository if not already loaded.

module = require(' repositoryUri ', ' jarCoordinates ')

Parameter Description

module

name to assign to module

repositoryUri

Maven repository URI

jarCoordinates

Maven artifact coordinates, in format groupId:artifactId:version

Invoke Java static method

Invoke static method of a Java class in a loaded JAR file.

module .invoke(' className ', ' methodName ')

Parameter Description

module

name of loaded module

className

Java class name

methodName

Java method name

Example:
hello = require('http://repository.example.com/', 'com.example:hello:1.0')
hello.invoke('com.example.Hello', 'greet')

The Java method must have accept two Map parameters:

public static Object greet(Map<String, Object> variables, Map<String, ScriptDocValues> docLookup) {

Load JAR file

Load JAR artifact from a Maven repository even if it was already loaded.

module = load(' repositoryUri ', ' jarCoordinates ')

Parameter Description

module

name to assign to module

repositoryUri

Maven repository URI

jarCoordinates

Maven artifact coordinates, in format groupId:artifactId:version

Example:
hello = load('http://repository.example.com/', 'com.example:hello:1.0')

Versions

Version
6.5.4-1
6.5.4-0
6.3.2-1
6.3.2-0
6.3.1-0
6.3.0-0
6.2.4-0
6.2.3-0
6.2.2-0
6.2.1-0
6.1.3-0
6.1.2-0
6.1.1-0
2.4.5-2
2.4.5-1
2.4.5-0