Skip to content
Permalink
Browse files
[JENKINS-32493] Move to ExtensionList.lookup
  • Loading branch information
Andres Rodriguez committed Feb 1, 2016
1 parent a32235d commit 4e5390964b230ea7cb9c2ddcf15816528a36e580
Showing with 7 additions and 20 deletions.
  1. +3 −10 src/main/java/jenkins/scm/api/SCMFileSystem.java
  2. +2 −5 src/main/java/jenkins/scm/api/SCMHead.java
  3. +2 −5 src/main/java/jenkins/scm/api/SCMSourceOwners.java
@@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.scm.SCM;
import jenkins.model.Jenkins;
@@ -112,11 +113,7 @@ public static SCMFileSystem of(@NonNull SCM scm) {
public static SCMFileSystem of(@NonNull SCM scm, @CheckForNull SCMRevision rev) {
scm.getClass(); // throw NPE if null
SCMFileSystem fallBack = null;
Jenkins j = Jenkins.getInstance();
if (j == null) {
return fallBack;
}
for (Builder b : j.getExtensionList(Builder.class)) { // TODO 1.572+ ExtensionList.lookup
for (Builder b : ExtensionList.lookup(Builder.class)) {
SCMFileSystem inspector = b.build(scm, rev);
if (inspector != null) {
if (inspector.isFixedRevision()) {
@@ -158,11 +155,7 @@ public static SCMFileSystem of(@NonNull SCMSource source, @NonNull SCMHead head,
@CheckForNull SCMRevision rev) {
source.getClass(); // throw NPE if null
SCMFileSystem fallBack = null;
Jenkins j = Jenkins.getInstance();
if (j == null) {
return fallBack;
}
for (Builder b : j.getExtensionList(Builder.class)) { // TODO 1.572+ ExtensionList.lookup
for (Builder b : ExtensionList.lookup(Builder.class)) {
SCMFileSystem inspector = b.build(source, head, rev);
if (inspector != null) {
if (inspector.isFixedRevision()) {
@@ -25,6 +25,7 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Item;
import hudson.model.ItemGroup;
@@ -137,11 +138,7 @@ public static abstract class HeadByItem implements ExtensionPoint {
*/
@CheckForNull
public static SCMHead findHead(Item item) {
Jenkins j = Jenkins.getInstance();
if (j == null) {
return null;
}
for (HeadByItem ext : j.getExtensionList(HeadByItem.class)) { // TODO 1.572+ ExtensionList.lookup
for (HeadByItem ext : ExtensionList.lookup(HeadByItem.class)) {
SCMHead head = ext.getHead(item);
if (head != null) {
return head;
@@ -26,6 +26,7 @@
import com.google.common.collect.Iterators;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import jenkins.model.Jenkins;

@@ -84,11 +85,7 @@ private static class All implements Iterable<SCMSourceOwner> {
* {@inheritDoc}
*/
public Iterator<SCMSourceOwner> iterator() {
Jenkins j = Jenkins.getInstance();
if (j == null) {
return Iterators.emptyIterator();
}
return new IteratorImpl(j.getExtensionList(Enumerator.class)); // TODO 1.572+ ExtensionList.lookup
return new IteratorImpl(ExtensionList.lookup(Enumerator.class));
}

/**

0 comments on commit 4e53909

Please sign in to comment.