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