Skip to content
Permalink
Browse files
[FIXED JENKINS-41767] default implementation for Config.getDescriptor…
…() to keep more backward compatability
  • Loading branch information
imod committed Feb 8, 2017
1 parent 65fed74 commit 30fe123b7f17172d6ffa43290b893f354bd59e2a
@@ -25,6 +25,7 @@ of this software and associated documentation files (the "Software"), to deal

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.model.*;
import jenkins.model.Jenkins;
import org.jenkinsci.lib.configprovider.ConfigProvider;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
@@ -105,7 +106,7 @@ public Config(@NonNull String id, String name, String comment, String content, @
* @return never null.
*/
public ConfigProvider getDescriptor() {
throw new IllegalStateException(getClass() + " must override 'getDescriptor()' this method!");
return (ConfigProvider) Jenkins.getActiveInstance().getDescriptorOrDie(this.getClass());
}

/**
@@ -47,11 +47,6 @@ public CustomConfig(String id, String name, String comment, String content, Stri
super(id, name, comment, content, providerId);
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(CustomConfigProvider.class);
}

@Extension(ordinal = 50)
public static class CustomConfigProvider extends AbstractConfigProviderImpl {

@@ -48,11 +48,6 @@ public GroovyScript(String id, String name, String comment, String content, Stri
super(id, name, comment, content, providerId);
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(GroovyConfigProvider.class);
}

@Extension(ordinal = 100)
public static class GroovyConfigProvider extends AbstractConfigProviderImpl {

@@ -65,11 +65,6 @@ private static String fixJsonContent(String content) {
return c;
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(JsonConfigProvider.class);
}

@Extension(ordinal = 180)
public static class JsonConfigProvider extends AbstractConfigProviderImpl {

@@ -71,11 +71,6 @@ public Boolean getIsReplaceAll() {
return isReplaceAll;
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(GlobalMavenSettingsConfigProvider.class);
}

@Extension(ordinal = 200)
public static class GlobalMavenSettingsConfigProvider extends AbstractMavenSettingsProvider {

@@ -68,11 +68,6 @@ public Boolean getIsReplaceAll() {
return isReplaceAll;
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(MavenSettingsConfigProvider.class);
}

@Extension(ordinal = 190)
public static class MavenSettingsConfigProvider extends AbstractMavenSettingsProvider {

@@ -51,11 +51,6 @@ public MavenToolchainsConfig(String id, String name, String comment, String cont
super(id, name, comment, content, providerId);
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(MavenToolchainsConfigProvider.class);
}

@Extension(ordinal = 180)
public static class MavenToolchainsConfigProvider extends AbstractConfigProviderImpl {

@@ -47,11 +47,6 @@ public XmlConfig(String id, String name, String comment, String content, String
super(id, name, comment, content, providerId);
}

@Override
public ConfigProvider getDescriptor() {
return Jenkins.getActiveInstance().getDescriptorByType(XmlConfigProvider.class);
}

@Extension(ordinal = 150)
public static class XmlConfigProvider extends AbstractConfigProviderImpl {

0 comments on commit 30fe123

Please sign in to comment.