本文整理了Java中org.kohsuke.stapler.StaplerRequest.getStapler()
方法的一些代码示例,展示了StaplerRequest.getStapler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.getStapler()
方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:getStapler
[英]Gets the Stapler instance that this belongs to.
[中]获取它所属的订书机实例。
代码示例来源:origin: jenkinsci/jenkins
if ("true".equals(req.getParameter("encrypt"))) {
final CapturingServletOutputStream csos = new CapturingServletOutputStream();
StaplerResponse temp = new ResponseImpl(req.getStapler(), new HttpServletResponseWrapper(res) {
@Override public ServletOutputStream getOutputStream() throws IOException {
return csos;
代码示例来源:origin: jenkinsci/multi-branch-project-plugin
/**
* Constructs this extension of {@link RequestImpl} under the assumption that {@link RequestImpl} is also the
* underlying type of the {@link StaplerRequest}.
*
* @param request the request submitted the {@link TemplateDrivenMultiBranchProject}
*/
TemplateStaplerRequestWrapper(StaplerRequest request) {
/*
* Ugly casts to RequestImpl... but should be ok since it will throw
* errors, which we want anyway if it's not that type.
*/
super(request.getStapler(), request, ((RequestImpl) request).ancestors,
((RequestImpl) request).tokens);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
if ("true".equals(req.getParameter("encrypt"))) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
StaplerResponse temp = new ResponseImpl(req.getStapler(), new HttpServletResponseWrapper(res) {
@Override public ServletOutputStream getOutputStream() throws IOException {
return new FilterServletOutputStream(baos);
代码示例来源:origin: org.jenkins-ci.plugins.workflow/workflow-multibranch
@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);
}
代码示例来源:origin: jenkinsci/workflow-multibranch-plugin
@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);
}
代码示例来源:origin: jenkinsci/multi-branch-project-plugin
/**
* Sets various implementation-specific fields and forwards wrapped req/rsp objects on to the
* {@link #template}'s {@link AbstractProject#doConfigSubmit(StaplerRequest, StaplerResponse)} method.
* <br>
* {@inheritDoc}
*/
@Override
public void submit(StaplerRequest req, StaplerResponse rsp)
throws ServletException, Descriptor.FormException, IOException {
super.submit(req, rsp);
makeDisabled(req.getParameter("disable") != null);
template.doConfigSubmit(
new TemplateStaplerRequestWrapper(req),
new TemplateStaplerResponseWrapper(req.getStapler(), rsp));
ItemListener.fireOnUpdated(this);
// notify the queue as the project might be now tied to different node
Jenkins.getActiveInstance().getQueue().scheduleMaintenance();
// this is to reflect the upstream build adjustments done above
Jenkins.getActiveInstance().rebuildDependencyGraphAsync();
}
内容来源于网络,如有侵权,请联系作者删除!