summaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-09-02 18:02:35 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2013-09-02 18:06:41 +0200
commit541311a3efbbaf357c4989379b42de573be60b2a (patch)
tree6469e9f9e981b38feb6a9a9e1e083a578255eb78 /sonar-plugin-api
parent6c6dc197d187b7db43fb019dbcaa8fa1b165bbcf (diff)
downloadsonarqube-541311a3efbbaf357c4989379b42de573be60b2a.tar.gz
sonarqube-541311a3efbbaf357c4989379b42de573be60b2a.zip
SONAR-4602 Invalidate dryRun cache when changing settings
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/GlobalPropertyChangeHandler.java11
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/SettingsChangeHandler.java84
2 files changed, 92 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/GlobalPropertyChangeHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/GlobalPropertyChangeHandler.java
index 3f65b21872d..ec7c8683a1c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/GlobalPropertyChangeHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/GlobalPropertyChangeHandler.java
@@ -19,8 +19,6 @@
*/
package org.sonar.api.config;
-import org.sonar.api.ServerExtension;
-
import javax.annotation.Nullable;
/**
@@ -32,7 +30,7 @@ import javax.annotation.Nullable;
*
* @since 3.0
*/
-public abstract class GlobalPropertyChangeHandler implements ServerExtension {
+public abstract class GlobalPropertyChangeHandler implements SettingsChangeHandler {
public static final class PropertyChange {
private String key;
@@ -65,4 +63,11 @@ public abstract class GlobalPropertyChangeHandler implements ServerExtension {
* This method gets called when a property is changed.
*/
public abstract void onChange(PropertyChange change);
+
+ @Override
+ public void onChange(SettingsChange change) {
+ if (change.isGlobal()) {
+ onChange(PropertyChange.create(change.key(), change.newValue()));
+ }
+ }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/SettingsChangeHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/SettingsChangeHandler.java
new file mode 100644
index 00000000000..bd618eb98d4
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/SettingsChangeHandler.java
@@ -0,0 +1,84 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.api.config;
+
+import org.sonar.api.ServerExtension;
+
+import javax.annotation.Nullable;
+
+/**
+ * Observe changes of properties done from web application. It does not support :
+ * <ul>
+ * <li>changes done programmatically on the component org.sonar.api.config.Settings</li>
+ * </ul>
+ *
+ * @since 4.0
+ */
+public interface SettingsChangeHandler extends ServerExtension {
+
+ public static final class SettingsChange {
+ private String key;
+ private String newValue;
+ private String componentKey;
+ private String userLogin;
+
+ private SettingsChange(String key, @Nullable String newValue, @Nullable String componentKey, @Nullable String userLogin) {
+ this.key = key;
+ this.newValue = newValue;
+ this.componentKey = componentKey;
+ this.userLogin = userLogin;
+ }
+
+ public static SettingsChange create(String key, @Nullable String newValue, @Nullable String componentKey, @Nullable String userLogin) {
+ return new SettingsChange(key, newValue, componentKey, userLogin);
+ }
+
+ public String key() {
+ return key;
+ }
+
+ public String newValue() {
+ return newValue;
+ }
+
+ public String componentKey() {
+ return componentKey;
+ }
+
+ public String userLogin() {
+ return userLogin;
+ }
+
+ public boolean isGlobal() {
+ return componentKey == null && userLogin == null;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[key=%s, newValue=%s, componentKey=%s]", key, newValue, componentKey);
+ }
+ }
+
+ /**
+ * This method gets called when a property is changed.
+ */
+ public void onChange(SettingsChange change);
+
+}