Skip to content

Commit

Permalink
Merge pull request #3009 from daniel-beck/Computer-DescriptorByNameOwner
Browse files Browse the repository at this point in the history
Make Computer a DescriptorByNameOwner
  • Loading branch information
daniel-beck committed Sep 10, 2017
2 parents a13a9dd + a36199f commit 8f9ddca
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
4 changes: 0 additions & 4 deletions core/src/main/java/hudson/model/AbstractItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,6 @@ private Object readResolve() {
}
}

public Descriptor getDescriptorByName(String className) {
return Jenkins.getInstance().getDescriptorByName(className);
}

/**
* Accepts the new description.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public /*transient*/ abstract class Computer extends Actionable implements AccessControlled, ExecutorListener {
public /*transient*/ abstract class Computer extends Actionable implements AccessControlled, ExecutorListener, DescriptorByNameOwner {

private final CopyOnWriteArrayList<Executor> executors = new CopyOnWriteArrayList<Executor>();
// TODO:
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/hudson/model/DescriptorByNameOwner.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/
package hudson.model;

import jenkins.model.Jenkins;

/**
* Adds {@link #getDescriptorByName(String)} to bind {@link Descriptor}s to URL.
* Binding them at some specific object (instead of {@link jenkins.model.Jenkins}), allows
Expand All @@ -46,5 +48,7 @@ public interface DescriptorByNameOwner extends ModelObject {
* @param id
* Either {@link Descriptor#getId()} (recommended) or the short name.
*/
Descriptor getDescriptorByName(String id);
default Descriptor getDescriptorByName(String id) {
return Jenkins.getInstance().getDescriptorByName(id);
}
}
5 changes: 0 additions & 5 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -1015,11 +1015,6 @@ protected void dropLinks() {
return id != null ? id : Integer.toString(number);
}

@Override
public @CheckForNull Descriptor getDescriptorByName(String className) {
return Jenkins.getInstance().getDescriptorByName(className);
}

/**
* Get the root directory of this {@link Run} on the master.
* Files related to this {@link Run} should be stored below this directory.
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/java/hudson/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,6 @@ public boolean canDelete() {
return r;
}

public Descriptor getDescriptorByName(String className) {
return Jenkins.getInstance().getDescriptorByName(className);
}

public Object getDynamic(String token) {
for(Action action: getTransientActions()){
if(Objects.equals(action.getUrlName(), token))
Expand Down

0 comments on commit 8f9ddca

Please sign in to comment.