File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\slaves\AbstractCloudImpl.java.html

1 package hudson.slaves;
2
3 /**
4 * Additional convenience implementation on top of {@link Cloud} that are likely useful to
5 * typical {@link Cloud} implementations.
6 *
7 * <p>
8 * Whereas {@link Cloud} is the contract between the rest of Hudson and a cloud implementation,
9 * this class focuses on providing a convenience to minimize the effort it takes to integrate
10 * a new cloud to Hudson.
11 *
12 * @author Kohsuke Kawaguchi
13 */
14 public abstract class AbstractCloudImpl extends Cloud {
15 /**
16 * Upper bound on how many instances we may provision.
17 */
18 private int instanceCap;
19
20 protected AbstractCloudImpl(String name, String instanceCapStr) {
21 super(name);
22
23 setInstanceCapStr(instanceCapStr);
24 }
25
26 protected void setInstanceCapStr(String value) {
27 if(value==null || value.equals(""))
28 this.instanceCap = Integer.MAX_VALUE;
29 else
30 this.instanceCap = Integer.parseInt(value);
31 }
32
33 /**
34 * Gets the instance cap as string. Used primarily for form binding.
35 */
36 public String getInstanceCapStr() {
37 if(instanceCap==Integer.MAX_VALUE)
38 return "";
39 else
40 return String.valueOf(instanceCap);
41 }
42
43 /**
44 * Gets the instance cap as int, where the capless is represented as {@link Integer#MAX_VALUE}
45 */
46 public int getInstanceCap() {
47 return instanceCap;
48 }
49
50 protected void setInstanceCap(int v) {
51 this.instanceCap = v;
52 }
53 }
54