本文整理了Java中groovy.lang.Binding.getVariable()
方法的一些代码示例,展示了Binding.getVariable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binding.getVariable()
方法的具体详情如下:
包路径:groovy.lang.Binding
类名称:Binding
方法名:getVariable
暂无
代码示例来源:origin: org.codehaus.groovy/groovy
private Object doGetVariable(String name) {
return super.getVariable(name);
}
代码示例来源:origin: groovy/groovy-core
public void include(String path) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) super.getVariable("request");
HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
RequestDispatcher dispatcher = request.getRequestDispatcher(path);
dispatcher.include(request, response);
}
代码示例来源:origin: groovy/groovy-core
public void forward(String path) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) super.getVariable("request");
HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
RequestDispatcher dispatcher = request.getRequestDispatcher(path);
dispatcher.forward(request, response);
}
代码示例来源:origin: groovy/groovy-core
public void redirect(String location) throws IOException {
HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
response.sendRedirect(location);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
public Object getProperty(String property) {
try {
return binding.getVariable(property);
} catch (MissingPropertyException e) {
return super.getProperty(property);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Overloaded to make variables appear as bean properties or via the subscript operator
*/
public Object getProperty(String property) {
/** @todo we should check if we have the property with the metaClass instead of try/catch */
try {
return super.getProperty(property);
}
catch (MissingPropertyException e) {
return getVariable(property);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
public Object get() {
return script.getBinding().getVariable(variable);
}
代码示例来源:origin: groovy/groovy-core
/**
* @return a writer, an output stream, a markup builder or another requested object
*/
@Override
public Object getVariable(String name) {
lazyInit();
validateArgs(name, "No variable with");
return super.getVariable(name);
}
代码示例来源:origin: spring-projects/spring-framework
Binding binding = getBinding();
if (binding != null && binding.hasVariable(name)) {
return binding.getVariable(name);
代码示例来源:origin: groovy/groovy-core
public void testScriptWithDerivedBaseClass() throws Exception {
Binding context = new Binding();
CompilerConfiguration config = new CompilerConfiguration();
config.setScriptBaseClass(DerivedScript.class.getName());
GroovyShell shell = new GroovyShell(context, config);
Object result = shell.evaluate("x = 'abc'; doSomething(cheese)");
assertEquals("I like Cheddar", result);
assertEquals("abc", context.getVariable("x"));
}
代码示例来源:origin: org.springframework/spring-beans
Binding binding = getBinding();
if (binding != null && binding.hasVariable(name)) {
return binding.getVariable(name);
代码示例来源:origin: groovy/groovy-core
private void lazyInit() {
if (initialized) return;
initialized = true;
HttpServletResponse response = (HttpServletResponse) super.getVariable("response");
ServletOutput output = new ServletOutput(response);
super.setVariable("out", output.getWriter());
super.setVariable("sout", output.getOutputStream());
MarkupBuilder builder = new MarkupBuilder(output.getWriter());
builder.setExpandEmptyElements(true);
super.setVariable("html", builder);
try {
Class jsonBuilderClass = this.getClass().getClassLoader().loadClass("groovy.json.StreamingJsonBuilder");
Constructor writerConstructor = jsonBuilderClass.getConstructor(Writer.class);
super.setVariable("json", writerConstructor.newInstance(output.getWriter()));
} catch (Throwable t) {
t.printStackTrace();
}
// bind forward method
MethodClosure c = new MethodClosure(this, "forward");
super.setVariable("forward", c);
// bind include method
c = new MethodClosure(this, "include");
super.setVariable("include", c);
// bind redirect method
c = new MethodClosure(this, "redirect");
super.setVariable("redirect", c);
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public Object getVariable(String name) {
try {
return super.getVariable(name);
}
catch (MissingPropertyException e) {
// ignore
}
return defaultValue;
}
};
代码示例来源:origin: crashub/crash
private String eval(ShellSession session, String name, String def) {
try {
GroovyShell shell = getGroovyShell(session);
Object ret = shell.getContext().getVariable(name);
if (ret instanceof Closure) {
log.log(Level.FINEST, "Invoking " + name + " closure");
Closure c = (Closure)ret;
ret = c.call();
} else if (ret == null) {
log.log(Level.FINEST, "No " + name + " will use empty");
return def;
}
return String.valueOf(ret);
}
catch (Exception e) {
log.log(Level.SEVERE, "Could not get a " + name + " message, will use empty", e);
return def;
}
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public Object getVariable(String name) {
try {
return super.getVariable(name);
}
catch (MissingPropertyException e) {
// Original {@link Binding} doesn't have 'variable' for the given 'name'.
// Try to resolve it as 'bean' from the given <code>beanFactory</code>.
}
if (GroovyScriptExecutingMessageProcessor.this.beanFactory == null) {
throw new MissingPropertyException(name, this.getClass());
}
try {
return GroovyScriptExecutingMessageProcessor.this.beanFactory.getBean(name);
}
catch (NoSuchBeanDefinitionException e) {
throw new MissingPropertyException(name, this.getClass(), e);
}
}
代码示例来源:origin: crashub/crash
@Override
public Object getVariable(String name) {
if (name.equals("context")) {
return proxy;
} else {
if (session != null) {
try {
Command<?> cmd = session.getCommand(name);
if (cmd != null) {
return new PipeLineClosure(new InvocationContextImpl<Object>(proxy), name, cmd);
}
} catch (CommandException ignore) {
// Really ?
}
return super.getVariable(name);
} else {
return super.getVariable(name);
}
}
}
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public Object getVariable(String name) {
try {
return super.getVariable(name);
代码示例来源:origin: io.snamp/scripting
/**
* @param name the name of the variable to lookup
* @return the variable value
*/
@Override
public Object getVariable(final String name) {
return first.hasVariable(name) ? first.getVariable(name) : second.getVariable(name);
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
/**
* Overloaded to make variables appear as bean properties or via the subscript operator
*/
public Object getProperty(String property) {
/** @todo we should check if we have the property with the metaClass instead of try/catch */
try {
return super.getProperty(property);
}
catch (MissingPropertyException e) {
return getVariable(property);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
/**
* @return a writer, an output stream, a markup builder or another requested object
*/
public Object getVariable(String name) {
lazyInit();
validateArgs(name, "No variable with");
return super.getVariable(name);
}
内容来源于网络,如有侵权,请联系作者删除!