Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pukkaone/jar-invoke
Dynamically load and invoke Java code in Elasticsearch
https://github.com/pukkaone/jar-invoke
elasticsearch elasticsearch-plugin
Last synced: 4 days ago
JSON representation
Dynamically load and invoke Java code in Elasticsearch
- Host: GitHub
- URL: https://github.com/pukkaone/jar-invoke
- Owner: pukkaone
- License: apache-2.0
- Created: 2017-09-06T00:10:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-26T14:16:54.000Z (over 5 years ago)
- Last Synced: 2023-06-30T21:42:08.306Z (over 1 year ago)
- Topics: elasticsearch, elasticsearch-plugin
- Language: Java
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE.txt
Awesome Lists containing this project
README
= Jar invoke Elasticsearch plugin {nbsp}image:https://maven-badges.herokuapp.com/maven-central/com.github.pukkaone/jar-invoke/badge.svg[Maven Central,link="https://maven-badges.herokuapp.com/maven-central/com.github.pukkaone/jar-invoke"]
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_ `')`
====[cols="1,3"]
|====
|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_ `')`
====[cols="1,3"]
|====
|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:
[source,java]
----
public static Object greet(Map variables, Map docLookup) {
----=== Load JAR file
Load JAR artifact from a Maven repository even if it was already loaded.
====
_module_ `= load('` _repositoryUri_ `', '` _jarCoordinates_ `')`
====[cols="1,3"]
|====
|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')
----