Standalone usage

Maven Artifact

Usage example

1
2
3
4
5
6
7
8
9
10
11
12
13
14

KevScriptEnginekevs=newKevScriptEngine(newKevoreeConfig.Builder().useDefault().build());try{finalStringscript="add node: JavaNode";finalKevoreeFactoryfactory=newDefaultKevoreeFactory();// a factory to create modelsfinalContainerRootmodel=factory.createContainerRoot();// create an empty modelfactory.root(model);// ignore this but make sure you do it :pkevs.execute(script,model);// in Java, the KevScript engine mutates the given model directlyassert(model.getNodes().get(0).getName().equals("node"));}catch(KevScriptExceptionex){// something went wrong while executing the scriptex.printStackTrace();}

NPM module

1

npm i kevoree-kevscript -S

You will also need tiny-conf & kevoree-commons

Usage example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

constconfig=require('tiny-conf');constKevScript=require('kevoree-kevscript');constloggerFactory=require('kevoree-logger');constassert=require('assert');// kevoree-kevscript uses tiny-conf under the hood to retrieve// its registry settings, so we have to define them before instantiationconfig.set('registry',{host:'registry.kevoree.org',port:443,ssl:true});constkevs=newKevScript(loggerFactory.create('KevScript'));constscript='add node: JavascriptNode';kevs.parse(script,(err,model)=>{if(err){console.error('Something went wrong while executing script',err.message);}else{assert.equal(model.nodes.array[0].name,'node');}});