diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 5cd2e4857a..fda8c3e054 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import com.google.common.collect.Lists; import hudson.Plugin.DummyImpl; import hudson.PluginWrapper.Dependency; diff --git a/core/src/main/java/hudson/DNSMultiCast.java b/core/src/main/java/hudson/DNSMultiCast.java index 4d2eb1816d..2ed4f28746 100644 --- a/core/src/main/java/hudson/DNSMultiCast.java +++ b/core/src/main/java/hudson/DNSMultiCast.java @@ -1,5 +1,6 @@ package hudson; +import jenkins.util.SystemProperties; import jenkins.model.Jenkins; import jenkins.model.Jenkins.MasterComputer; diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 536cfe679b..61817e9dde 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -25,6 +25,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import com.jcraft.jzlib.GZIPInputStream; import com.jcraft.jzlib.GZIPOutputStream; import hudson.Launcher.LocalLauncher; diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index ca26fb0d6f..1cd644ebfd 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -25,6 +25,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import hudson.cli.CLICommand; import hudson.console.ConsoleAnnotationDescriptor; import hudson.console.ConsoleAnnotatorFactory; @@ -616,7 +617,7 @@ public class Functions { response.addCookie(c); } if (refresh) { - response.addHeader("Refresh", SystemProperties.getProperty("hudson.Functions.autoRefreshSeconds", "10")); + response.addHeader("Refresh", SystemProperties.getString("hudson.Functions.autoRefreshSeconds", "10")); } } @@ -838,7 +839,7 @@ public class Functions { */ public static String getFooterURL() { if(footerURL == null) { - footerURL = SystemProperties.getProperty("hudson.footerURL"); + footerURL = SystemProperties.getString("hudson.footerURL"); if(StringUtils.isBlank(footerURL)) { footerURL = "http://jenkins-ci.org/"; } diff --git a/core/src/main/java/hudson/LocalPluginManager.java b/core/src/main/java/hudson/LocalPluginManager.java index 62aee91afa..acbac8e412 100644 --- a/core/src/main/java/hudson/LocalPluginManager.java +++ b/core/src/main/java/hudson/LocalPluginManager.java @@ -24,6 +24,7 @@ package hudson; +import jenkins.util.SystemProperties; import jenkins.model.Jenkins; import javax.servlet.ServletContext; @@ -60,7 +61,7 @@ public class LocalPluginManager extends PluginManager { @Override protected Collection loadBundledPlugins() { // this is used in tests, when we want to override the default bundled plugins with .jpl (or .hpl) versions - if (SystemProperties.getProperty("hudson.bundled.plugins") != null) { + if (SystemProperties.getString("hudson.bundled.plugins") != null) { return Collections.emptySet(); } diff --git a/core/src/main/java/hudson/Main.java b/core/src/main/java/hudson/Main.java index c1aaab9786..8e8ec46dd4 100644 --- a/core/src/main/java/hudson/Main.java +++ b/core/src/main/java/hudson/Main.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import hudson.util.DualOutputStream; import hudson.util.EncodingStream; import com.thoughtworks.xstream.core.util.Base64Encoder; diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index d96c68dc20..802bbf180f 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import hudson.PluginWrapper.Dependency; import hudson.init.InitMilestone; import hudson.init.InitStrategy; @@ -633,7 +634,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas * Creates a hudson.PluginStrategy, looking at the corresponding system property. */ protected PluginStrategy createPluginStrategy() { - String strategyName = SystemProperties.getProperty(PluginStrategy.class.getName()); + String strategyName = SystemProperties.getString(PluginStrategy.class.getName()); if (strategyName != null) { try { Class klazz = getClass().getClassLoader().loadClass(strategyName); diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index 7fe14e0496..8e4b075344 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import hudson.slaves.OfflineCause; import jenkins.AgentProtocol; @@ -203,7 +204,7 @@ public final class TcpSlaveAgentListener extends Thread { * * TODO: think about how to expose this (including whether this needs to be exposed at all.) */ - public static String CLI_HOST_NAME = SystemProperties.getProperty(TcpSlaveAgentListener.class.getName()+".hostName"); + public static String CLI_HOST_NAME = SystemProperties.getString(TcpSlaveAgentListener.class.getName()+".hostName"); /** * Port number that we advertise the CLI client to connect to. diff --git a/core/src/main/java/hudson/UDPBroadcastThread.java b/core/src/main/java/hudson/UDPBroadcastThread.java index bb9b5aa708..9824f6c027 100644 --- a/core/src/main/java/hudson/UDPBroadcastThread.java +++ b/core/src/main/java/hudson/UDPBroadcastThread.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import edu.umd.cs.findbugs.annotations.SuppressWarnings; import hudson.model.Hudson; import jenkins.model.Jenkins; diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index c3c649dc48..f4d9ae5177 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.NativeLong; diff --git a/core/src/main/java/hudson/WebAppMain.java b/core/src/main/java/hudson/WebAppMain.java index 99bdef5641..b7b3d0ed8e 100644 --- a/core/src/main/java/hudson/WebAppMain.java +++ b/core/src/main/java/hudson/WebAppMain.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.util.SystemProperties; import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider; import com.thoughtworks.xstream.core.JVM; import com.trilead.ssh2.util.IOUtils; @@ -359,7 +360,7 @@ public class WebAppMain implements ServletContextListener { // next the system property for (String name : HOME_NAMES) { - String sysProp = SystemProperties.getProperty(name); + String sysProp = SystemProperties.getString(name); if(sysProp!=null) return new FileAndDescription(new File(sysProp.trim()),"SystemProperties.getProperty(\""+name+"\")"); } diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index d18a66464c..4995a38c82 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -29,7 +29,7 @@ import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.cli.declarative.CLIMethod; import hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.cli.declarative.OptionHandlerExtension; import jenkins.model.Jenkins; import hudson.remoting.Callable; @@ -419,7 +419,7 @@ public abstract class CLICommand implements ExtensionPoint, Cloneable { } public String call() throws IOException { - return SystemProperties.getProperty(name); + return SystemProperties.getString(name); } private static final long serialVersionUID = 1L; diff --git a/core/src/main/java/hudson/init/InitStrategy.java b/core/src/main/java/hudson/init/InitStrategy.java index 1ba014597d..69227afb61 100644 --- a/core/src/main/java/hudson/init/InitStrategy.java +++ b/core/src/main/java/hudson/init/InitStrategy.java @@ -15,7 +15,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import hudson.PluginManager; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.util.DirScanner; import hudson.util.FileVisitor; import hudson.util.Service; @@ -85,7 +85,7 @@ public class InitStrategy { * TODO: maven-hpi-plugin should inject its own InitStrategy instead of having this in the core. */ protected void getBundledPluginsFromProperty(final List r) { - String hplProperty = SystemProperties.getProperty("hudson.bundled.plugins"); + String hplProperty = SystemProperties.getString("hudson.bundled.plugins"); if (hplProperty != null) { for (String hplLocation : hplProperty.split(",")) { File hpl = new File(hplLocation.trim()); diff --git a/core/src/main/java/hudson/lifecycle/Lifecycle.java b/core/src/main/java/hudson/lifecycle/Lifecycle.java index b768cc545c..34915da0de 100644 --- a/core/src/main/java/hudson/lifecycle/Lifecycle.java +++ b/core/src/main/java/hudson/lifecycle/Lifecycle.java @@ -25,7 +25,7 @@ package hudson.lifecycle; import hudson.ExtensionPoint; import hudson.Functions; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.Util; import jenkins.model.Jenkins; @@ -58,7 +58,7 @@ public abstract class Lifecycle implements ExtensionPoint { public synchronized static Lifecycle get() { if(INSTANCE==null) { Lifecycle instance; - String p = SystemProperties.getProperty("hudson.lifecycle"); + String p = SystemProperties.getString("hudson.lifecycle"); if(p!=null) { try { ClassLoader cl = Jenkins.getInstance().getPluginManager().uberClassLoader; @@ -120,7 +120,7 @@ public abstract class Lifecycle implements ExtensionPoint { * to a newer version. */ public File getHudsonWar() { - String war = SystemProperties.getProperty("executable-war"); + String war = SystemProperties.getString("executable-war"); if(war!=null && new File(war).exists()) return new File(war); return null; diff --git a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java index afef84e84e..978b3c7965 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java +++ b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java @@ -34,7 +34,7 @@ import hudson.util.jna.Shell32; import jenkins.model.Jenkins; import hudson.AbortException; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.util.StreamTaskListener; import hudson.util.jna.DotNet; import org.apache.commons.io.IOUtils; @@ -258,14 +258,14 @@ public class WindowsInstallerLink extends ManagementLink { // this system property is set by the launcher when we run "java -jar jenkins.war" // and this is how we know where is jenkins.war. - String war = SystemProperties.getProperty("executable-war"); + String war = SystemProperties.getString("executable-war"); if(war!=null && new File(war).exists()) { WindowsInstallerLink link = new WindowsInstallerLink(new File(war)); // in certain situations where we know the user is just trying Jenkins (like when Jenkins is launched // from JNLP), also put this link on the navigation bar to increase // visibility - if(SystemProperties.getProperty(WindowsInstallerLink.class.getName()+".prominent")!=null) + if(SystemProperties.getString(WindowsInstallerLink.class.getName()+".prominent")!=null) Jenkins.getInstance().getActions().add(link); return link; diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index bb55d86198..e37e7a7347 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -30,7 +30,7 @@ import hudson.EnvVars; import hudson.FilePath; import hudson.Functions; import hudson.Launcher; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.console.ModelHyperlinkNote; import hudson.model.Fingerprint.BuildPtr; import hudson.model.Fingerprint.RangeSet; diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index f221a396d1..7f0f8673ec 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -29,7 +29,7 @@ import edu.umd.cs.findbugs.annotations.When; import hudson.EnvVars; import hudson.Extension; import hudson.Launcher.ProcStarter; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.Util; import hudson.cli.declarative.CLIMethod; import hudson.cli.declarative.CLIResolver; @@ -1273,7 +1273,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces private static class GetFallbackName extends MasterToSlaveCallable { public String call() throws IOException { - return SystemProperties.getProperty("host.name"); + return SystemProperties.getString("host.name"); } private static final long serialVersionUID = 1L; } diff --git a/core/src/main/java/hudson/model/DownloadService.java b/core/src/main/java/hudson/model/DownloadService.java index 359ff186bf..2af1515145 100644 --- a/core/src/main/java/hudson/model/DownloadService.java +++ b/core/src/main/java/hudson/model/DownloadService.java @@ -28,7 +28,7 @@ import hudson.ExtensionList; import hudson.ExtensionListListener; import hudson.ExtensionPoint; import hudson.ProxyConfiguration; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.init.InitMilestone; import hudson.init.Initializer; import hudson.util.FormValidation; diff --git a/core/src/main/java/hudson/model/FullDuplexHttpChannel.java b/core/src/main/java/hudson/model/FullDuplexHttpChannel.java index 872c6f9dc3..c0fdafb56f 100644 --- a/core/src/main/java/hudson/model/FullDuplexHttpChannel.java +++ b/core/src/main/java/hudson/model/FullDuplexHttpChannel.java @@ -23,7 +23,7 @@ */ package hudson.model; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.remoting.Channel; import hudson.remoting.PingThread; import hudson.remoting.Channel.Mode; diff --git a/core/src/main/java/hudson/model/Item.java b/core/src/main/java/hudson/model/Item.java index 50a8b23b38..9d43714841 100644 --- a/core/src/main/java/hudson/model/Item.java +++ b/core/src/main/java/hudson/model/Item.java @@ -25,7 +25,7 @@ package hudson.model; import hudson.Functions; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.security.PermissionScope; import org.kohsuke.stapler.StaplerRequest; diff --git a/core/src/main/java/hudson/model/LoadStatistics.java b/core/src/main/java/hudson/model/LoadStatistics.java index c905c4ab4e..728d79ddbb 100644 --- a/core/src/main/java/hudson/model/LoadStatistics.java +++ b/core/src/main/java/hudson/model/LoadStatistics.java @@ -24,7 +24,7 @@ package hudson.model; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.model.MultiStageTimeSeries.TimeScale; import hudson.model.MultiStageTimeSeries.TrendChart; import hudson.model.queue.SubTask; @@ -372,7 +372,7 @@ public abstract class LoadStatistics { * * Put differently, the half reduction time is {@code CLOCK*log(0.5)/log(DECAY)} */ - public static final float DECAY = Float.parseFloat(SystemProperties.getProperty(LoadStatistics.class.getName()+".decay","0.9")); + public static final float DECAY = Float.parseFloat(SystemProperties.getString(LoadStatistics.class.getName()+".decay","0.9")); /** * Load statistics clock cycle in milliseconds. Specify a small value for quickly debugging this feature and node provisioning through cloud. */ diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index df5c002c8d..f66303efa5 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -123,7 +123,7 @@ import org.kohsuke.accmod.restrictions.DoNotUse; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import javax.annotation.CheckForNull; import javax.annotation.Nonnegative; import jenkins.model.queue.AsynchronousExecution; diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index bf77d9fc52..8138bb4745 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -36,7 +36,7 @@ import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.FeedAdapter; import hudson.Functions; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.Util; import hudson.XmlFile; import hudson.cli.declarative.CLIMethod; @@ -1140,12 +1140,12 @@ public abstract class Run ,RunT extends Run { @Extension(ordinal=Double.NEGATIVE_INFINITY) public static final class DefaultHolderFactory implements HolderFactory { public static final String MODE_PROPERTY = "jenkins.model.lazy.BuildReference.MODE"; - private static final String mode = SystemProperties.getProperty(MODE_PROPERTY); + private static final String mode = SystemProperties.getString(MODE_PROPERTY); @Override public Holder make(R referent) { if (mode == null || mode.equals("soft")) { diff --git a/core/src/main/java/jenkins/security/ApiTokenProperty.java b/core/src/main/java/jenkins/security/ApiTokenProperty.java index 4e87c8b664..c478ab16f3 100644 --- a/core/src/main/java/jenkins/security/ApiTokenProperty.java +++ b/core/src/main/java/jenkins/security/ApiTokenProperty.java @@ -24,7 +24,7 @@ package jenkins.security; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.Util; import hudson.model.Descriptor.FormException; import hudson.model.User; diff --git a/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java b/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java index a0feec091d..4e3d60f7bd 100644 --- a/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java +++ b/core/src/main/java/jenkins/security/BasicHeaderRealPasswordAuthenticator.java @@ -15,7 +15,7 @@ package jenkins.security; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import jenkins.ExtensionFilter; import jenkins.model.Jenkins; import org.acegisecurity.Authentication; diff --git a/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java b/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java index 9155717606..7bf162a422 100644 --- a/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java +++ b/core/src/main/java/jenkins/security/FrameOptionsPageDecorator.java @@ -1,7 +1,7 @@ package jenkins.security; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.model.PageDecorator; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -14,5 +14,5 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; @Extension(ordinal = 1000) public class FrameOptionsPageDecorator extends PageDecorator { @Restricted(NoExternalUse.class) - public static boolean enabled = Boolean.valueOf(SystemProperties.getProperty(FrameOptionsPageDecorator.class.getName() + ".enabled", "true")); + public static boolean enabled = Boolean.valueOf(SystemProperties.getString(FrameOptionsPageDecorator.class.getName() + ".enabled", "true")); } diff --git a/core/src/main/java/jenkins/security/SecureRequester.java b/core/src/main/java/jenkins/security/SecureRequester.java index 5443898928..f13385cca7 100644 --- a/core/src/main/java/jenkins/security/SecureRequester.java +++ b/core/src/main/java/jenkins/security/SecureRequester.java @@ -2,7 +2,7 @@ package jenkins.security; import hudson.Extension; import hudson.ExtensionPoint; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.model.Api; import java.util.logging.Logger; import jenkins.model.Jenkins; diff --git a/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java b/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java index ab03d4ea16..1a63573576 100644 --- a/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java +++ b/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java @@ -1,7 +1,7 @@ package jenkins.security.s2m; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.remoting.Callable; import hudson.remoting.ChannelBuilder; import jenkins.security.ChannelConfigurator; diff --git a/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java b/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java index c4a810fe9b..562cb808fc 100644 --- a/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java +++ b/core/src/main/java/jenkins/security/s2m/DefaultFilePathFilter.java @@ -25,7 +25,7 @@ package jenkins.security.s2m; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.remoting.ChannelBuilder; import jenkins.ReflectiveFilePathFilter; import jenkins.security.ChannelConfigurator; diff --git a/core/src/main/java/jenkins/slaves/NioChannelSelector.java b/core/src/main/java/jenkins/slaves/NioChannelSelector.java index 97d97b4fbd..9401e7686d 100644 --- a/core/src/main/java/jenkins/slaves/NioChannelSelector.java +++ b/core/src/main/java/jenkins/slaves/NioChannelSelector.java @@ -1,7 +1,7 @@ package jenkins.slaves; import hudson.Extension; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.model.Computer; import org.jenkinsci.remoting.nio.NioChannelHub; diff --git a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java index 82efe25384..89fedfd04f 100644 --- a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java +++ b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java @@ -2,7 +2,7 @@ package jenkins.slaves; import hudson.Extension; import hudson.FilePath; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import hudson.model.Computer; import hudson.model.TaskListener; import hudson.remoting.Channel; diff --git a/core/src/main/java/hudson/SystemProperties.java b/core/src/main/java/jenkins/util/SystemProperties.java similarity index 63% rename from core/src/main/java/hudson/SystemProperties.java rename to core/src/main/java/jenkins/util/SystemProperties.java index 88fa83163f..04561ff4a5 100644 --- a/core/src/main/java/hudson/SystemProperties.java +++ b/core/src/main/java/jenkins/util/SystemProperties.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright 2015 Johannes Ernst, http://upon2020.com/. + * Copyright 2015 Johannes Ernst http://upon2020.com/ * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,29 +21,32 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package hudson; +package jenkins.util; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletContext; /** - * Centralizes calls to System.getProperty() and related calls. + * Centralizes calls to System.getProperty() and related calls. * This allows us to get values not just from environment variables but also from - * the ServletContext, so things like hudson.DNSMultiCast.disabled can be set - * in context.xml and the app server's boot script does not have to be changed. + * the ServletContext, so properties like hudson.DNSMultiCast.disabled + * can be set in context.xml and the app server's boot script does not + * have to be changed. * - * While it looks like it on first glamce, this cannot be mapped to EnvVars.java - * because EnvVars.java is only for build variables, not Jenkins itself variables. + *

While it looks like it on first glance, this cannot be mapped to EnvVars.java + * because EnvVars.java is only for build variables, not Jenkins itself variables. * - * This should be invoked for hudson parameters (e.g. hudson.DNSMultiCast.disabled), - * but not for system parameters (e.g. os.name). + *

This should be used to obtain hudson/jenkins "app"-level parameters + * (e.g. hudson.DNSMultiCast.disabled), but not for system parameters + * (e.g. os.name). * * @author Johannes Ernst + * @since 1.639 */ public class SystemProperties { /** - * The ServletContext to get the init parameters from. + * The ServletContext to get the "init" parameters from. */ private static ServletContext theContext; @@ -52,10 +55,15 @@ public class SystemProperties { */ private static final Logger LOGGER = Logger.getLogger(SystemProperties.class.getName()); + /** + * This class should never be instantiated. + */ + private SystemProperties() {} + /** * Gets the system property indicated by the specified key. - * This behaves just like System.getProperty(String), except that it - * also consults the ServletContext's init parameters. + * This behaves just like System.getProperty(String), except that it + * also consults the ServletContext's "init" parameters. * * @param key the name of the system property. * @return the string value of the system property, @@ -68,32 +76,31 @@ public class SystemProperties { * null. * @exception IllegalArgumentException if key is empty. */ - public static String getProperty(String key) { + public static String getString(String key) { String value = System.getProperty(key); // keep passing on any exceptions - if( value != null ) { - if( LOGGER.isLoggable(Level.INFO )) { - LOGGER.log(Level.INFO, "Property (system): {0} => {1}", new Object[]{ key, value }); + if (value != null) { + if (LOGGER.isLoggable(Level.INFO)) { + LOGGER.log(Level.INFO, "Property (system): {0} => {1}", new Object[] {key, value}); } - } else if( theContext != null ) { + } else if (theContext != null) { value = theContext.getInitParameter(key); - if( value != null ) { - if( LOGGER.isLoggable(Level.INFO )) { - LOGGER.log(Level.INFO, "Property (context): {0} => {1}", new Object[]{ key, value }); + if (value != null) { + if (LOGGER.isLoggable(Level.INFO)) { + LOGGER.log(Level.INFO, "Property (context): {0} => {1}", new Object[] {key, value}); } } } else { - if( LOGGER.isLoggable(Level.INFO )) { - LOGGER.log(Level.INFO, "Property (not found): {0} => {1}", new Object[]{ key, value }); + if (LOGGER.isLoggable(Level.INFO)) { + LOGGER.log(Level.INFO, "Property (not found): {0} => {1}", new Object[] {key, value}); } } - return value; } /** - * Gets the system property indicated by the specified key. - * This behaves just like System.getProperty(String), except that it - * also consults the ServletContext's init parameters. + * Gets the system property indicated by the specified key, or a default value. + * This behaves just like System.getProperty(String,String), except + * that it also consults the ServletContext's "init" parameters. * * @param key the name of the system property. * @param def a default value. @@ -107,24 +114,24 @@ public class SystemProperties { * null. * @exception IllegalArgumentException if key is empty. */ - public static String getProperty(String key, String def) { + public static String getString(String key, String def) { String value = System.getProperty(key); // keep passing on any exceptions - if( value != null ) { - if( LOGGER.isLoggable(Level.INFO )) { - LOGGER.log(Level.INFO, "Property (system): {0} => {1}", new Object[]{ key, value }); + if (value != null) { + if (LOGGER.isLoggable(Level.INFO)) { + LOGGER.log(Level.INFO, "Property (system): {0} => {1}", new Object[] {key, value}); } - } else if( theContext != null ) { + } else if (theContext != null) { value = theContext.getInitParameter(key); - if( value != null ) { - if( LOGGER.isLoggable(Level.INFO )) { - LOGGER.log(Level.INFO, "Property (context): {0} => {1}", new Object[]{ key, value }); + if (value != null) { + if(LOGGER.isLoggable(Level.INFO)) { + LOGGER.log(Level.INFO, "Property (context): {0} => {1}", new Object[] {key, value}); } } } - if( value == null ) { + if (value == null) { value = def; - if( LOGGER.isLoggable(Level.INFO )) { - LOGGER.log(Level.INFO, "Property (default): {0} => {1}", new Object[]{ key, value }); + if (LOGGER.isLoggable(Level.INFO)) { + LOGGER.log(Level.INFO, "Property (default): {0} => {1}", new Object[] {key, value}); } } return value; @@ -134,11 +141,11 @@ public class SystemProperties { * Returns {@code true} if the system property * named by the argument exists and is equal to the string * {@code "true"}. If the system property does not exist, return - * {@code "true"} if a property by this name exists in the servletcontext + * {@code "true"} if a property by this name exists in the ServletContext * and is equal to the string {@code "true"}. * - * This behaves just like Boolean.getBoolean(String), except that it - * also consults the ServletContext's init parameters. + * This behaves just like Boolean.getBoolean(String), except that it + * also consults the ServletContext's "init" parameters. * * @param name the system property name. * @return the {@code boolean} value of the system property. @@ -150,20 +157,20 @@ public class SystemProperties { /** * Returns {@code true} if the system property * named by the argument exists and is equal to the string - * {@code "true"}. If the system property does not exist, return - * {@code "true"} if a property by this name exists in the servletcontext + * {@code "true"}, or a default value. If the system property does not exist, return + * {@code "true"} if a property by this name exists in the ServletContext * and is equal to the string {@code "true"}. If that property does not * exist either, return the default value. * - * This behaves just like Boolean.getBoolean(String), except that it - * also consults the ServletContext's init parameters. + * This behaves just like Boolean.getBoolean(String) with a default + * value, except that it also consults the ServletContext's "init" parameters. * * @param name the system property name. * @param def a default value. * @return the {@code boolean} value of the system property. */ public static boolean getBoolean(String name, boolean def) { - String v = getProperty(name); + String v = getString(name); if (v != null) { return Boolean.parseBoolean(v); @@ -175,31 +182,30 @@ public class SystemProperties { * Determines the integer value of the system property with the * specified name. * - * This behaves just like Integer.getInteger(String), except that it - * also consults the ServletContext's init parameters. + * This behaves just like Integer.getInteger(String), except that it + * also consults the ServletContext's "init" parameters. * * @param name property name. * @return the {@code Integer} value of the property. */ public static Integer getInteger(String name) { - return getInteger( name, null ); + return getInteger(name, null); } /** * Determines the integer value of the system property with the - * specified name. + * specified name, or a default value. * - * This behaves just like Integer.getInteger(String), except that it - * also consults the ServletContext's init parameters. If neither exist, + * This behaves just like Integer.getInteger(String,Integer), except that it + * also consults the ServletContext's "init" parameters. If neither exist, * return the default value. * * @param name property name. * @param def a default value. * @return the {@code Integer} value of the property. */ - public static Integer getInteger(String name, Integer def) { - String v = getProperty(name); + String v = getString(name); if (v != null) { try { @@ -209,10 +215,11 @@ public class SystemProperties { } return def; } + /** - * Invoked by WebAppMain, tells us where to get the init parameters from. + * Invoked by WebAppMain, tells us where to get the "init" parameters from. * - * @param context the ServletContext obtained from contextInitialized + * @param context the ServletContext obtained from contextInitialized */ public static void initialize(ServletContext context) { theContext = context; diff --git a/core/src/main/java/jenkins/util/xml/XMLUtils.java b/core/src/main/java/jenkins/util/xml/XMLUtils.java index afe3bc844c..811adf308f 100644 --- a/core/src/main/java/jenkins/util/xml/XMLUtils.java +++ b/core/src/main/java/jenkins/util/xml/XMLUtils.java @@ -1,6 +1,6 @@ package jenkins.util.xml; -import hudson.SystemProperties; +import jenkins.util.SystemProperties; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.xml.sax.InputSource;