All Known Implementing Classes:
EagerSingletonInstaller, JerseyProviderInstaller, PluginInstaller, ResourceInstaller

public interface BindingInstaller
Marker interface must be used together with FeatureInstaller. Used for installers which requires custom bindings for extension. Note: binder.bind(type) is not called by default for binding installer, assuming installer will specify proper binding itself.

Install methods may be also used to restrict extension declaration only as class or bindings.

If extension is annotated with LazyBinding boolean hint is passed and installer must decide what to do with it (preferably support or fail, not ignore). Bindings extensions (resolved from guice modules) may not be declared as lazy (this will be detected automatically).

Installer may be called multiple times if guice bindings or aop report is enabled. If required, report execution may be detected by used stage: binder.currentStage() == Stage.TOOL.

Since:
09.10.2014
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bind(com.google.inject.Binder binder, Class<?> type, boolean lazy)
    Called to apply custom binding for installed feature.
    default void
    extensionBound(com.google.inject.Stage stage, Class<?> type)
    Called after execution of one of above methods.
    default <T> void
    manualBinding(com.google.inject.Binder binder, Class<T> type, com.google.inject.Binding<T> binding)
    Called for extensions, resolved from guice bindings (in user modules).
  • Method Details

    • bind

      void bind(com.google.inject.Binder binder, Class<?> type, boolean lazy)
      Called to apply custom binding for installed feature. By default, all found extensions are installed as binder.bind(type). This method will be called instead of default registration.

      Called only for non binding extensions (extensions that are not already bound in guice module.

      WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.

      Parameters:
      binder - guice binder
      type - extension class
      lazy - true if extension is annotated with LazyBinding
    • manualBinding

      default <T> void manualBinding(com.google.inject.Binder binder, Class<T> type, com.google.inject.Binding<T> binding)
      Called for extensions, resolved from guice bindings (in user modules). May be used to validate binding or do some additional bindings with existing binding. Binding is detected primarily by main key Binding.getKey(), but linked bindings (LinkedKeyBinding) are also checked for target key (LinkedKeyBinding.getLinkedKey()).

      LazyBinding flag is not used here because guicey will automatically throw an error if existing binding is annotated as lazy binding (which don't makes any sense).

      WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.

      Type Parameters:
      T - extension type, used to connect extension class with binding
      Parameters:
      binder - guice binder
      type - extension class
      binding - binding declaration from guice module
      See Also:
    • extensionBound

      default void extensionBound(com.google.inject.Stage stage, Class<?> type)
      Called after execution of one of above methods. Useful for reporting. Binder is not provided here to avoid confusion with bind(Binder, Class, boolean).

      WARNING: may be called multiple times due to enabled bindings reporting! Be sure to produce correct logs.

      Parameters:
      stage - stage (useful for differentiation between normal run (Stage.PRODUCTION) and report rendering (Stage.TOOL)
      type - extension class