本文整理了Java中groovy.lang.Script.invokeMethod()
方法的一些代码示例,展示了Script.invokeMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Script.invokeMethod()
方法的具体详情如下:
包路径:groovy.lang.Script
类名称:Script
方法名:invokeMethod
[英]Invoke a method (or closure in the binding) defined.
[中]调用定义的方法(或绑定中的闭包)。
代码示例来源:origin: jenkinsci/jenkins
@Override
public Object invokeMethod(String name, Object args) {
try {
return delegate.invokeMethod(name,args);
} catch (MissingMethodException mme) {
return super.invokeMethod(name, args);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
@Override
public Object invokeMethod(String name, Object args) {
try {
if (delegate instanceof GroovyObject) {
return ((GroovyObject) delegate).invokeMethod(name, args);
}
return metaClass.invokeMethod(delegate, name, args);
} catch (MissingMethodException mme) {
return super.invokeMethod(name, args);
}
}
代码示例来源:origin: spockframework/spock
@Override
public Object invokeMethod(String name, Object args) {
try {
return GroovyRuntimeUtil.invokeMethod($delegate, name, GroovyRuntimeUtil.asArgumentArray(args));
} catch (MissingMethodException e) {
return super.invokeMethod(name, args);
}
}
}
代码示例来源:origin: crashub/crash
@Override
public final Object invokeMethod(String name, Object args) {
//
try {
return super.invokeMethod(name, args);
}
catch (MissingMethodException missing) {
return Helper.invokeMethod(context, name, args, missing);
}
}
代码示例来源:origin: jenkinsci/acceptance-test-harness
@Override
public Object invokeMethod(String name, Object args) {
try {
return delegateMetaClass.invokeMethod(delegate, name, args);
} catch (MissingMethodException e) {
return super.invokeMethod(name,args);
}
}
}
代码示例来源:origin: freeplane/freeplane
@Override
public Object invokeMethod(String methodName, Object args) {
try {
return super.invokeMethod(methodName, args);
}
catch (MissingMethodException mme) {
try {
return nodeMetaClass.invokeMethod(node, methodName, args);
}
catch (MissingMethodException e) {
throw e;
}
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public Object invokeMethod(String name, Object args) {
try {
return delegate.invokeMethod(name,args);
} catch (MissingMethodException mme) {
return super.invokeMethod(name, args);
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@Override
public Object invokeMethod(String name, Object args) {
try {
return delegate.invokeMethod(name,args);
} catch (MissingMethodException mme) {
return super.invokeMethod(name, args);
}
}
代码示例来源:origin: com.github.corda.crash/crash.shell
@Override
public final Object invokeMethod(String name, Object args) {
//
try {
return super.invokeMethod(name, args);
}
catch (MissingMethodException missing) {
return Helper.invokeMethod(context, name, args, missing);
}
}
代码示例来源:origin: hudson/hudson-2.x
@Override
public Object invokeMethod(String name, Object args) {
try {
return delegate.invokeMethod(name,args);
} catch (MissingMethodException mme) {
return super.invokeMethod(name, args);
}
}
代码示例来源:origin: org.crashub/crash.shell
@Override
public final Object invokeMethod(String name, Object args) {
//
try {
return super.invokeMethod(name, args);
}
catch (MissingMethodException missing) {
return Helper.invokeMethod(context, name, args, missing);
}
}
代码示例来源:origin: stapler/stapler
public Object invokeMethod(String name, Object args) {
try {
return delegate.invokeMethod(name,args);
} catch (MissingMethodException mme) {
return super.invokeMethod(name, args);
}
}
代码示例来源:origin: disney/groovity
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if(request instanceof HttpServletRequest){
HttpServletRequest hr = (HttpServletRequest) request;
HttpSession session = hr.getSession(false);
if(session!=null){
Object userId = session.getAttribute("userId");
if(userId != null){
Groovity groovity = (Groovity) servletContext.getAttribute(GroovityServlet.SERVLET_CONTEXT_GROOVITY_INSTANCE);
Script factory;
try {
factory = groovity.load("/data/factory", new Binding());
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new ServletException(e);
}
Object user = factory.invokeMethod("call", new String[]{"person",userId.toString()});
if(user!=null && user instanceof Principal){
request = new AuthenticatedRequestWrapper(hr, (Principal)user);
}
}
}
}
chain.doFilter(request, response);
}
代码示例来源:origin: com.disney.groovity/groovity-portal
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if(request instanceof HttpServletRequest){
HttpServletRequest hr = (HttpServletRequest) request;
HttpSession session = hr.getSession(false);
if(session!=null){
Object userId = session.getAttribute("userId");
if(userId != null){
Groovity groovity = (Groovity) servletContext.getAttribute(GroovityServlet.SERVLET_CONTEXT_GROOVITY_INSTANCE);
Script factory;
try {
factory = groovity.load("/data/factory", new Binding());
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new ServletException(e);
}
Object user = factory.invokeMethod("call", new String[]{"person",userId.toString()});
if(user!=null && user instanceof Principal){
request = new AuthenticatedRequestWrapper(hr, (Principal)user);
}
}
}
}
chain.doFilter(request, response);
}
代码示例来源:origin: com.celum/db-tool
/**
* executes the Groovy script
*/
@Override
public void execute(DbStep step)
{
LOG.info("[GROOVY STEP]:" + step.getName() + " (" + step.getVersion() + ")");
Reader scriptReader = step.getStepReader();
Script s = shell.parse(scriptReader);
s.invokeMethod(GROOVY_DBMAIN, new Object[] {dataSource, variables} );
}
}
代码示例来源:origin: disney/groovity
@Override
protected void filteredObject(ModelWalker walker, boolean matched, Object value, ModelVisitor consumer) throws Exception {
if(matched) {
if(value instanceof Pointer) {
Pointer pointer = (Pointer) value;
boolean known = (boolean) factory.invokeMethod("isKnownType", pointer.getType());
if(!known) {
Referent cur = walker.getContextObject(Referent.class);
if(cur != null) {
Pointer parent = cur.getPointer();
//check for lifecycle suffix
String t = parent.getType();
int u = t.indexOf("_");
if(u>0) {
String nt = pointer.getType().concat(t.substring(u));
known = (boolean) factory.invokeMethod("isKnownType", nt);
if(known) {
pointer = new Pointer(nt,pointer.getId());
}
}
}
}
if(known) {
value = factory.invokeMethod("call", pointer);
}
}
}
consumer.visitObject(value);
}
};
代码示例来源:origin: fizzed/blaze
@Override
public void execute(String task) throws BlazeException {
Method method = findTaskMethod(task);
try {
script.invokeMethod(task, new Object[]{});
} catch (Exception e) {
logFirstScriptSource(e);
if (e instanceof BlazeException) {
throw (BlazeException)e;
} else if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else {
throw new BlazeException("Unable to execute task '" + task + "'", e);
}
}
}
代码示例来源:origin: apache/ofbiz-framework
public static Object runScriptAtLocation(String location, String methodName, Map<String, Object> context) throws GeneralException {
Script script = InvokerHelper.createScript(getScriptClassFromLocation(location), getBinding(context));
Object result = null;
if (UtilValidate.isEmpty(methodName)) {
result = script.run();
} else {
result = script.invokeMethod(methodName, new Object[] { context });
}
return result;
}
代码示例来源:origin: org.crsh/crsh.shell.core
@Override
public final Object invokeMethod(String name, Object args) {
//
try {
return super.invokeMethod(name, args);
}
catch (MissingMethodException e) {
if (context instanceof InvocationContext) {
InvocationContext ic = (InvocationContext)context;
CRaSH crash = (CRaSH)context.getSession().get("crash");
if (crash != null) {
ShellCommand cmd;
try {
cmd = crash.getCommand(name);
}
catch (NoSuchCommandException ce) {
throw new InvokerInvocationException(ce);
}
if (cmd != null) {
ClassDispatcher dispatcher = new ClassDispatcher(cmd, this);
return dispatcher.dispatch("", CommandClosure.unwrapArgs(args));
}
}
}
//
throw e;
}
}
代码示例来源:origin: apache/ofbiz-framework
resultObj = script.run();
} else {
resultObj = script.invokeMethod(modelService.invoke, EMPTY_ARGS);
内容来源于网络,如有侵权,请联系作者删除!