提交 1dec420e 编写于 作者: K kohsuke

updated Node to support auto-discovery

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15665 71c3de6d-444a-0410-be80-ed276b4c234a
上级 791aab92
......@@ -56,6 +56,16 @@ public final class DescriptorExtensionList<T extends Describable<T>> extends Ext
this.describableType = describableType;
}
/**
* Finds the descriptor that has the matching fully-qualified class name.
*
* @param fqcn
* Fully qualified name of the descriptor, not the describable.
*/
public Descriptor<T> find(String fqcn) {
return Descriptor.find(this,fqcn);
}
/**
* Loading the descriptors in this case means filtering the descriptor from the master {@link ExtensionList}.
*/
......@@ -74,13 +84,6 @@ public final class DescriptorExtensionList<T extends Describable<T>> extends Ext
return r;
}
/**
* Obtain the statically-scoped storage to store manulaly registered {@link Descriptor}s.
*/
private static List allocateLegacyInstanceStore(Class describableType) {
return legacyDescriptors.get(describableType);
}
/**
* Stores manually registered Descriptor instances.
*/
......
......@@ -194,7 +194,7 @@ public final class ComputerSet extends AbstractModelObject {
return;
}
req.setAttribute("descriptor", NodeDescriptor.ALL.find(mode));
req.setAttribute("descriptor", NodeDescriptor.all().find(mode));
req.getView(this,"_new.jelly").forward(req,rsp);
}
}
......@@ -211,7 +211,7 @@ public final class ComputerSet extends AbstractModelObject {
if (checkName(req, rsp, name)) return;
Node result = NodeDescriptor.ALL.find(type).newInstance(req, req.getSubmittedForm());
Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm());
app.addNode(result);
// take the user back to the slave list top page
......
......@@ -35,7 +35,6 @@ import hudson.slaves.ComputerLauncher;
import hudson.slaves.DumbSlave;
import hudson.slaves.JNLPLauncher;
import hudson.slaves.NodeDescriptor;
import hudson.slaves.NodeProperties;
import hudson.slaves.NodeProperty;
import hudson.slaves.NodePropertyDescriptor;
import hudson.slaves.RetentionStrategy;
......@@ -424,7 +423,9 @@ public abstract class Slave extends Node implements Serializable {
return this;
}
public abstract SlaveDescriptor getDescriptor();
public SlaveDescriptor getDescriptor() {
return (SlaveDescriptor)Hudson.getInstance().getDescriptor(getClass());
}
public static abstract class SlaveDescriptor extends NodeDescriptor {
public void doCheckNumExecutors() throws IOException, ServletException {
......
......@@ -25,6 +25,7 @@ package hudson.slaves;
import hudson.model.Slave;
import hudson.model.Descriptor.FormException;
import hudson.Extension;
import java.io.IOException;
import java.util.ArrayList;
......@@ -39,7 +40,6 @@ import org.kohsuke.stapler.DataBoundConstructor;
* @author Kohsuke Kawaguchi
*/
public final class DumbSlave extends Slave {
@Deprecated
public DumbSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Mode mode, String label, ComputerLauncher launcher, RetentionStrategy retentionStrategy) throws FormException, IOException {
this(name, nodeDescription, remoteFS, numExecutors, mode, label, launcher, retentionStrategy, new ArrayList());
......@@ -50,19 +50,10 @@ public final class DumbSlave extends Slave {
super(name, nodeDescription, remoteFS, numExecutors, mode, label, launcher, retentionStrategy, nodeProperties);
}
public DescriptorImpl getDescriptor() {
return DescriptorImpl.INSTANCE;
}
@Extension
public static final class DescriptorImpl extends SlaveDescriptor {
public static final DescriptorImpl INSTANCE = new DescriptorImpl();
public String getDisplayName() {
return Messages.DumbSlave_displayName();
}
}
static {
NodeDescriptor.ALL.add(DescriptorImpl.INSTANCE);
}
}
......@@ -26,7 +26,10 @@ package hudson.slaves;
import hudson.model.Descriptor;
import hudson.model.Slave;
import hudson.model.Node;
import hudson.model.Hudson;
import hudson.util.DescriptorList;
import hudson.Extension;
import hudson.DescriptorExtensionList;
/**
* {@link Descriptor} for {@link Slave}.
......@@ -58,11 +61,16 @@ public abstract class NodeDescriptor extends Descriptor<Node> {
}
/**
* All the registered instances.
* Returns all the registered {@link NodeDescriptor} descriptors.
*/
public static final DescriptorList<Node> ALL = new DescriptorList<Node>();
static {
ALL.load(DumbSlave.class);
public static DescriptorExtensionList<Node> all() {
return Hudson.getInstance().getDescriptorList(Node.class);
}
/**
* All the registered instances.
* @deprecated as of 1.286
* Use {@link #all()} for read access, and {@link Extension} for registration.
*/
public static final DescriptorList<Node> ALL = new DescriptorList<Node>(Node.class);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册