Skip to content

Instantly share code, notes, and snippets.

@theopendle
Created April 7, 2021 12:17
Show Gist options
  • Save theopendle/8d652f63ff6677fab0ed78932128897d to your computer and use it in GitHub Desktop.
Save theopendle/8d652f63ff6677fab0ed78932128897d to your computer and use it in GitHub Desktop.
import com.icfolson.aem.groovy.console.api.BindingExtensionProvider;
import com.icfolson.aem.groovy.console.api.BindingVariable;
import com.icfolson.aem.groovy.console.api.context.ScriptContext;
import org.osgi.service.component.annotations.Component;
import java.util.HashMap;
import java.util.Map;
// Tells the Groovy Console bundle to use this class as an extension to the default Binding
@Component(service = BindingExtensionProvider.class, immediate = true)
// Implementing this class gives us the method signature below
public class CustomBindingExtension implements BindingExtensionProvider {
@Override
public Map<String, BindingVariable> getBindingVariables(final ScriptContext scriptContext) {
// Simply return a map representing each new binding variable you wish to add, in this case just one
final HashMap<String, BindingVariable> bindingVariables = new HashMap<>();
bindingVariables.put("importer", new BindingVariable(new Importer()));
return bindingVariables;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment