Browse Source

Add method for getting domain from PluginInfo.

Plugins shouldn't be required to have getters and setters for
something that's constant.

Change-Id: I99ebc7d10f558008a7889252cc3c96f39747303e
Reviewed-on: http://gerrit.dmdirc.com/2860
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 years ago
parent
commit
969ef95d12

+ 4
- 0
src/com/dmdirc/plugins/Plugin.java View File

@@ -46,8 +46,10 @@ public interface Plugin {
46 46
     /**
47 47
      * Get the domain name settings for this plugin should be stored in.
48 48
      *
49
+     * @deprecated Domain should be obtained from {@link PluginInfo}
49 50
      * @return Domain name for plugin settings
50 51
      */
52
+    @Deprecated
51 53
     String getDomain();
52 54
 
53 55
     /**
@@ -122,8 +124,10 @@ public interface Plugin {
122 124
      * Called by PluginInfo to set the domain name.
123 125
      * This can only be called once, all other attempts will be ignored.
124 126
      *
127
+     * @deprecated Domain should be obtained from {@link PluginInfo}
125 128
      * @param newDomain Domain name for plugin settings
126 129
      */
130
+    @Deprecated
127 131
     void setDomain(final String newDomain);
128 132
 
129 133
     /**

+ 13
- 6
src/com/dmdirc/plugins/PluginInfo.java View File

@@ -224,16 +224,15 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
224 224
      */
225 225
     private void getDefaults() {
226 226
         final ConfigProvider defaults = IdentityManager.getIdentityManager().getAddonSettings();
227
-        final String domain = "plugin-" + metaData.getName();
228 227
 
229 228
         log.trace("{}: Using domain '{}'",
230
-                new Object[]{metaData.getName(), domain});
229
+                new Object[]{metaData.getName(), getDomain()});
231 230
 
232 231
         for (Map.Entry<String, String> entry : metaData.getDefaultSettings().entrySet()) {
233 232
             final String key = entry.getKey();
234 233
             final String value = entry.getValue();
235 234
 
236
-            defaults.setOption(domain, key, value);
235
+            defaults.setOption(getDomain(), key, value);
237 236
         }
238 237
 
239 238
         for (Map.Entry<String, String> entry : metaData.getFormatters().entrySet()) {
@@ -717,13 +716,12 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
717 716
                             Logger.userError(ErrorLevel.LOW, lastError);
718 717
                         }
719 718
                     } else {
720
-                        final String domain = "plugin-" + metaData.getName();
721 719
                         plugin = (Plugin) temp;
722 720
 
723 721
                         log.debug("{}: Setting domain '{}'",
724
-                                new Object[]{metaData.getName(), domain});
722
+                                new Object[]{metaData.getName(), getDomain()});
725 723
 
726
-                        plugin.setDomain(domain);
724
+                        plugin.setDomain(getDomain());
727 725
                         if (!tempLoaded) {
728 726
                             try {
729 727
                                 plugin.load(this, getObjectGraph());
@@ -764,6 +762,15 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
764 762
         }
765 763
     }
766 764
 
765
+    /**
766
+     * Gets the configuration domain that should be used by this plugin.
767
+     *
768
+     * @return The configuration domain to use.
769
+     */
770
+    public String getDomain() {
771
+        return "plugin-" + metaData.getName();
772
+    }
773
+
767 774
     /**
768 775
      * Unload the plugin if possible.
769 776
      */

+ 5
- 0
src/com/dmdirc/plugins/implementations/BasePlugin.java View File

@@ -43,6 +43,7 @@ public abstract class BasePlugin implements Plugin {
43 43
 
44 44
     /** {@inheritDoc} */
45 45
     @Override
46
+    @Deprecated
46 47
     public void setDomain(final String newDomain) {
47 48
         if (!domainSet) {
48 49
             domainSet = true;
@@ -86,6 +87,7 @@ public abstract class BasePlugin implements Plugin {
86 87
 
87 88
     /** {@inheritDoc} */
88 89
     @Override
90
+    @Deprecated
89 91
     public String getDomain() {
90 92
         return myDomain;
91 93
     }
@@ -94,7 +96,10 @@ public abstract class BasePlugin implements Plugin {
94 96
      * Called when the domain for plugin settings has been set.
95 97
      * This will only be called once (either when the plugin is loading, or when
96 98
      * its config is being shown).
99
+     *
100
+     * @deprecated Domain should be obtained from {@link PluginInfo}, and will never be updated.
97 101
      */
102
+    @Deprecated
98 103
     protected void domainUpdated() {
99 104
         //Define this here so only implementations that care have to override
100 105
     }

Loading…
Cancel
Save