Custom binding


A custom binding is a Java class that will be instantiated and bound into the the Groovy script runtime environment.

Custom bindings are identified by their root package and class level annotations. These annotated classes are found automatically by scanning the classpath.

When a class is customer and/or implementation specific, it is typically installed as a JAR or CLASS file placed in ${B2BOX.DATA}/lib. Care should be taken to ensure any dependent classes already exist within the b2box distribution or are also available in a folder on the classpath.

All classes with a root package of com.amalto.b2box.groovy will be scanned for the annotation @B2GroovyBinding. Each class identified will be instantiated using an expected no-args constructor and bound into the script environment using the name specified in the annotation.


package com.amalto.b2box.groovy.mybindings;

import com.amalto.b2box.groovy.binding.B2GroovyBinding;

@B2GroovyBinding( name="hello" )
public class HelloWorld {

    public HelloWorld(){
        // My no-args constructor

    public String Say(){
        return "Hello World";

Once this class is available on the Platform 6 classpath you can use the following from a Groovy script:

println hello.Say()