return new RequestImpl(Stapler.getCurrent(), (HttpServletRequest) Proxy.newProxyInstance(ProgressiveRendering.class.getClassLoader(), new Class<?>[] {HttpServletRequest.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String m = method.getName();
Stapler stapler = Stapler.getCurrent(); if (stapler != null) { try {
/** * Gets the current {@link WebApp} that the calling thread is associated with. */ public static WebApp getCurrent() { return Stapler.getCurrent().getWebApp(); } }
public String getDescription() { Stapler stapler = Stapler.getCurrent(); if (stapler != null) { try { WebApp webapp = WebApp.getCurrent(); MetaClass meta = webapp.getMetaClass(this); Script s = meta.loadTearOff(JellyClassTearOff.class).findScript("newInstanceDetail"); if (s == null) { return ""; } DefaultScriptInvoker dsi = new DefaultScriptInvoker(); StringWriter sw = new StringWriter(); XMLOutput xml = dsi.createXMLOutput(sw, true); dsi.invokeScript(Stapler.getCurrentRequest(), Stapler.getCurrentResponse(), s, this, xml); return sw.toString(); } catch (Exception e) { Logger.getLogger(clazz.getName()).log(Level.WARNING, e.getMessage(), e); return ""; } } else { return ""; } }
@Exported public List<JobMetric> getMetrics() { final StaplerRequest req = Stapler.getCurrent().getCurrentRequest(); final String branchTab = req.getParameter("branchTab"); final String buildCount = req.getParameter("count"); return JobMetric.getApplicableJobMetrics(this.dynamicProject, branchTab, Integer.parseInt(buildCount)); } }
/** * Gets the current {@link WebApp} that the calling thread is associated with. */ public static WebApp getCurrent() { return Stapler.getCurrent().getWebApp(); }
Stapler stapler = Stapler.getCurrent(); if (stapler != null) { try {
@Exported public List<Build> getBuilds() { final StaplerRequest req = Stapler.getCurrent().getCurrentRequest(); final String branchTab = req.getParameter("branchTab"); final String buildCount = req.getParameter("count"); return Lists.newArrayList(new BuildHistory(this.dynamicProject).getBuilds(branchTab, Integer.parseInt(buildCount))); }
/** * Gets the current {@link WebApp} that the calling thread is associated with. */ public static WebApp getCurrent() { return Stapler.getCurrent().getWebApp(); }
return new RequestImpl(Stapler.getCurrent(), (HttpServletRequest) Proxy.newProxyInstance(ProgressiveRendering.class.getClassLoader(), new Class<?>[] {HttpServletRequest.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String m = method.getName();
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { Stapler.getCurrent().serveStaticResource(req,rsp,resource,expiration); } };
@Nonnull private static List<ApplicationTracer> getTracers() { synchronized (ApplicationTracer.class) { if (tracers == null) { List<ApplicationTracer> t = new ArrayList<>(); for (ApplicationTracer tracer : ServiceLoader.load(EvaluationTrace.ApplicationTracer.class, Stapler.getCurrent().getWebApp().getClassLoader())) { try { t.add(tracer); } catch (Exception e) { // robustness if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Exception thrown when notifying tracer", e); } } } tracers = t; } } return tracers; } }
@Nonnull private static List<ApplicationTracer> getTracers() { synchronized (ApplicationTracer.class) { if (tracers == null) { List<ApplicationTracer> t = new ArrayList<>(); for (ApplicationTracer tracer : ServiceLoader.load(EvaluationTrace.ApplicationTracer.class, Stapler.getCurrent().getWebApp().getClassLoader())) { try { t.add(tracer); } catch (Exception e) { // robustness if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Exception thrown when notifying tracer", e); } } } tracers = t; } } return tracers; } }