Codota Logo
Script.getBinding
Code IndexAdd Codota to your IDE (free)

How to use
getBinding
method
in
groovy.lang.Script

Best Java code snippets using groovy.lang.Script.getBinding (Showing top 20 results out of 315)

  • Common ways to obtain Script
private void myMethod () {
Script s =
  • Codota IconGroovyShell shell;String scriptText;shell.parse(scriptText)
  • Codota IconClass scriptClass;(Script) scriptClass.newInstance()
  • Codota IconClass scriptClass;Binding context;InvokerHelper.createScript(scriptClass, context)
  • Smart code suggestions by Codota
}
origin: org.codehaus.groovy/groovy

  public void set(Object value) {
    script.getBinding().setVariable(variable, value);
  }
}
origin: org.codehaus.groovy/groovy

public Object get() {
  return script.getBinding().getVariable(variable);
}
origin: org.codehaus.groovy/groovy

private Object invokePropertyOrMissing(Object object, String methodName, Object[] originalArguments, boolean fromInsideClass, boolean isCallToSuper) {
  // if no method was found, try to find a closure defined as a field of the class and run it
  Object value = null;
  final MetaProperty metaProperty = this.getMetaProperty(methodName, false);
  if (metaProperty != null)
   value = metaProperty.getProperty(object);
  else {
    if (object instanceof Map)
     value = ((Map)object).get(methodName);
  }
  if (value instanceof Closure) {  // This test ensures that value != this If you ever change this ensure that value != this
    Closure closure = (Closure) value;
    MetaClass delegateMetaClass = closure.getMetaClass();
    return delegateMetaClass.invokeMethod(closure.getClass(), closure, CLOSURE_DO_CALL_METHOD, originalArguments, false, fromInsideClass);
  }
  if (object instanceof Script) {
    Object bindingVar = ((Script) object).getBinding().getVariables().get(methodName);
    if (bindingVar != null) {
      MetaClass bindingVarMC = ((MetaClassRegistryImpl) registry).getMetaClass(bindingVar);
      return bindingVarMC.invokeMethod(bindingVar, CLOSURE_CALL_METHOD, originalArguments);
    }
  }
  return invokeMissingMethod(object, methodName, originalArguments, null, isCallToSuper);
}
origin: groovy/groovy-core

public void testCreateScriptWithNullClass() {
  Script script = InvokerHelper.createScript(null, new Binding(bindingVariables));
  assertEquals(bindingVariables, script.getBinding().getVariables());
}
origin: apache/nifi

Map bindings = script.getBinding().getVariables();
origin: groovy/groovy-core

  public void testCreateScriptWithScriptClass() {
    GroovyClassLoader classLoader = new GroovyClassLoader();
    String controlProperty = "text";
    String controlValue = "I am a script";
    String code = controlProperty + " = '" + controlValue + "'";
    GroovyCodeSource codeSource = new GroovyCodeSource(code, "testscript", "/groovy/shell");
    Class scriptClass = classLoader.parseClass(codeSource, false);
    Script script = InvokerHelper.createScript(scriptClass, new Binding(bindingVariables));
    assertEquals(bindingVariables, script.getBinding().getVariables());
    script.run();
    assertEquals(controlValue, script.getProperty(controlProperty));
  }
}
origin: palantir/atlasdb

/**
 * Note on the System.setSecurityManager call:
 *
 * The main method of the Groovysh class initializes a SecurityManager to
 * prevent the use of System.exit. The SecurityManager is not actually
 * necessary for Groovysh, so this change removes it to allow JDBC
 * access (removes the need for users to create an explicit ~/.java.policy
 * file).
 */
public static void callback(Script script, boolean mutationsEnabled) throws CompilationFailedException, IOException {
  System.setSecurityManager(null);
  setupBinding(script.getBinding(), mutationsEnabled);
}
origin: spring-projects/spring-integration

public void customize(GroovyObject goo) {
  Assert.state(goo instanceof Script, "Expected a Script");
  if (this.variables != null) {
    Binding binding = ((Script) goo).getBinding();
    for (Map.Entry<String, ?> entry : this.variables.entrySet()) {
      binding.setVariable(entry.getKey(), entry.getValue());
    }
  }
  if (this.customizer != null) {
    this.customizer.customize(goo);
  }
}
origin: org.elasticsearch/elasticsearch-lang-groovy

