Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-38370] Start defining APIs that are for the master JVM only (#…
  • Loading branch information
stephenc authored and oleg-nenashev committed Oct 24, 2016
1 parent bedbe1a commit 37c4736
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 6 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/ExtensionList.java
Expand Up @@ -46,6 +46,7 @@
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import jenkins.util.io.OnMaster;

/**
* Retains the known extension instances for the given type 'T'.
Expand All @@ -68,7 +69,7 @@
* @see jenkins.model.Jenkins#getExtensionList(Class)
* @see jenkins.model.Jenkins#getDescriptorList(Class)
*/
public class ExtensionList<T> extends AbstractList<T> {
public class ExtensionList<T> extends AbstractList<T> implements OnMaster {
/**
* @deprecated as of 1.417
* Use {@link #jenkins}
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/ExtensionPoint.java
Expand Up @@ -29,6 +29,7 @@
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import jenkins.util.io.OnMaster;

/**
* Marker interface that designates extensible components
Expand All @@ -47,7 +48,7 @@
* @see Plugin
* @see Extension
*/
public interface ExtensionPoint {
public interface ExtensionPoint extends OnMaster {
/**
* Used by designers of extension points (direct subtypes of {@link ExtensionPoint}) to indicate that
* the legacy instances are scoped to {@link Jenkins} instance. By default, legacy instances are
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/Descriptor.java
Expand Up @@ -39,6 +39,7 @@
import jenkins.model.GlobalConfiguration;
import jenkins.model.GlobalConfigurationCategory;
import jenkins.model.Jenkins;
import jenkins.util.io.OnMaster;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.*;
Expand Down Expand Up @@ -125,7 +126,7 @@
* @author Kohsuke Kawaguchi
* @see Describable
*/
public abstract class Descriptor<T extends Describable<T>> implements Saveable {
public abstract class Descriptor<T extends Describable<T>> implements Saveable, OnMaster {
/**
* The class being described by this descriptor.
*/
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/Item.java
Expand Up @@ -27,6 +27,7 @@
import hudson.Functions;
import jenkins.util.SystemProperties;
import hudson.security.PermissionScope;
import jenkins.util.io.OnMaster;
import org.kohsuke.stapler.StaplerRequest;

import java.io.IOException;
Expand Down Expand Up @@ -67,7 +68,7 @@
* @see Items
* @see ItemVisitor
*/
public interface Item extends PersistenceRoot, SearchableModelObject, AccessControlled {
public interface Item extends PersistenceRoot, SearchableModelObject, AccessControlled, OnMaster {
/**
* Gets the parent that contains this item.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Job.java
Expand Up @@ -128,7 +128,7 @@
* @author Kohsuke Kawaguchi
*/
public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, RunT>>
extends AbstractItem implements ExtensionPoint, StaplerOverridable, ModelObjectWithChildren, OnMaster {
extends AbstractItem implements ExtensionPoint, StaplerOverridable, ModelObjectWithChildren {

private static final Logger LOGGER = Logger.getLogger(Job.class.getName());

Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -213,6 +213,7 @@
import jenkins.util.JenkinsJVM;
import jenkins.util.Timer;
import jenkins.util.io.FileBoolean;
import jenkins.util.io.OnMaster;
import jenkins.util.xml.XMLUtils;
import net.jcip.annotations.GuardedBy;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -324,7 +325,7 @@
@ExportedBean
public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLevelItemGroup, StaplerProxy, StaplerFallback,
ModifiableViewGroup, AccessControlled, DescriptorByNameOwner,
ModelObjectWithContextMenu, ModelObjectWithChildren {
ModelObjectWithContextMenu, ModelObjectWithChildren, OnMaster {
private transient final Queue queue;

/**
Expand Down
32 changes: 32 additions & 0 deletions core/src/main/java/jenkins/util/io/OnMaster.java
Expand Up @@ -16,4 +16,36 @@
* @since 1.475
*/
public interface OnMaster {
// TODO uncomment once we can have a delegating ClassFilter, also add SystemProperty to toggle feature
// @Extension
// @Restricted(NoExternalUse.class)
// class ChannelConfiguratorImpl extends ChannelConfigurator {
// @Override
// public void onChannelBuilding(ChannelBuilder builder, @Nullable Object context) {
// if (context instanceof SlaveComputer) {
// builder.withClassFilter(new ClassFilterImpl(builder.getClassFilter(), OnMaster.class.getName, ...));
// }
// }
// }
//
// @Restricted(NoExternalUse.class)
// class ClassFilterImpl extends ClassFilter {
// private final ClassFilter delegate;
// private final Set<String> blacklist;
//
// public ClassFilterImpl(ClassFilter delegate, String... blacklist) {
// this.blacklist = new HashSet<>(blacklist);
// this.delegate = delegate;
// }
//
// @Override
// protected boolean isBlacklisted(String name) {
// return blacklist.contains(name) || delegate.isBlacklisted(name);
// }
//
// @Override
// protected boolean isBlacklisted(Class c) {
// return c.getAnnotation(MasterJVMOnly.class) != null || delegate.isBlacklisted(c);
// }
// }
}

0 comments on commit 37c4736

Please sign in to comment.