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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Tom Huybrechts
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 hudson.tools;
25
26 import hudson.ExtensionList;
27 import hudson.ExtensionPoint;
28 import hudson.slaves.NodeSpecific;
29 import jenkins.model.Jenkins;
30 import hudson.model.Node;
31 import hudson.model.TaskListener;
32
33 import java.io.File;
34 import java.io.IOException;
35
36 /**
37 * This Jenkins-wide extension points can participate in determining the actual node-specific path
38 * of the {@link ToolInstallation} for the given {@link Node}.
39 *
40 * <p>
41 * This extension point is useful when there's a deterministic rule of where tools are installed.
42 * One can program such a logic and contribute a {@link ToolLocationTranslator}.
43 * Compared to manually specifying {@link ToolLocationNodeProperty}, duplicated configurations
44 * can be avoided this way.
45 *
46 * <p>
47 * Entry point to the translation process is
48 *
49 * @author Kohsuke Kawaguchi
50 * @since 1.299
51 * @see ToolInstallation#translateFor(Node, TaskListener)
52 */
53 public abstract class ToolLocationTranslator implements ExtensionPoint {
54 /**
55 * Called for each {@link ToolInstallation#translateFor(Node, TaskListener)} invocations
56 * (which normally means it's invoked for each {@link NodeSpecific#forNode(Node, TaskListener)})
57 * to translate the tool location into the node specific location.
58 *
59 * <p>
60 * If this implementation is capable of determining the location, return the path in the absolute file name.
61 * (This method doesn't return {@link File} so that it can handle path names of a different OS.
62 *
63 * <p>
64 * Otherwise return null to let other {@link ToolLocationTranslator}s a chance to do translations
65 * on their own.
66 */
67 public abstract String getToolHome(Node node, ToolInstallation installation, TaskListener log) throws IOException, InterruptedException;
68
69 /**
70 * Returns all the registered {@link ToolLocationTranslator}s.
71 */
72 public static ExtensionList<ToolLocationTranslator> all() {
73 return Jenkins.getInstance().getExtensionList(ToolLocationTranslator.class);
74 }
75 }
76