diff --git a/core/src/main/java/hudson/ExtensionList.java b/core/src/main/java/hudson/ExtensionList.java index 397f57030dbb..8cf98253dc26 100644 --- a/core/src/main/java/hudson/ExtensionList.java +++ b/core/src/main/java/hudson/ExtensionList.java @@ -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'. @@ -68,7 +69,7 @@ * @see jenkins.model.Jenkins#getExtensionList(Class) * @see jenkins.model.Jenkins#getDescriptorList(Class) */ -public class ExtensionList extends AbstractList { +public class ExtensionList extends AbstractList implements OnMaster { /** * @deprecated as of 1.417 * Use {@link #jenkins} diff --git a/core/src/main/java/hudson/ExtensionPoint.java b/core/src/main/java/hudson/ExtensionPoint.java index f49a5a096cc7..5af5d4c28327 100644 --- a/core/src/main/java/hudson/ExtensionPoint.java +++ b/core/src/main/java/hudson/ExtensionPoint.java @@ -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 @@ -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 diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 66a2ff90e73a..afe5fec528ec 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -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.*; @@ -125,7 +126,7 @@ * @author Kohsuke Kawaguchi * @see Describable */ -public abstract class Descriptor> implements Saveable { +public abstract class Descriptor> implements Saveable, OnMaster { /** * The class being described by this descriptor. */ diff --git a/core/src/main/java/hudson/model/Item.java b/core/src/main/java/hudson/model/Item.java index 6706f2b492a3..a63a7d49e722 100644 --- a/core/src/main/java/hudson/model/Item.java +++ b/core/src/main/java/hudson/model/Item.java @@ -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; @@ -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. */ diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index f66ef2109570..ac6431b15171 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -128,7 +128,7 @@ * @author Kohsuke Kawaguchi */ public abstract class Job, RunT extends Run> - extends AbstractItem implements ExtensionPoint, StaplerOverridable, ModelObjectWithChildren, OnMaster { + extends AbstractItem implements ExtensionPoint, StaplerOverridable, ModelObjectWithChildren { private static final Logger LOGGER = Logger.getLogger(Job.class.getName()); diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 66090849f9ea..8dd4e31d1061 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -212,6 +212,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; @@ -323,7 +324,7 @@ @ExportedBean public class Jenkins extends AbstractCIBase implements DirectlyModifiableTopLevelItemGroup, StaplerProxy, StaplerFallback, ModifiableViewGroup, AccessControlled, DescriptorByNameOwner, - ModelObjectWithContextMenu, ModelObjectWithChildren { + ModelObjectWithContextMenu, ModelObjectWithChildren, OnMaster { private transient final Queue queue; /** diff --git a/core/src/main/java/jenkins/util/io/OnMaster.java b/core/src/main/java/jenkins/util/io/OnMaster.java index dccd02d6ceb3..e8006d6b890b 100644 --- a/core/src/main/java/jenkins/util/io/OnMaster.java +++ b/core/src/main/java/jenkins/util/io/OnMaster.java @@ -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 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); +// } +// } }