org.kohsuke.stapler.WebApp.getMetaClass()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.kohsuke.stapler.WebApp.getMetaClass()方法的一些代码示例,展示了WebApp.getMetaClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebApp.getMetaClass()方法的具体详情如下:
包路径:org.kohsuke.stapler.WebApp
类名称:WebApp
方法名:getMetaClass

WebApp.getMetaClass介绍

[英]Obtains a MetaClass that represents the type of the given object.

This code consults all facets to handle scripting language objects correctly.
[中]获取表示给定对象类型的元类。
这段代码参考了所有方面来正确处理脚本语言对象。

代码示例

代码示例来源:origin: jenkinsci/jenkins

/**
 * Evaluates the Jelly script submitted by the client.
 *
 * This is useful for system administration as well as unit testing.
 */
@RequirePOST
public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  checkPermission(RUN_SCRIPTS);
  try {
    MetaClass mc = WebApp.getCurrent().getMetaClass(getClass());
    Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader()));
    new JellyRequestDispatcher(this,script).forward(req,rsp);
  } catch (JellyException e) {
    throw new ServletException(e);
  }
}

代码示例来源:origin: jenkinsci/jenkins

try {
  WebApp webapp = WebApp.getCurrent();
  MetaClass meta = webapp.getMetaClass(this);
  Script s = meta.loadTearOff(JellyClassTearOff.class).findScript("newInstanceDetail");
  if (s == null) {

代码示例来源:origin: jenkinsci/jenkins

public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException {
    WebApp webApp = WebApp.getCurrent();
    final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view);
    if (s!=null) {
      JellyFacet facet = webApp.getFacet(JellyFacet.class);
      request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us
      request.setAttribute("mode","side-panel");
      // run sidepanel but ignore generated HTML
      facet.scriptInvoker.invokeScript(request,response,new Script() {
        public Script compile() throws JellyException {
          return this;
        }
        public void run(JellyContext context, XMLOutput output) throws JellyTagException {
          Functions.initPageVariables(context);
          s.run(context,output);
        }
      },self,new XMLOutput(new DefaultHandler()));
    } else
    if (self instanceof Actionable) {
      // fallback
      this.addAll(((Actionable)self).getAllActions());
    }

    return this;
  }
}

代码示例来源:origin: stapler/stapler

/**
 * Obtains a {@link MetaClass} that represents the type of the given object.
 *
 * <p>
 * This code consults all facets to handle scripting language objects correctly.
 */
public MetaClass getMetaClass(Object o) {
  return getMetaClass(getKlass(o));
}

代码示例来源:origin: org.kohsuke.stapler/stapler

/**
 * Obtains a {@link MetaClass} that represents the type of the given object.
 *
 * <p>
 * This code consults all facets to handle scripting language objects correctly.
 */
public MetaClass getMetaClass(Object o) {
  return getMetaClass(getKlass(o));
}

代码示例来源:origin: stapler/stapler

public MetaClass getMetaClass(Class c) {
  return getMetaClass(Klass.java(c));
}

代码示例来源:origin: org.kohsuke.stapler/stapler

public MetaClass getMetaClass(Class c) {
  return getMetaClass(Klass.java(c));
}

代码示例来源:origin: org.hudsonci.stapler/stapler-core

/*package*/ MetaClass(WebApp webApp, Class clazz) {
  this.clazz = clazz;
  this.webApp = webApp;
  this.baseClass = webApp.getMetaClass(clazz.getSuperclass());
  this.classLoader = MetaClassLoader.get(clazz.getClassLoader());
  buildDispatchers(
    new ClassDescriptor(clazz,null/*support wrappers*/));
}

代码示例来源:origin: stapler/stapler

public RequestDispatcher createRequestDispatcher(RequestImpl request, Klass type, Object it, String viewName) throws IOException {
  MetaClass mc = request.stapler.getWebApp().getMetaClass(type);
  return createDispatcher(it, viewName, mc);
}

代码示例来源:origin: org.kohsuke.stapler/stapler

