/** * @deprecated * Use {@link WebApp#getClassLoader()} */ public ClassLoader getClassLoader() { return webApp.getClassLoader(); }
/** * @deprecated * Use {@link WebApp#getClassLoader()} */ public ClassLoader getClassLoader() { return webApp.getClassLoader(); }
/** * @deprecated * Use {@link WebApp#getClassLoader()} */ public ClassLoader getClassLoader() { return webApp.getClassLoader(); }
/** * @deprecated * Use {@link WebApp#getClassLoader()} */ public static ClassLoader getClassLoader( ServletContext context ) { return WebApp.get(context).getClassLoader(); }
/** * @deprecated * Use {@link WebApp#getClassLoader()} */ public static ClassLoader getClassLoader( ServletContext context ) { return WebApp.get(context).getClassLoader(); }
/** * @deprecated * Use {@link WebApp#getClassLoader()} */ public static ClassLoader getClassLoader( ServletContext context ) { return WebApp.get(context).getClassLoader(); }
@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; } }
protected JellyContext createContext(final StaplerRequest req, StaplerResponse rsp, Script script, Object it) { CustomJellyContext context = new CustomJellyContext(); // let Jelly see the whole classes context.setClassLoader(req.getWebApp().getClassLoader()); // so TagScript.getBodyText() will use HTMLWriterOutput context.setVariable(XMLOutputFactory.class.getName(), this); return context; }
protected JellyContext createContext(final StaplerRequest req, StaplerResponse rsp, Script script, Object it) { CustomJellyContext context = new CustomJellyContext(); // let Jelly see the whole classes context.setClassLoader(req.getWebApp().getClassLoader()); // so TagScript.getBodyText() will use HTMLWriterOutput context.setVariable(XMLOutputFactory.class.getName(), this); return context; }
@Override public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments) throws IllegalAccessException, InvocationTargetException, ServletException { if (!request.getMethod().equals("POST")) { for (ErrorCustomizer handler : ServiceLoader.load(ErrorCustomizer.class, request.getWebApp().getClassLoader())) { ForwardToView forwardToView = handler.getForwardView(); if (forwardToView != null) { throw new InvocationTargetException(forwardToView.with("requestURL", request.getRequestURLWithQueryString().toString())); } } throw new InvocationTargetException(new HttpResponses.HttpResponseException() { public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); rsp.addHeader("Allow", "POST"); rsp.setContentType("text/html"); PrintWriter w = rsp.getWriter(); w.println("<html><head><title>POST required</title></head><body>"); w.println("POST is required for " + target.getQualifiedName() + "<br>"); w.println("<form method='POST'><input type='submit' value='Try POSTing'></form>"); w.println("</body></html>"); } }); } return target.invoke(request, response, instance, arguments); } }
@Override public Object invoke(StaplerRequest request, StaplerResponse response, Object instance, Object[] arguments) throws IllegalAccessException, InvocationTargetException, ServletException { if (!request.getMethod().equals("POST")) { for (ErrorCustomizer handler : ServiceLoader.load(ErrorCustomizer.class, request.getWebApp().getClassLoader())) { ForwardToView forwardToView = handler.getForwardView(); if (forwardToView != null) { throw new InvocationTargetException(forwardToView.with("requestURL", request.getRequestURLWithQueryString().toString())); } } throw new InvocationTargetException(new HttpResponses.HttpResponseException() { public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); rsp.addHeader("Allow", "POST"); rsp.setContentType("text/html"); PrintWriter w = rsp.getWriter(); w.println("<html><head><title>POST required</title></head><body>"); w.println("POST is required for " + target.getQualifiedName() + "<br>"); w.println("<form method='POST'><input type='submit' value='Try POSTing'></form>"); w.println("</body></html>"); } }); } return target.invoke(request, response, instance, arguments); } }
@Override public Step newInstance(StaplerRequest req, JSONObject formData) throws FormException { if (req == null) { // should not happen return super.newInstance(null, formData); } // A modified version of RequestImpl.TypePair.convertJSON. // Works around the fact that Stapler does not call back into Descriptor.newInstance for nested objects (JENKINS-31458); // and propertiesMap virtual field name; and null values for unselected properties. List<JobProperty> properties = new ArrayList<JobProperty>(); ClassLoader cl = req.getStapler().getWebApp().getClassLoader(); @SuppressWarnings("unchecked") Set<Map.Entry<String,Object>> entrySet = formData.getJSONObject("propertiesMap").entrySet(); for (Map.Entry<String,Object> e : entrySet) { if (e.getValue() instanceof JSONObject) { String className = e.getKey().replace('-', '.'); // decode JSON-safe class name escaping Class<? extends JobProperty> itemType; try { itemType = cl.loadClass(className).asSubclass(JobProperty.class); } catch (ClassNotFoundException x) { throw new FormException(x, "propertiesMap"); } JobPropertyDescriptor d = (JobPropertyDescriptor) Jenkins.getActiveInstance().getDescriptorOrDie(itemType); JSONObject more = (JSONObject) e.getValue(); JobProperty property = d.newInstance(req, more); if (property != null) { properties.add(property); } } } return new JobPropertyStep(properties); }
@Override public Step newInstance(StaplerRequest req, JSONObject formData) throws FormException { if (req == null) { // should not happen return super.newInstance(null, formData); } // A modified version of RequestImpl.TypePair.convertJSON. // Works around the fact that Stapler does not call back into Descriptor.newInstance for nested objects (JENKINS-31458); // and propertiesMap virtual field name; and null values for unselected properties. List<JobProperty> properties = new ArrayList<JobProperty>(); ClassLoader cl = req.getStapler().getWebApp().getClassLoader(); @SuppressWarnings("unchecked") Set<Map.Entry<String,Object>> entrySet = formData.getJSONObject("propertiesMap").entrySet(); for (Map.Entry<String,Object> e : entrySet) { if (e.getValue() instanceof JSONObject) { String className = e.getKey().replace('-', '.'); // decode JSON-safe class name escaping Class<? extends JobProperty> itemType; try { itemType = cl.loadClass(className).asSubclass(JobProperty.class); } catch (ClassNotFoundException x) { throw new FormException(x, "propertiesMap"); } JobPropertyDescriptor d = (JobPropertyDescriptor) Jenkins.getActiveInstance().getDescriptorOrDie(itemType); JSONObject more = (JSONObject) e.getValue(); JobProperty property = d.newInstance(req, more); if (property != null) { properties.add(property); } } } return new JobPropertyStep(properties); }
ClassLoader cl = stapler.getWebApp().getClassLoader(); String className = j.getString("stapler-class"); try { ClassLoader cl = stapler.getWebApp().getClassLoader(); for (Map.Entry<String,Object> e : (Set<Map.Entry<String,Object>>)j.entrySet()) { Object v = e.getValue();
ClassLoader cl = stapler.getWebApp().getClassLoader(); try { Class<?> subType = cl.loadClass(className); ClassLoader cl = stapler.getWebApp().getClassLoader(); for (Map.Entry<String,Object> e : (Set<Map.Entry<String,Object>>)j.entrySet()) { Object v = e.getValue();
ClassLoader cl = stapler.getWebApp().getClassLoader(); try { Class<?> subType = cl.loadClass(className); ClassLoader cl = stapler.getWebApp().getClassLoader(); for (Map.Entry<String,Object> e : (Set<Map.Entry<String,Object>>)j.entrySet()) { Object v = e.getValue();