@SuppressWarnings({"unchecked"})
@Override
public void setNextScore(float score) {
  script.getBinding().getVariables().put("_score", score);
}
origin: org.elasticsearch/elasticsearch-lang-groovy

@SuppressWarnings({"unchecked"})
@Override
public void setNextVar(String name, Object value) {
  script.getBinding().getVariables().put(name, value);
}
origin: org.elasticsearch/elasticsearch-lang-groovy

@SuppressWarnings({"unchecked"})
@Override
public void setNextVar(String name, Object value) {
  script.getBinding().getVariables().put(name, value);
}
origin: org.codehaus.groovy/groovy-jdk14

  public void set(Object value) {
    script.getBinding().setVariable(variable, value);
  }
}
origin: org.kohsuke.droovy/groovy

  public void set(Object value) {
    script.getBinding().setVariable(variable, value);
  }
}
origin: org.codehaus.groovy/groovy-all-minimal

  public void set(Object value) {
    script.getBinding().setVariable(variable, value);
  }
}
origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

  public void set(Object value) {
    script.getBinding().setVariable(variable, value);
  }
}
origin: com.palantir.atlasdb/atlasdb-console

/**
 * Note on the System.setSecurityManager call:
 *
 * The main method of the Groovysh class initializes a SecurityManager to
 * prevent the use of System.exit. The SecurityManager is not actually
 * necessary for Groovysh, so this change removes it to allow JDBC
 * access (removes the need for users to create an explicit ~/.java.policy
 * file).
 */
public static void callback(Script script, boolean mutationsEnabled) throws CompilationFailedException, IOException {
  System.setSecurityManager(null);
  setupBinding(script.getBinding(), mutationsEnabled);
}
origin: org.springframework.integration/spring-integration-groovy

public void customize(GroovyObject goo) {
  Assert.state(goo instanceof Script, "Expected a Script");
  if (this.variables != null) {
    Binding binding = ((Script) goo).getBinding();
    for (Map.Entry<String, ?> entry : this.variables.entrySet()) {
      binding.setVariable(entry.getKey(), entry.getValue());
    }
  }
  if (this.customizer != null) {
    this.customizer.customize(goo);
  }
}
origin: com.disney.groovity/groovity-core

public void startRun(final Script script){
  final Binding oldBinding = THREAD_BINDING.get();
  final Binding scriptBinding = script.getBinding();
  if(oldBinding != scriptBinding){
    if(oldBinding!=null){
      scriptBinding.setVariable(THREAD_BINDING_PREVIOUS, oldBinding);
    }
    scriptBinding.setVariable(THREAD_BINDING_OWNER, script);
    THREAD_BINDING.set(scriptBinding);
  }
}

origin: disney/groovity

public void startRun(final Script script){
  final Binding oldBinding = THREAD_BINDING.get();
  final Binding scriptBinding = script.getBinding();
  if(oldBinding != scriptBinding){
    if(oldBinding!=null){
      scriptBinding.setVariable(THREAD_BINDING_PREVIOUS, oldBinding);
    }
    scriptBinding.setVariable(THREAD_BINDING_OWNER, script);
    THREAD_BINDING.set(scriptBinding);
  }
}

origin: org.elasticsearch.module/lang-groovy

@SuppressWarnings("unchecked")
public GroovyScript(CompiledScript compiledScript, Script script, @Nullable LeafSearchLookup lookup, ESLogger logger) {
  this.compiledScript = compiledScript;
  this.script = script;
  this.lookup = lookup;
  this.logger = logger;
  this.variables = script.getBinding().getVariables();
}
groovy.langScriptgetBinding

Popular methods of Script

  • run
    A helper method to allow scripts to be run taking command line arguments
  • setBinding
  • getProperty
  • setProperty
  • invokeMethod
    Invoke a method (or closure in the binding) defined.
  • getMetaClass
  • setMetaClass
  • evaluate
    A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (Timer)
  • getApplicationContext (Context)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • JList (javax.swing)
  • JOptionPane (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now