mirror of https://github.com/jenkinsci/jenkins.git
updated PageDecorator to support auto discovery
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15674 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
parent
36e49dd616
commit
2c64b1337d
|
|
@ -1037,7 +1037,7 @@ public class Functions {
|
|||
* Gets all the {@link PageDecorator}s.
|
||||
*/
|
||||
public static List<PageDecorator> getPageDecorators() {
|
||||
return (List)PageDecorator.ALL;
|
||||
return PageDecorator.all();
|
||||
}
|
||||
|
||||
public static DescriptorList<Cloud> getCloudDescriptors() {
|
||||
|
|
|
|||
|
|
@ -536,7 +536,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
|
|||
l.onLoaded();
|
||||
|
||||
WindowsInstallerLink.registerIfApplicable();
|
||||
UsageStatistics.register();
|
||||
LoadStatistics.register();
|
||||
NodeProvisioner.launch();
|
||||
}
|
||||
|
|
@ -2043,7 +2042,7 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
|
|||
for( JobPropertyDescriptor d : JobPropertyDescriptor.all() )
|
||||
result &= configureDescriptor(req,json,d);
|
||||
|
||||
for( PageDecorator d : PageDecorator.ALL )
|
||||
for( PageDecorator d : PageDecorator.all() )
|
||||
result &= configureDescriptor(req,json,d);
|
||||
|
||||
for( JSONObject o : StructuredForm.toList(json,"plugin"))
|
||||
|
|
|
|||
|
|
@ -25,9 +25,11 @@ package hudson.model;
|
|||
|
||||
import hudson.ExtensionPoint;
|
||||
import hudson.Plugin;
|
||||
import hudson.ExtensionListView;
|
||||
import hudson.DescriptorExtensionList;
|
||||
import hudson.Extension;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* Participates in the rendering of HTML pages for all pages of Hudson.
|
||||
|
|
@ -42,8 +44,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
*
|
||||
* <h2>Life-cycle</h2>
|
||||
* <p>
|
||||
* Instances of this class is singleton. {@link Plugin}s that contribute this extension point
|
||||
* should instantiate a new decorator and add it to the {@link #ALL} list in {@link Plugin#start()}.
|
||||
* {@link Plugin}s that contribute this extension point
|
||||
* should implement a new decorator and put {@link Extension} on the class.
|
||||
*
|
||||
* <h2>Associated Views</h2>
|
||||
* <h4>global.jelly</h4>
|
||||
|
|
@ -74,15 +76,9 @@ public abstract class PageDecorator extends Descriptor<PageDecorator> implements
|
|||
super(yourClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Infers the type of the corresponding {@link Describable} from the outer class.
|
||||
* This version works when you follow the common convention, where a descriptor
|
||||
* is written as the static nested class of the describable class.
|
||||
*
|
||||
* @since 1.278
|
||||
*/
|
||||
protected PageDecorator() {
|
||||
}
|
||||
// this will never work because Descriptor and Describable are the same thing.
|
||||
// protected PageDecorator() {
|
||||
// }
|
||||
|
||||
public final Descriptor<PageDecorator> getDescriptor() {
|
||||
return this;
|
||||
|
|
@ -98,6 +94,15 @@ public abstract class PageDecorator extends Descriptor<PageDecorator> implements
|
|||
|
||||
/**
|
||||
* All the registered instances.
|
||||
* @deprecated as of 1.286
|
||||
* Use {@link #all()} for read access, and use {@link Extension} for registration.
|
||||
*/
|
||||
public static final List<PageDecorator> ALL = new CopyOnWriteArrayList<PageDecorator>();
|
||||
public static final List<PageDecorator> ALL = ExtensionListView.createList(PageDecorator.class);
|
||||
|
||||
/**
|
||||
* Returns all the registered {@link PageDecorator} descriptors.
|
||||
*/
|
||||
public static DescriptorExtensionList<PageDecorator,PageDecorator> all() {
|
||||
return Hudson.getInstance().getDescriptorList(PageDecorator.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -894,16 +894,13 @@ public class UpdateCenter extends AbstractModelObject {
|
|||
/**
|
||||
* Adds the update center data retriever to HTML.
|
||||
*/
|
||||
@Extension
|
||||
public static class PageDecoratorImpl extends PageDecorator {
|
||||
public PageDecoratorImpl() {
|
||||
super(PageDecoratorImpl.class);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
PageDecorator.ALL.add(new PageDecoratorImpl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sequence number generator.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ package hudson.model;
|
|||
import com.trilead.ssh2.crypto.Base64;
|
||||
import hudson.PluginWrapper;
|
||||
import hudson.Util;
|
||||
import hudson.Extension;
|
||||
import hudson.node_monitors.ArchitectureMonitor.DescriptorImpl;
|
||||
import static hudson.util.TimeUnit2.DAYS;
|
||||
import net.sf.json.JSONObject;
|
||||
|
|
@ -55,6 +56,7 @@ import java.util.zip.GZIPOutputStream;
|
|||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
@Extension
|
||||
public class UsageStatistics extends PageDecorator {
|
||||
private final String keyImage;
|
||||
|
||||
|
|
@ -81,16 +83,6 @@ public class UsageStatistics extends PageDecorator {
|
|||
load();
|
||||
}
|
||||
|
||||
// register the instance
|
||||
static {
|
||||
PageDecorator.ALL.add(new UsageStatistics());
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op, but calling this method makes sure that the static initializer is run.
|
||||
*/
|
||||
static void register() {}
|
||||
|
||||
/**
|
||||
* Returns true if it's time for us to check for new version.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue