本文整理了Java中groovy.lang.Binding.setVariable()
方法的一些代码示例,展示了Binding.setVariable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.setVariable()
方法的具体详情如下:
包路径:groovy.lang.Binding
类名称:Binding
方法名:setVariable
[英]Sets the value of the given variable
[中]设置给定变量的值
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* A helper constructor used in main(String[]) method calls
*
* @param args are the command line arguments from a main()
*/
public Binding(String[] args) {
this();
setVariable("args", args);
}
代码示例来源:origin: org.codehaus.groovy/groovy
private void doSetVariable(String name, Object value) {
super.setVariable(name, value);
}
代码示例来源:origin: org.codehaus.groovy/groovy
public void setVariable(String name, Object value) {
context.setVariable(name, value);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void setVariable(String name, Object value) {
if (currentBeanDefinition != null) {
applyPropertyToBeanDefinition(name, value);
}
else {
super.setVariable(name, value);
}
}
};
代码示例来源:origin: jenkinsci/jenkins
/**
* Loads a set of given beans
* @param resources The resources to load
* @throws IOException
*/
public void loadBeans(Resource[] resources) throws IOException {
Closure beans = new Closure(this){
@Override
public Object call(Object... args) {
return beans((Closure)args[0]);
}
};
Binding b = new Binding();
b.setVariable("beans", beans);
GroovyShell shell = classLoader != null ? new GroovyShell(classLoader,b) : new GroovyShell(b);
for (Resource resource : resources) {
shell.evaluate(new InputStreamReader(resource.getInputStream()));
}
}
代码示例来源:origin: org.springframework/spring-beans
@Override
public void setVariable(String name, Object value) {
if (currentBeanDefinition != null) {
applyPropertyToBeanDefinition(name, value);
}
else {
super.setVariable(name, value);
}
}
};
代码示例来源:origin: jenkinsci/jenkins
/**
* Filter to run for the LegacySecurityRealm is the
* ChainServletFilter legacy from /WEB-INF/security/SecurityFilters.groovy.
*/
@Override
public Filter createFilter(FilterConfig filterConfig) {
Binding binding = new Binding();
SecurityComponents sc = this.createSecurityComponents();
binding.setVariable("securityComponents", sc);
binding.setVariable("securityRealm",this);
BeanBuilder builder = new BeanBuilder();
builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"),binding);
WebApplicationContext context = builder.createApplicationContext();
return (Filter) context.getBean("legacy");
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Overloaded to make variables appear as bean properties or via the subscript operator
*/
public void setProperty(String property, Object newValue) {
/** @todo we should check if we have the property with the metaClass instead of try/catch */
try {
super.setProperty(property, newValue);
}
catch (MissingPropertyException e) {
setVariable(property, newValue);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
public void set(Object value) {
script.getBinding().setVariable(variable, value);
}
}
代码示例来源:origin: apache/groovy
private static void retrieveBindingVars(ScriptEngine self, Binding binding) {
Set<Map.Entry<String, Object>> returnVars = self.getBindings(ScriptContext.ENGINE_SCOPE).entrySet();
for (Map.Entry<String, Object> me : returnVars) {
binding.setVariable(me.getKey(), me.getValue());
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Creates {@link Filter} that all the incoming HTTP requests will go through
* for authentication.
*
* <p>
* The default implementation uses {@link #getSecurityComponents()} and builds
* a standard filter chain from /WEB-INF/security/SecurityFilters.groovy.
* But subclasses can override this to completely change the filter sequence.
*
* <p>
* For other plugins that want to contribute {@link Filter}, see
* {@link PluginServletFilter}.
*
* @since 1.271
*/
public Filter createFilter(FilterConfig filterConfig) {
LOGGER.entering(SecurityRealm.class.getName(), "createFilter");
Binding binding = new Binding();
SecurityComponents sc = getSecurityComponents();
binding.setVariable("securityComponents", sc);
binding.setVariable("securityRealm",this);
BeanBuilder builder = new BeanBuilder();
builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"),binding);
WebApplicationContext context = builder.createApplicationContext();
return (Filter) context.getBean("filter");
}
代码示例来源:origin: org.codehaus.groovy/groovy
public void setProperty(String property, Object newValue) {
if ("binding".equals(property))
setBinding((Binding) newValue);
else if("metaClass".equals(property))
setMetaClass((MetaClass)newValue);
else
binding.setVariable(property, newValue);
}
代码示例来源:origin: org.codehaus.groovy/groovy
public static void processConfigScripts(List<String> scripts, CompilerConfiguration conf) throws IOException {
if (scripts.isEmpty()) return;
Binding binding = new Binding();
binding.setVariable("configuration", conf);
CompilerConfiguration configuratorConfig = new CompilerConfiguration();
ImportCustomizer customizer = new ImportCustomizer();
customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
configuratorConfig.addCompilationCustomizers(customizer);
GroovyShell shell = new GroovyShell(binding, configuratorConfig);
for (String script : scripts) {
shell.evaluate(new File(script));
}
}
代码示例来源:origin: groovy/groovy-core
@Override
public void run() {
try {
Binding b = new Binding();
b.setVariable("number", count);
result = (String) this.gse.run(script, b);
} catch (Throwable t) {
throw new RuntimeException("problem running script", t);
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public SecurityComponents createSecurityComponents() {
Binding binding = new Binding();
binding.setVariable("authenticator", new Authenticator());
BeanBuilder builder = new BeanBuilder();
builder.parse(Jenkins.getInstance().servletContext.getResourceAsStream("/WEB-INF/security/AbstractPasswordBasedSecurityRealm.groovy"),binding);
WebApplicationContext context = builder.createApplicationContext();
return new SecurityComponents(
findBean(AuthenticationManager.class, context),
new ImpersonatingUserDetailsService(this));
}
代码示例来源:origin: spring-projects/spring-framework
binding.setVariable("beans", beans);
代码示例来源:origin: twosigma/beakerx
private Object runScript(Script script) {
groovyEvaluator.getScriptBinding().setVariable(Evaluator.BEAKER_VARIABLE_NAME, groovyEvaluator.getBeakerX());
script.setBinding(groovyEvaluator.getScriptBinding());
return script.run();
}
代码示例来源:origin: groovy/groovy-core
public void run()
{
final long id = Thread.currentThread().getId();
// run the script numIter times
for (int i = 0; i < numIter; i++)
{
Builder builder = new Builder();
Binding binding = new Binding();
binding.setVariable("builder", builder);
script = InvokerHelper.createScript(scriptClass, binding);
script.run();
}
latch.countDown();
}
}
代码示例来源:origin: groovy/groovy-core
public void testExecuteScriptWithContext() {
Binding context = new Binding();
context.setVariable("test", new PropertyHolder());
GroovyShell shell = new GroovyShell(context);
try {
Object result = shell.evaluate(script2, "Test.groovy");
assertEquals(new Integer(2), result);
}
catch (Exception e) {
fail(e.toString());
}
}
代码示例来源:origin: groovy/groovy-core
@Override
public void setVariable(String name, Object value) {
lazyInit();
validateArgs(name, "Can't bind variable to");
excludeReservedName(name, "out");
excludeReservedName(name, "sout");
excludeReservedName(name, "html");
excludeReservedName(name, "json");
excludeReservedName(name, "forward");
excludeReservedName(name, "include");
excludeReservedName(name, "redirect");
super.setVariable(name, value);
}
内容来源于网络,如有侵权,请联系作者删除!