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

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(69)

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

StaplerRequest.findAncestor介绍

[英]Finds the nearest ancestor that has the object of the given type, or null if not found.
[中]查找具有给定类型对象的最近祖先,如果未找到,则为null。

代码示例

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

/**
 * @since 1.402
 */
public static String getCurrentDescriptorByNameUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  // this override allows RenderOnDemandClosure to preserve the proper value
  Object url = req.getAttribute("currentDescriptorByNameUrl");
  if (url!=null)  return url.toString();
  Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
  return a.getUrl();
}

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

AbstractBuild build = (AbstractBuild)request.findAncestor(AbstractBuild.class).getObject();
File fileParameter = getLocationUnderBuild(build);

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

private Job<?, ?> retrieveCurrentJob() {
  StaplerRequest request = Stapler.getCurrentRequest();
  if (request != null) {
    Ancestor ancestor = request.findAncestor(Job.class);
    return ancestor == null ? null : (Job<?, ?>) ancestor.getObject();
  }
  return null;
}

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

Ancestor ancestor = Stapler.getCurrentRequest().findAncestor(BoundObjectTable.class);
if (ancestor == null) {
  throw new IllegalStateException("no BoundObjectTable");

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

/**
 * @see ContextMenuVisibility
 */
public ContextMenu add(Action a) {
  if (!Functions.isContextMenuVisible(a)) {
    return this;
  }
  StaplerRequest req = Stapler.getCurrentRequest();
  String text = a.getDisplayName();
  String base = Functions.getIconFilePath(a);
  if (base==null)     return this;
  String icon = Stapler.getCurrentRequest().getContextPath()+(base.startsWith("images/")?Functions.getResourcePath():"")+'/'+base;
  String url =  Functions.getActionUrl(req.findAncestor(ModelObject.class).getUrl(),a);
  return add(url,icon,text);
}

代码示例来源:origin: org.eclipse.hudson/hudson-plugin-utils

protected void redirectAncestor(final StaplerRequest req, final StaplerResponse resp, final Object obj) throws IOException {
  log.trace("Redirect ancestor: {}", obj);
  Ancestor ancestor = req.findAncestor(obj);
  redirect(req, resp, ancestor.getUrl());
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-plugin-utils

protected void redirectAncestor(final StaplerRequest req, final StaplerResponse resp, final Object obj) throws IOException {
  log.trace("Redirect ancestor: {}", obj);
  Ancestor ancestor = req.findAncestor(obj);
  redirect(req, resp, ancestor.getUrl());
}

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

protected void redirectAncestor(final StaplerRequest req, final StaplerResponse resp, final Object obj) throws IOException {
  log.trace("Redirect ancestor: {}", obj);
  Ancestor ancestor = req.findAncestor(obj);
  redirect(req, resp, ancestor.getUrl());
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-plugin-utils

protected void redirectAncestor(final StaplerRequest req, final StaplerResponse resp, final Class type) throws IOException {
  log.trace("Redirect ancestor: {}", type);
  redirect(req, resp, req.findAncestor(type).getUrl());
}

代码示例来源:origin: org.eclipse.hudson/hudson-plugin-utils

protected void redirectAncestor(final StaplerRequest req, final StaplerResponse resp, final Class type) throws IOException {
  log.trace("Redirect ancestor: {}", type);
  redirect(req, resp, req.findAncestor(type).getUrl());
}

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

protected void redirectAncestor(final StaplerRequest req, final StaplerResponse resp, final Class type) throws IOException {
  log.trace("Redirect ancestor: {}", type);
  redirect(req, resp, req.findAncestor(type).getUrl());
}

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

private String getCurrentDescriptorByNameUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
  return Functions.getAncestorUrl(req, a);
}

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

private String getCurrentDescriptorByNameUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
  return a.getUrl();
}

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

private String getCurrentDescriptorByNameUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
  return a.getUrl();
}

代码示例来源:origin: hudson/hudson-2.x

private String getCurrentDescriptorByNameUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
  return a.getUrl();
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * @since 1.402
 */
public static String getCurrentDescriptorByNameUrl() {
  StaplerRequest req = Stapler.getCurrentRequest();
  // this override allows RenderOnDemandClosure to preserve the proper value
  Object url = req.getAttribute("currentDescriptorByNameUrl");
  if (url!=null)  return url.toString();
  Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
  return a.getUrl();
}

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

/**
 * Called from within the request handling of a bound object, to release the object explicitly.
 */
public void releaseMe() {
  Ancestor eot = Stapler.getCurrentRequest().findAncestor(BoundObjectTable.class);
  if (eot==null)
    throw new IllegalStateException("The thread is not handling a request to a abound object");
  String id = eot.getNextToken(0);
  resolve(false).release(id); // resolve(false) can't fail because we are processing this request now.
}

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

/**
 * Called from within the request handling of a bound object, to release the object explicitly.
 */
public void releaseMe() {
  Ancestor eot = Stapler.getCurrentRequest().findAncestor(BoundObjectTable.class);
  if (eot==null)
    throw new IllegalStateException("The thread is not handling a request to a abound object");
  String id = eot.getNextToken(0);
  resolve(false).release(id); // resolve(false) can't fail because we are processing this request now.
}

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

/**
 * Called from within the request handling of a bound object, to release the object explicitly.
 */
public void releaseMe() {
  Ancestor eot = Stapler.getCurrentRequest().findAncestor(BoundObjectTable.class);
  if (eot==null)
    throw new IllegalStateException("The thread is not handling a request to a abound object");
  String id = eot.getNextToken(0);
  resolve(false).release(id); // resolve(false) can't fail because we are processing this request now.
}

代码示例来源:origin: etsy/jenkins-master-project

@Override
public void doDynamic(StaplerRequest req, StaplerResponse res)
  throws ServletException, IOException {
 if (("/" + getOriginalFileName()).equals(req.getRestOfPath())) {
  AbstractBuild build = (AbstractBuild) req
    .findAncestor(AbstractBuild.class)
    .getObject();
  File fileParameter = getLocationUnderBuild(build);
  if (fileParameter.isFile()) {
   res.serveFile(req, fileParameter.toURI().toURL());
  }
 }
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法