Esempio n. 1
0
 /**
  * Binds the extension class to the class that is registered for the give configured for the
  * settings key in the settings object.
  *
  * @param binder the binder to use
  * @param settings the settings to look up the key to find the implementation to bind
  * @param settingsKey the key to use with the settings
  * @param defaultValue the default value if the settings do not contain the key, or null if
  *     there is no default
  * @return the actual bound type key
  */
 public String bindType(
     Binder binder, Settings settings, String settingsKey, String defaultValue) {
   final String type = settings.get(settingsKey, defaultValue);
   if (type == null) {
     throw new IllegalArgumentException("Missing setting [" + settingsKey + "]");
   }
   final Class<? extends T> instance = getExtension(type);
   if (instance == null) {
     throw new IllegalArgumentException("Unknown [" + this.name + "] type [" + type + "]");
   }
   binder.bind(extensionClass).to(instance).asEagerSingleton();
   return type;
 }
Esempio n. 2
0
 /** @since 2.0 */
 @Override
 public void applyTo(Binder binder) {
   binder.withSource(getSource()).addError(this);
 }
 @Override
 public void applyTo(Binder binder) {
   binder.withSource(getSource()).convertToTypes(typeMatcher, typeConverter);
 }
 public void applyTo(Binder binder) {
   getScoping().applyTo(binder.withSource(getSource()).bind(getKey()).to(getLinkedKey()));
 }
Esempio n. 5
0
 /**
  * Binds the extension as well as the singletons to the given guice binder.
  *
  * @param binder the binder to use
  */
 public final void bind(Binder binder) {
   for (Class<?> c : singletons) {
     binder.bind(c).asEagerSingleton();
   }
   bindExtensions(binder);
 }