/*package*/ MetaClass(WebApp webApp, Klass<?> klass) {
  this.clazz = klass.toJavaClass();
  this.klass = klass;
  this.webApp = webApp;
  this.baseClass = webApp.getMetaClass(klass.getSuperClass());
  this.classLoader = MetaClassLoader.get(clazz.getClassLoader());
  buildDispatchers();
}

代码示例来源:origin: org.jvnet.hudson.main/maven-plugin

/**
 * Returns true if this descriptor has <tt>config.jelly</tt>.
 */
public final boolean hasConfigScreen() {
  MetaClass c = WebApp.getCurrent().getMetaClass(getClass());
  try {
    JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class);
    return tearOff.findScript(getConfigPage())!=null;
  } catch(JellyException e) {
    return false;
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/ivy

/**
 * Returns true if this descriptor has <tt>config.jelly</tt>.
 */
public final boolean hasConfigScreen() {
  MetaClass c = WebApp.getCurrent().getMetaClass(getClass());
  try {
    JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class);
    return tearOff.findScript(getConfigPage())!=null;
  } catch(JellyException e) {
    return false;
  }
}

代码示例来源:origin: org.hudsonci.plugins/ivy

/**
 * Returns true if this descriptor has <tt>config.jelly</tt>.
 */
public final boolean hasConfigScreen() {
  MetaClass c = WebApp.getCurrent().getMetaClass(getClass());
  try {
    JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class);
    return tearOff.findScript(getConfigPage())!=null;
  } catch(JellyException e) {
    return false;
  }
}

代码示例来源:origin: stapler/stapler

/*package*/ MetaClass(WebApp webApp, Klass<?> klass) {
  this.clazz = klass.toJavaClass();
  this.klass = klass;
  this.webApp = webApp;
  this.baseClass = webApp.getMetaClass(klass.getSuperClass());
  this.classLoader = MetaClassLoader.get(clazz.getClassLoader());
  buildDispatchers();
}

代码示例来源:origin: org.jvnet.hudson.plugins/ivy

/**
 * Returns true if this descriptor has <tt>config.jelly</tt>.
 */
public final boolean hasConfigScreen() {
  MetaClass c = WebApp.getCurrent().getMetaClass(getClass());
  try {
    JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class);
    return tearOff.findScript(getConfigPage())!=null;
  } catch(JellyException e) {
    return false;
  }
}

代码示例来源:origin: stapler/stapler

public RequestDispatcher createRequestDispatcher(RequestImpl request, Klass<?> type, Object it, String viewName) throws IOException {
  TearOffSupport mc = request.stapler.getWebApp().getMetaClass(type);
  return mc.loadTearOff(ERbClassTearOff.class).createDispatcher(it,viewName);
}

代码示例来源:origin: jenkinsci/maven-plugin

/**
 * Returns true if this descriptor has <tt>config.jelly</tt>.
 */
public final boolean hasConfigScreen() {
  MetaClass c = WebApp.getCurrent().getMetaClass(getClass());
  try {
    JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class);
    return tearOff.findScript(getConfigPage())!=null;
  } catch(JellyException e) {
    return false;
  }
}

代码示例来源:origin: org.eclipse.hudson.stapler/stapler-jelly

public RequestDispatcher createRequestDispatcher(RequestImpl request, Class type, Object it, String viewName) throws IOException {
  TearOffSupport mc = request.stapler.getWebApp().getMetaClass(type);
  return mc.loadTearOff(JellyClassTearOff.class).createDispatcher(it,viewName);
}

代码示例来源:origin: stapler/stapler

public RequestDispatcher createRequestDispatcher(RequestImpl request, Klass<?> type, Object it, String viewName) throws IOException {
  TearOffSupport mc = request.stapler.getWebApp().getMetaClass(type);
  return mc.loadTearOff(JellyClassTearOff.class).createDispatcher(it,viewName);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

/**
 * Evaluates the Jelly script submitted by the client.
 *
 * This is useful for system administration as well as unit testing.
 */
public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  checkPermission(ADMINISTER);
  requirePOST();
  try {
    MetaClass mc = WebApp.getCurrent().getMetaClass(getClass());
    Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader()));
    new JellyRequestDispatcher(this, script).forward(req, rsp);
  } catch (JellyException e) {
    throw new ServletException(e);
  }
}

相关文章