提交 64392290 编写于 作者: K kohsuke

doc improvements

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15745 71c3de6d-444a-0410-be80-ed276b4c234a
上级 40445922
...@@ -29,11 +29,14 @@ import hudson.model.Describable; ...@@ -29,11 +29,14 @@ import hudson.model.Describable;
import hudson.tasks.BuildStep; import hudson.tasks.BuildStep;
/** /**
* {@link Descriptor} for {@link ToolInstallation}.
*
* @author huybrechts * @author huybrechts
* @since 1.286
*/ */
public abstract class ToolDescriptor<T extends ToolInstallation> extends Descriptor<ToolInstallation> { public abstract class ToolDescriptor<T extends ToolInstallation> extends Descriptor<ToolInstallation> {
T[] installations; private T[] installations;
public T[] getInstallations() { public T[] getInstallations() {
return installations; return installations;
...@@ -42,6 +45,4 @@ public abstract class ToolDescriptor<T extends ToolInstallation> extends Descrip ...@@ -42,6 +45,4 @@ public abstract class ToolDescriptor<T extends ToolInstallation> extends Descrip
public void setInstallations(T[] installations) { public void setInstallations(T[] installations) {
this.installations = installations; this.installations = installations;
} }
public abstract String getDisplayName();
} }
...@@ -27,15 +27,38 @@ package hudson.tools; ...@@ -27,15 +27,38 @@ package hudson.tools;
import hudson.model.Describable; import hudson.model.Describable;
import hudson.model.Descriptor; import hudson.model.Descriptor;
import hudson.model.Hudson; import hudson.model.Hudson;
import hudson.model.JDK;
import hudson.DescriptorExtensionList; import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.Extension;
import hudson.tasks.BuildWrapper; import hudson.tasks.BuildWrapper;
import java.io.Serializable; import java.io.Serializable;
/** /**
* Formalization of a tool installed in nodes used for builds
* (examples include things like JDKs, Ants, Mavens, and Groovys)
*
* <p>
* You can define such a concept in your plugin entirely on your own, without extending from
* this class, but choosing this class as a base class has several benefits:
*
* <ul>
* <li>Hudson allows admins to specify different locations for tools on some slaves.
* For example, JDK on the master might be on /usr/local/java but on a Windows slave
* it could be at c:\Program Files\Java
* <li>Hudson can verify the existence of tools and provide warnings and diagnostics for
* admins. (TBD)
* <li>Hudson can perform automatic installations for users. (TBD)
* </ul>
*
* <p>
* To contribute an extension point, put {@link Extension} on your {@link ToolDescriptor} class.
*
* @author huybrechts * @author huybrechts
* @since 1.286
*/ */
public abstract class ToolInstallation implements Serializable, Describable<ToolInstallation> { public abstract class ToolInstallation implements Serializable, Describable<ToolInstallation>, ExtensionPoint {
private final String name; private final String name;
private final String home; private final String home;
...@@ -45,20 +68,34 @@ public abstract class ToolInstallation implements Serializable, Describable<Tool ...@@ -45,20 +68,34 @@ public abstract class ToolInstallation implements Serializable, Describable<Tool
this.home = home; this.home = home;
} }
/**
* Gets the human readable name that identifies this tool among other {@link ToolInstallation}s of the same kind.
*/
public String getName() {
return name;
}
/**
* Gets the home directory of this tool.
*
* The path can be in Unix format as well as in Windows format.
* Must be absolute.
*/
public String getHome() { public String getHome() {
return home; return home;
} }
public String getName() {
return name;
}
public ToolDescriptor<?> getDescriptor() { public ToolDescriptor<?> getDescriptor() {
return (ToolDescriptor) Hudson.getInstance().getDescriptor(getClass()); return (ToolDescriptor) Hudson.getInstance().getDescriptor(getClass());
} }
/**
* Returns all the registered {@link ToolDescriptor}s.
*/
public static DescriptorExtensionList<ToolInstallation,ToolDescriptor<?>> all() { public static DescriptorExtensionList<ToolInstallation,ToolDescriptor<?>> all() {
// use getDescriptorList and not getExtensionList to pick up legacy instances // use getDescriptorList and not getExtensionList to pick up legacy instances
return Hudson.getInstance().getDescriptorList(ToolInstallation.class); return Hudson.getInstance().getDescriptorList(ToolInstallation.class);
} }
private static final long serialVersionUID = 1L;
} }
...@@ -24,25 +24,24 @@ ...@@ -24,25 +24,24 @@
package hudson.tools; package hudson.tools;
import hudson.model.Node; import hudson.DescriptorExtensionList;
import hudson.model.Hudson; import hudson.Extension;
import hudson.model.Descriptor; import hudson.model.Descriptor;
import hudson.model.Hudson;
import hudson.model.Node;
import hudson.slaves.NodeProperty; import hudson.slaves.NodeProperty;
import hudson.slaves.NodePropertyDescriptor; import hudson.slaves.NodePropertyDescriptor;
import hudson.tasks.Ant;
import hudson.DescriptorExtensionList;
import hudson.Extension;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundConstructor;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* {@link NodeProperty} that allows users to specify different locations for {@link ToolInstallation}s.
*
* @since 1.286
*/
public class ToolLocationNodeProperty extends NodeProperty<Node> { public class ToolLocationNodeProperty extends NodeProperty<Node> {
private final List<ToolLocation> locations; private final List<ToolLocation> locations;
...@@ -85,7 +84,7 @@ public class ToolLocationNodeProperty extends NodeProperty<Node> { ...@@ -85,7 +84,7 @@ public class ToolLocationNodeProperty extends NodeProperty<Node> {
return "Tool Locations"; return "Tool Locations";
} }
public synchronized DescriptorExtensionList<ToolInstallation,ToolDescriptor<ToolInstallation>> getToolDescriptors() { public synchronized DescriptorExtensionList<ToolInstallation,ToolDescriptor<?>> getToolDescriptors() {
return ToolInstallation.all(); return ToolInstallation.all();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册