Move dependency injection configuration closer to where it’s useful.
[Sone.git] / src / main / java / net / pterodactylus / sone / fcp / FcpInterface.java
index c71fd82..551dc4f 100644 (file)
@@ -41,6 +41,7 @@ import freenet.support.api.Bucket;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.inject.Inject;
+import com.google.inject.Singleton;
 
 /**
  * Implementation of an FCP interface for other clients or plugins to
@@ -48,6 +49,7 @@ import com.google.inject.Inject;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
+@Singleton
 public class FcpInterface {
 
        /**
@@ -126,6 +128,11 @@ public class FcpInterface {
                this.active = active;
        }
 
+       @VisibleForTesting
+       FullAccessRequired getFullAccessRequired() {
+               return fullAccessRequired;
+       }
+
        /**
         * Sets the action level for which full FCP access is required.
         *
@@ -233,4 +240,13 @@ public class FcpInterface {
 
        }
 
+       public class SetFullAccessRequired implements OptionWatcher<Integer> {
+
+               @Override
+               public void optionChanged(Option<Integer> option, Integer oldValue, Integer newValue) {
+                       setFullAccessRequired(FullAccessRequired.values()[newValue]);
+               }
+
+       }
+
 }