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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2011, CloudBees, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package jenkins.model;
25
26 import hudson.ExtensionPoint;
27 import hudson.model.Action;
28 import hudson.model.Fingerprint;
29 import org.kohsuke.accmod.Restricted;
30 import org.kohsuke.accmod.restrictions.NoExternalUse;
31
32 import java.util.List;
33
34 /**
35 * Plugin-specific additions to fingerprint information.
36 *
37 * <p>
38 * Each {@link Fingerprint} object records how a particular object (most typically a file,
39 * but it can be generalized to anything else that can be turned into a checksum) is used.
40 *
41 * Traditionally, this "use" is narrowly defined as "seen in build #N of job X", but this
42 * extension point generalizes this to allow arbitrary use (such as "deployed to Maven repository",
43 * "released to UAT environment", etc.
44 *
45 * <p>
46 * Plugins can just define subtypes of this and {@code fingerprint.getFacets().add(new MyFacet(fingerprint))}
47 * to add it to a fingerprint. The intended design is that every time some use happens, you create
48 * an instance of new facet and add it.
49 *
50 * <h2>Views</h2>
51 * <h4>main.groovy</h4>
52 * <p>
53 * This view is rendered into the
54 *
55 * @author Kohsuke Kawaguchi
56 * @since 1.421
57 * @see TransientFingerprintFacetFactory
58 */
59 public abstract class FingerprintFacet implements ExtensionPoint {
60 private transient Fingerprint fingerprint;
61
62 private final long timestamp;
63
64 /**
65 * @param fingerprint
66 * {@link Fingerprint} object to which this facet is going to be added to.
67 * @param timestamp
68 * Timestamp when the use happened.
69 */
70 protected FingerprintFacet(Fingerprint fingerprint, long timestamp) {
71 assert fingerprint!=null;
72 this.fingerprint = fingerprint;
73 this.timestamp = timestamp;
74 }
75
76 /**
77 * Gets the {@link Fingerprint} that this object belongs to.
78 *
79 * @return
80 * always non-null.
81 */
82 public Fingerprint getFingerprint() {
83 return fingerprint;
84 }
85
86 /**
87 * Create action objects to be contributed to the owner {@link Fingerprint}.
88 *
89 * <p>
90 * {@link Fingerprint} calls this method for every {@link FingerprintFacet} that
91 * it owns when the rendering is requested.
92 */
93 public void createActions(List<Action> result) {
94 }
95
96 /**
97 * Gets the timestamp associated with this facet.
98 * The rendering of facets are sorted by their chronological order.
99 */
100 public long getTimestamp() {
101 return timestamp;
102 }
103
104 /**
105 * Backdoor for {@link Fingerprint} to set itself to its facets.
106 * Public only because this needs to be accessible to {@link Fingerprint}. Do not call this method directly.
107 */
108 @Restricted(NoExternalUse.class)
109 public void _setOwner(Fingerprint fingerprint) {
110 assert fingerprint!=null;
111 this.fingerprint = fingerprint;
112 }
113 }
114