PageRenderTime 23ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/hudson-core/src/main/java/hudson/tools/ToolProperty.java

http://github.com/hudson/hudson
Java | 75 lines | 18 code | 6 blank | 51 comment | 0 complexity | 4719019f08525dd3c0f2586c4b75e684 MD5 | raw file
 1/*
 2 * The MIT License
 3 *
 4 * Copyright (c) 2004-2009, Sun Microsystems, 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 */
24package hudson.tools;
25
26import hudson.DescriptorExtensionList;
27import hudson.ExtensionPoint;
28import hudson.model.Describable;
29import hudson.model.Hudson;
30
31/**
32 * Extensible property of {@link ToolInstallation}.
33 *
34 * <p>
35 * Plugins can contribute this extension point to add additional data or UI actions to {@link ToolInstallation}.
36 * {@link ToolProperty}s show up in the configuration screen of a tool, and they are persisted with the {@link ToolInstallation} object.
37 *
38 *
39 * <h2>Views</h2>
40 * <dl>
41 * <dt>config.jelly</dt>
42 * <dd>Added to the configuration page of the tool.
43 * </dl>
44 *
45 * @param <T>
46 *      {@link ToolProperty} can choose to only work with a certain subtype of {@link ToolInstallation}, and this 'T'
47 *      represents that type. Also see {@link ToolPropertyDescriptor#isApplicable(Class)}.
48 *
49 * @since 1.303
50 */
51public abstract class ToolProperty<T extends ToolInstallation> implements Describable<ToolProperty<?>>, ExtensionPoint {
52    protected transient T tool;
53
54    protected void setTool(T tool) {
55        this.tool = tool;
56    }
57
58    public ToolPropertyDescriptor getDescriptor() {
59        return (ToolPropertyDescriptor) Hudson.getInstance().getDescriptorOrDie(getClass());
60    }
61
62    /**
63     * What is your 'T'?
64     */
65    public abstract Class<T> type();
66
67    /**
68     * Lists up all the registered {@link ToolPropertyDescriptor}s in the system.
69     *
70     * @see ToolDescriptor#getPropertyDescriptors() 
71     */
72    public static DescriptorExtensionList<ToolProperty<?>,ToolPropertyDescriptor> all() {
73        return (DescriptorExtensionList)Hudson.getInstance().getDescriptorList(ToolProperty.class);
74    }
75}