renamed ServerSettings to WebServerSettings and extract from it a ServerSetting interface to be able to easily provide separte implementations for Web Server and CE)
CE Server implementation is called ComputeEngineSettings which supports loading up to date Settings for a specific worker using delegation and a ThreadLocal
import org.sonar.api.utils.UriReader;
import org.sonar.ce.es.EsIndexerEnabler;
import org.sonar.ce.property.CePropertyDefinitions;
+import org.sonar.ce.settings.ComputeEngineSettings;
import org.sonar.core.component.DefaultResourceTypes;
import org.sonar.core.config.CorePropertyDefinitions;
import org.sonar.core.i18n.DefaultI18n;
import org.sonar.server.platform.ServerImpl;
import org.sonar.server.platform.ServerLifecycleNotifier;
import org.sonar.server.platform.ServerLogging;
-import org.sonar.server.platform.ServerSettings;
import org.sonar.server.platform.TempFolderProvider;
import org.sonar.server.plugins.InstalledPluginReferentialFactory;
import org.sonar.server.plugins.ServerExtensionInstaller;
public class ComputeEngineContainerImpl implements ComputeEngineContainer {
private static final Object[] LEVEL_1_COMPONENTS = new Object[] {
+ ComputeEngineSettings.class,
new SonarQubeVersionProvider(),
- ServerSettings.class,
ServerImpl.class,
UuidFactoryImpl.INSTANCE,
// no EmbeddedDatabaseFactory.class, creating H2 DB if responsibility of WebServer
// DB
DbClient.class,
DaoModule.class,
- // MigrationStepModule.class, DB maintenance, responsibility of Web Server
+ // MigrationStepModule.class, DB maintenance, responsibility of Web Server
// Elasticsearch
EsSearchModule.class,
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.ce.settings;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.Maps;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.Encryption;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.config.Settings;
+import org.sonar.core.platform.ComponentContainer;
+import org.sonar.db.DbClient;
+import org.sonar.db.property.PropertyDto;
+import org.sonar.server.platform.ServerSettings;
+
+import static com.google.common.base.Preconditions.checkState;
+
+/**
+ * This class implements ServerSettings and extends Settings so that it can be injected in any component depending upon
+ * either ServerSettings or Settings.
+ *
+ * <p>
+ * In order to honor both Settings and ThreadLocalSettings contracts, none of the code inherited from the Settings super
+ * class is actually used. Every public method of Settings is override and their implementation is delegated to
+ * an inner object which can either be the default one or one specific to the current Thread. Selected of the inner
+ * object will depend on whether the current Thread made use of method {@link #load()} or not. This approach also greatly
+ * simplifies delegation code (see {@link #currentDelegate()}).
+ * </p>
+ */
+public class ComputeEngineSettings extends Settings implements ThreadLocalSettings, ServerSettings {
+ private final ServerSettings defaultDelegate;
+ private final ThreadLocal<ServerSettings> threadLocalDelegate = new ThreadLocal<>();
+
+ private final Properties rootProperties;
+ private final ComponentContainer componentContainer;
+ // we can't get injected with DBClient because it creates a circular dependency
+ private volatile DbClient dbClient;
+
+ public ComputeEngineSettings(PropertyDefinitions definitions, Properties rootProperties, ComponentContainer componentContainer) {
+ super(definitions);
+ this.rootProperties = rootProperties;
+ this.componentContainer = componentContainer;
+
+ this.defaultDelegate = new ServerSettingsImpl(definitions, rootProperties);
+ }
+
+ @Override
+ public void load() {
+ checkState(
+ this.threadLocalDelegate.get() == null,
+ "loadLocal called twice for Thread '%' or state wasn't cleared last time it was used",
+ Thread.currentThread().getName());
+ this.threadLocalDelegate.set(loadServerSettings());
+ }
+
+ @Override
+ public void remove() {
+ this.threadLocalDelegate.remove();
+ }
+
+ private ServerSettings loadServerSettings() {
+ ServerSettings res = new ServerSettingsImpl(this.definitions, this.rootProperties);
+ Map<String, String> databaseProperties = Maps.newHashMap();
+ for (PropertyDto property : getDbClient().propertiesDao().selectGlobalProperties()) {
+ databaseProperties.put(property.getKey(), property.getValue());
+ }
+ res.activateDatabaseSettings(databaseProperties);
+ return res;
+ }
+
+ private DbClient getDbClient() {
+ if (dbClient == null) {
+ this.dbClient = componentContainer.getComponentByType(DbClient.class);
+ }
+ return dbClient;
+ }
+
+ private ServerSettings currentDelegate() {
+ return Objects.firstNonNull(threadLocalDelegate.get(), defaultDelegate);
+ }
+
+ private Settings currentSettings() {
+ return currentDelegate().getSettings();
+ }
+
+ @Override
+ public ServerSettings activateDatabaseSettings(Map<String, String> databaseProperties) {
+ checkState(threadLocalDelegate.get() == null, "activateDatabaseSettings must not be called from a Worker");
+
+ return defaultDelegate.activateDatabaseSettings(databaseProperties);
+ }
+
+ private static final class ServerSettingsImpl extends Settings implements ServerSettings {
+
+ private final Properties rootProperties;
+
+ public ServerSettingsImpl(PropertyDefinitions definitions, Properties rootProperties) {
+ super(definitions);
+ this.rootProperties = rootProperties;
+ addProperties(rootProperties);
+ // Secret key is loaded from conf/sonar.properties
+ getEncryption().setPathToSecretKey(getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
+ }
+
+ @Override
+ public ServerSettings activateDatabaseSettings(Map<String, String> databaseProperties) {
+ clear();
+
+ // order is important : the last override the first
+ addProperties(databaseProperties);
+ addProperties(rootProperties);
+
+ return this;
+ }
+
+ @Override
+ public Settings getSettings() {
+ return this;
+ }
+ }
+
+ @Override
+ public Settings getSettings() {
+ return this;
+ }
+
+ @Override
+ public Encryption getEncryption() {
+ return currentSettings().getEncryption();
+ }
+
+ @Override
+ @CheckForNull
+ public String getDefaultValue(String key) {
+ return currentSettings().getDefaultValue(key);
+ }
+
+ @Override
+ public boolean hasKey(String key) {
+ return currentSettings().hasKey(key);
+ }
+
+ @Override
+ public boolean hasDefaultValue(String key) {
+ return currentSettings().hasDefaultValue(key);
+ }
+
+ @Override
+ @CheckForNull
+ public String getString(String key) {
+ return currentDelegate().getString(key);
+ }
+
+ @Override
+ public boolean getBoolean(String key) {
+ return currentSettings().getBoolean(key);
+ }
+
+ @Override
+ public int getInt(String key) {
+ return currentSettings().getInt(key);
+ }
+
+ @Override
+ public long getLong(String key) {
+ return currentSettings().getLong(key);
+ }
+
+ @Override
+ @CheckForNull
+ public Date getDate(String key) {
+ return currentSettings().getDate(key);
+ }
+
+ @Override
+ @CheckForNull
+ public Date getDateTime(String key) {
+ return currentSettings().getDateTime(key);
+ }
+
+ @Override
+ @CheckForNull
+ public Float getFloat(String key) {
+ return currentSettings().getFloat(key);
+ }
+
+ @Override
+ @CheckForNull
+ public Double getDouble(String key) {
+ return currentSettings().getDouble(key);
+ }
+
+ @Override
+ public String[] getStringArray(String key) {
+ return currentSettings().getStringArray(key);
+ }
+
+ @Override
+ public String[] getStringLines(String key) {
+ return currentSettings().getStringLines(key);
+ }
+
+ @Override
+ public String[] getStringArrayBySeparator(String key, String separator) {
+ return currentSettings().getStringArrayBySeparator(key, separator);
+ }
+
+ @Override
+ public List<String> getKeysStartingWith(String prefix) {
+ return currentSettings().getKeysStartingWith(prefix);
+ }
+
+ @Override
+ public Settings appendProperty(String key, String value) {
+ return currentSettings().appendProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable String[] values) {
+ return currentSettings().setProperty(key, values);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable String value) {
+ return currentSettings().setProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Boolean value) {
+ return currentSettings().setProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Integer value) {
+ return currentSettings().setProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Long value) {
+ return currentSettings().setProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Double value) {
+ return currentSettings().setProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Float value) {
+ return currentSettings().setProperty(key, value);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Date date) {
+ return currentSettings().setProperty(key, date);
+ }
+
+ @Override
+ public Settings addProperties(Map<String, String> props) {
+ return currentSettings().addProperties(props);
+ }
+
+ @Override
+ public Settings addProperties(Properties props) {
+ return currentSettings().addProperties(props);
+ }
+
+ @Override
+ @Deprecated
+ public Settings addSystemProperties() {
+ return currentSettings().addSystemProperties();
+ }
+
+ @Override
+ @Deprecated
+ public Settings addEnvironmentVariables() {
+ return currentSettings().addEnvironmentVariables();
+ }
+
+ @Override
+ public Settings setProperties(Map<String, String> props) {
+ return currentSettings().setProperties(props);
+ }
+
+ @Override
+ public Settings setProperty(String key, @Nullable Date date, boolean includeTime) {
+ return currentSettings().setProperty(key, date, includeTime);
+ }
+
+ @Override
+ public Settings removeProperty(String key) {
+ return currentSettings().removeProperty(key);
+ }
+
+ @Override
+ public Settings clear() {
+ return currentSettings().clear();
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return currentSettings().getProperties();
+ }
+
+ @Override
+ public PropertyDefinitions getDefinitions() {
+ return currentSettings().getDefinitions();
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.ce.settings;
+
+public interface ThreadLocalSettings {
+ /**
+ * Loads up-to-date Settings specific to the current thread.
+ *
+ * @throws IllegalStateException if the current thread already has specific Settings
+ */
+ void load();
+
+ /**
+ * Clears the Settings specific to the current thread (if any).
+ */
+ void remove();
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.ce.settings;
+
+import javax.annotation.ParametersAreNonnullByDefault;
import org.picocontainer.lifecycle.ReflectionLifecycleStrategy;
import org.picocontainer.monitors.ComponentMonitorHelper;
import org.picocontainer.monitors.NullComponentMonitor;
+import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.core.platform.ComponentContainer;
private static final Logger LOG = Loggers.get(ComputeEngineContainerImpl.class);
public ComputeEngineContainerImpl(ComponentContainer parent, ContainerPopulator<ComputeEngineContainer> populator) {
- super(createContainer(requireNonNull(parent)));
+ super(createContainer(requireNonNull(parent)), parent.getComponentByType(PropertyDefinitions.class));
populateContainer(requireNonNull(populator));
startComponents();
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
+import org.sonar.ce.queue.CeTask;
import org.sonar.core.issue.tracking.Tracker;
import org.sonar.core.platform.ContainerPopulator;
import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl;
import org.sonar.server.computation.qualitymodel.QualityModelMeasuresVisitor;
import org.sonar.server.computation.qualitymodel.RatingSettings;
import org.sonar.server.computation.qualityprofile.ActiveRulesHolderImpl;
-import org.sonar.ce.queue.CeTask;
import org.sonar.server.computation.scm.ScmInfoRepositoryImpl;
import org.sonar.server.computation.source.LastCommitVisitor;
import org.sonar.server.computation.source.SourceHashRepositoryImpl;
private static List componentClasses() {
return Arrays.asList(
ComputationStepExecutor.class,
+
+ // File System
new ComputationTempFolderProvider(),
MetricModule.class,
TestErrorRule.class,
SkippedTestRule.class,
- // order is important: RuleTypeCopier must be the first one. And DebtAggregator must be before NewDebtAggregator (new debt requires debt)
+ // order is important: RuleTypeCopier must be the first one. And DebtAggregator must be before NewDebtAggregator (new debt requires
+ // debt)
RuleTypeCopier.class,
RuleTagsCopier.class,
DebtCalculator.class,
import java.util.Collections;
import java.util.Set;
import javax.annotation.CheckForNull;
+import org.sonar.ce.queue.CeTask;
+import org.sonar.ce.queue.CeTaskResult;
+import org.sonar.ce.settings.ThreadLocalSettings;
+import org.sonar.ce.taskprocessor.CeTaskProcessor;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.db.ce.CeTaskTypes;
import org.sonar.server.computation.container.ComputeEngineContainer;
import org.sonar.server.computation.container.ContainerFactory;
-import org.sonar.ce.queue.CeTask;
-import org.sonar.ce.queue.CeTaskResult;
import org.sonar.server.computation.step.ComputationStepExecutor;
-import org.sonar.ce.taskprocessor.CeTaskProcessor;
import org.sonar.server.computation.taskprocessor.TaskResultHolder;
import org.sonar.server.devcockpit.DevCockpitBridge;
@Override
public CeTaskResult process(CeTask task) {
ComputeEngineContainer ceContainer = containerFactory.create(serverContainer, task, devCockpitBridge);
+ ThreadLocalSettings ceSettings = null;
try {
+ ceSettings = ceContainer.getComponentByType(ThreadLocalSettings.class);
+ ceSettings.load();
+
ceContainer.getComponentByType(ComputationStepExecutor.class).execute();
return ceContainer.getComponentByType(TaskResultHolder.class).getResult();
} finally {
+ if (ceSettings != null) {
+ ceSettings.remove();
+ }
ceContainer.cleanup();
}
}
*/
public class PersistentSettings implements Startable {
private final PropertiesDao propertiesDao;
- private final ServerSettings settings;
+ private final ServerSettings serverSettings;
- public PersistentSettings(PropertiesDao propertiesDao, ServerSettings settings) {
+ public PersistentSettings(PropertiesDao propertiesDao, ServerSettings serverSettings) {
this.propertiesDao = propertiesDao;
- this.settings = settings;
+ this.serverSettings = serverSettings;
}
@Override
for (PropertyDto property : getGlobalProperties()) {
databaseProperties.put(property.getKey(), property.getValue());
}
- settings.activateDatabaseSettings(databaseProperties);
+ serverSettings.activateDatabaseSettings(databaseProperties);
}
@Override
}
public PersistentSettings saveProperty(String key, @Nullable String value) {
- settings.setProperty(key, value);
+ serverSettings.setProperty(key, value);
propertiesDao.insertProperty(new PropertyDto().setKey(key).setValue(value));
return this;
}
public PersistentSettings deleteProperty(String key) {
- settings.removeProperty(key);
+ serverSettings.removeProperty(key);
propertiesDao.deleteGlobalProperty(key);
return this;
}
public PersistentSettings deleteProperties() {
- settings.clear();
+ serverSettings.clear();
propertiesDao.deleteGlobalProperties();
return this;
}
public PersistentSettings saveProperties(Map<String, String> properties) {
- settings.addProperties(properties);
+ serverSettings.addProperties(properties);
propertiesDao.insertGlobalProperties(properties);
return this;
}
public String getString(String key) {
- return settings.getString(key);
+ return serverSettings.getString(key);
}
public Map<String, String> getProperties() {
- return settings.getProperties();
+ return serverSettings.getProperties();
}
public Settings getSettings() {
- return settings;
+ return serverSettings.getSettings();
}
public List<PropertyDto> getGlobalProperties() {
*/
package org.sonar.server.platform;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-
-import java.util.Collections;
import java.util.Map;
-import java.util.Properties;
+import org.sonar.api.config.Settings;
/**
- * Load settings in the following order (the last override the first) :
- * <ol>
- * <li>general settings persisted in database</li>
- * <li>file $SONAR_HOME/conf/sonar.properties</li>
- * <li>environment variables</li>
- * <li>system properties</li>
- * </ol>
- *
- * @since 2.12
+ * Defines some of the methods of {@link Settings} plus some specific to load db properties on the server side
+ * (see {@link PersistentSettings}).
*/
-public class ServerSettings extends Settings {
+public interface ServerSettings {
+ ServerSettings activateDatabaseSettings(Map<String, String> databaseProperties);
+
+ Settings getSettings();
+
+ /**
+ * @see Settings#getString(String)
+ */
+ String getString(String key);
- private final Properties properties;
+ /**
+ * @see Settings#getProperties()
+ */
+ Map<String, String> getProperties();
- public ServerSettings(PropertyDefinitions definitions, Properties properties) {
- super(definitions);
- this.properties = properties;
- load(Collections.<String, String>emptyMap());
- // Secret key is loaded from conf/sonar.properties
- getEncryption().setPathToSecretKey(getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
- }
+ /**
+ * @see Settings#hasKey(String)
+ */
+ boolean hasKey(String foo);
- public ServerSettings activateDatabaseSettings(Map<String, String> databaseProperties) {
- return load(databaseProperties);
- }
+ /**
+ * @see Settings#setProperty(String, String)
+ */
+ Settings setProperty(String key, String value);
- private ServerSettings load(Map<String, String> databaseSettings) {
- clear();
+ /**
+ * @see Settings#removeProperty(String)
+ */
+ Settings removeProperty(String key);
- // order is important : the last override the first
- addProperties(databaseSettings);
- addProperties(properties);
+ /**
+ * @see Settings#clear()
+ */
+ Settings clear();
- return this;
- }
+ /**
+ * @see Settings#addProperties(Map)
+ */
+ Settings addProperties(Map<String, String> properties);
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform;
+
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.PropertyDefinitions;
+import org.sonar.api.config.Settings;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Load settings in the following order (the last override the first) :
+ * <ol>
+ * <li>general settings persisted in database</li>
+ * <li>file $SONAR_HOME/conf/sonar.properties</li>
+ * <li>environment variables</li>
+ * <li>system properties</li>
+ * </ol>
+ *
+ * @since 2.12
+ */
+public class WebServerSettings extends Settings implements ServerSettings {
+
+ private final Properties properties;
+
+ public WebServerSettings(PropertyDefinitions definitions, Properties properties) {
+ super(definitions);
+ this.properties = properties;
+ load(Collections.<String, String>emptyMap());
+ // Secret key is loaded from conf/sonar.properties
+ getEncryption().setPathToSecretKey(getString(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
+ }
+
+ @Override
+ public ServerSettings activateDatabaseSettings(Map<String, String> databaseProperties) {
+ return load(databaseProperties);
+ }
+
+ @Override
+ public Settings getSettings() {
+ return this;
+ }
+
+ private ServerSettings load(Map<String, String> databaseSettings) {
+ clear();
+
+ // order is important : the last override the first
+ addProperties(databaseSettings);
+ addProperties(properties);
+
+ return this;
+ }
+}
import org.sonar.server.platform.DefaultServerFileSystem;
import org.sonar.server.platform.Platform;
import org.sonar.server.platform.ServerImpl;
-import org.sonar.server.platform.ServerSettings;
+import org.sonar.server.platform.WebServerSettings;
import org.sonar.server.platform.TempFolderProvider;
import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
import org.sonar.server.ruby.PlatformRackBridge;
add(
new SonarQubeVersionProvider(),
ProcessCommandWrapperImpl.class,
- ServerSettings.class,
+ WebServerSettings.class,
ServerImpl.class,
UuidFactoryImpl.INSTANCE,
EmbeddedDatabaseFactory.class,
import org.sonar.server.i18n.I18nRule;
import org.sonar.server.permission.ws.PermissionDependenciesFinder;
import org.sonar.server.platform.PersistentSettings;
-import org.sonar.server.platform.ServerSettings;
+import org.sonar.server.platform.WebServerSettings;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.usergroups.ws.UserGroupFinder;
import org.sonar.server.ws.TestRequest;
@Before
public void setUp() {
DbClient dbClient = db.getDbClient();
- persistentSettings = new PersistentSettings(dbClient.propertiesDao(), new ServerSettings(new PropertyDefinitions(), new Properties()));
+ persistentSettings = new PersistentSettings(dbClient.propertiesDao(), new WebServerSettings(new PropertyDefinitions(), new Properties()));
persistentSettings.saveProperty(DEFAULT_TEMPLATE_PROPERTY, "any-template-uuid");
persistentSettings.saveProperty(defaultRootQualifierTemplateProperty(PROJECT), "any-template-uuid");
persistentSettings.saveProperty(defaultRootQualifierTemplateProperty(VIEW), "any-view-template-uuid");
public void init() {
dao = mock(PropertiesDao.class);
- settings = new ServerSettings(
+ settings = new WebServerSettings(
new PropertyDefinitions(),
new Properties());
}
Properties properties;
- ServerSettings settings;
+ WebServerSettings settings;
@Before
public void before() {
properties.put("hello", "world");
properties.put("in_file", "true");
properties.put("ServerSettingsTestEnv", "in_file");
- settings = new ServerSettings(new PropertyDefinitions(), properties);
+ settings = new WebServerSettings(new PropertyDefinitions(), properties);
}
@Test
}
protected ComponentContainer(MutablePicoContainer picoContainer) {
+ this(picoContainer, new PropertyDefinitions());
+ }
+
+ protected ComponentContainer(MutablePicoContainer picoContainer, PropertyDefinitions propertyDefinitions) {
+ requireNonNull(propertyDefinitions, "PropertyDefinitions can not be null");
this.parent = null;
this.pico = picoContainer;
this.componentKeys = new ComponentKeys();
- propertyDefinitions = new PropertyDefinitions();
+ this.propertyDefinitions = propertyDefinitions;
addSingleton(propertyDefinitions);
addSingleton(this);
}
* @since 3.1
*/
public Settings(Settings other) {
- this.properties = Maps.newHashMap(other.properties);
- this.definitions = other.definitions;
- this.encryption = other.encryption;
+ this.properties = Maps.newHashMap(other.getProperties());
+ this.definitions = other.getDefinitions();
+ this.encryption = other.getEncryption();
}
public Encryption getEncryption() {