Class GuiceyConfigurationInfo

java.lang.Object
ru.vyarus.dropwizard.guice.module.GuiceyConfigurationInfo

public class GuiceyConfigurationInfo extends Object
Public api for internal guicey configuration info and startup statistics. Provides information about time spent for configurations and configuration details like registered bundle types, installers, extensions, disabled installers etc. Registered as guice bean and could be directly injected.

Could be used for configuration diagnostics or unit test checks.

Since:
21.06.2016
  • Constructor Details

    • GuiceyConfigurationInfo

      @Inject public GuiceyConfigurationInfo(ConfigurationInfo context, StatsInfo stats, OptionsInfo options, ExtensionsHolder holder, ConfigurationTree configurationTree)
      Create configuration info.
      Parameters:
      context - configuration context
      stats - stat trackers
      options - options
      holder - extensions holder
      configurationTree - parsed configuration
  • Method Details

    • getData

      public ConfigurationInfo getData()
      Use to perform custom configuration items data lookups (e.g. for additional logging, diagnostics or consistency checks).
      Returns:
      raw configuration info object
    • getStats

      public StatsInfo getStats()
      Timers and counters collected at startup.
      Returns:
      startup statistics object
      See Also:
    • getOptions

      public OptionsInfo getOptions()
      Returns:
      configuration options
      See Also:
    • getConfigurationTree

      public ConfigurationTree getConfigurationTree()
      Note that object is also available for direct injection because, in contrast to other guicey-related data, configuration properties tree could be used directly in business logic.
      Returns:
      dropwizard configuration introspection result
    • getItemsByScope

      public List<ItemId<Object>> getItemsByScope(ConfigScope specialScope)
      Shortcut for getItemsByScope(Class) for special scopes (like classpath scan, bundles lookup etc).
      Parameters:
      specialScope - special scope
      Returns:
      all enabled items registered in specified scope or empty list
    • getItemsByScope

      public List<ItemId<Object>> getItemsByScope(ItemId scope)
      NOTE: single item may be registered from multiple scopes! This method will return entity by all it's registered scopes and not just by first registration. It makes it usable, for example, for configuration tree building. If you need exact registration scope use Filters.registrationScope(Class) filter.
      Parameters:
      scope - required scope
      Returns:
      all enabled items registered in specified scope or empty list
      See Also:
    • getItemsByScope

      public List<ItemId<Object>> getItemsByScope(Class<?> scope)
      Shortcut for getItemsByScope(ItemId). Note that bundle of the same type may be registered multiple times and querying by such bundle type will return registrations from all bundle instances.
      Parameters:
      scope - scope class
      Returns:
      all enabled items registered in specified scope or empty list
    • getActiveScopes

      public Set<ItemId> getActiveScopes()
      Returns:
      all active scopes including disable only scopes
      See Also:
    • getActiveScopes

      public Set<ItemId> getActiveScopes(boolean countDisables)
      Parameters:
      countDisables - include scopes with disables only
      Returns:
      all active scopes or empty collection
      See Also:
    • getInfo

      public <T extends ItemInfo> T getInfo(Class<?> type)
      Shortcut for ConfigurationInfo.getInfos(Class) which always returns one configuration info object per class. It is generally not correct for instance types (where multiple instances of the same type could be registered), but enough for general reporting needs (showing general info on class level).
      Type Parameters:
      T - required info object type
      Parameters:
      type - item type
      Returns:
      configuration item object for provided class (first one for multiple instances) or empty list if not found
    • getInfos

      public <T extends ItemInfo> List<T> getInfos(Class<?> type)
      Shortcut for ConfigurationInfo.getInfos(Class). Added to avoid confusion with getInfo(Class).
      Type Parameters:
      T - required info object type
      Parameters:
      type - item type
      Returns:
      all configuration object registered with required class (could be multiple for instance types and always one element for class types).
      See Also:
    • getCommands

      public List<Class<io.dropwizard.core.cli.Command>> getCommands()
      Note: only commands installed after classpath scan are tracked and so there might be only one instance for each command type (in spite of the fact that commands descriptors are instance based).
      Returns:
      types of all installed commands or empty list
      See Also:
    • getGuiceyBundles

      public List<Class<GuiceyBundle>> getGuiceyBundles()
      Note that multiple instances could be installed for some bundles, but returned list will contain just bundle type (no matter how many instances were actually installed).

      Important: bundles returned in the registration order; if initialization order is required see getGuiceyBundlesInInitOrder() (different because of transitive bundles).

      Returns:
      types of all installed and enabled bundles (including lookup bundles) or empty list
    • getGuiceyBundlesInInitOrder

      public List<Class<? extends GuiceyBundle>> getGuiceyBundlesInInitOrder()
      Guicey bundle could register another guicey bundle then this transitive bundle would be initialized before the root bundle. This method sorts registered bundles according to actual initialization order (not by when init started, but when init finished - the same order as for transitive dropwizard bundles).
      Returns:
      applied guicey bundles in initialization order.
    • getGuiceyBundleIds

      public List<ItemId<GuiceyBundle>> getGuiceyBundleIds()
      Note that this list could be larger then getGuiceyBundles() because multiple bundle instances of the same class could be registered.
      Returns:
      types of all enabled normal guice modules or empty list
      See Also:
    • getDropwizardBundles

      public List<Class<io.dropwizard.core.ConfiguredBundle>> getDropwizardBundles()
      Note that multiple instances could be installed for some bundles, but returned list will contain just bundle type (no matter how many instances were actually installed).
      Returns:
      types of all installed and enabled dropwizard bundles or empty list
    • getDropwizardBundleIds

      public List<ItemId<io.dropwizard.core.ConfiguredBundle>> getDropwizardBundleIds()
      Note that this list could be larger then getDropwizardBundles() because multiple bundle instances of the same class could be registered.
      Returns:
      types of all enabled normal guice modules or empty list
      See Also:
    • getBundlesFromLookup

      public List<Class<GuiceyBundle>> getBundlesFromLookup()
      Bundles lookup mechanism could register only one instance of bundle type, but other instances may be registered directly (anyway, it is correct that only one bundle instance belongs to lookup scope).
      Returns:
      types of bundles resolved by bundle lookup mechanism or empty list
      See Also:
    • getDirectBundles

      public List<Class<Object>> getDirectBundles()
      Returns:
      all (guicey and dropwizard) enabled top-level bundles (without transitives)
    • getBundlesDisabled

      public List<Class<Object>> getBundlesDisabled()
      Note that the same type may appear in both enabled and disabled lists if it is instance item and only some instances were disabled.
      Returns:
      types of manually disabled bundles or empty list
    • getRelativelyInstalledBundles

      public List<Class<Object>> getRelativelyInstalledBundles(Class<?> bundle)
      Parameters:
      bundle - bundle
      Returns:
      types of bundles (guicey and dropwizard) registered from provided bundle avoiding disabled bundles or empty list
    • getModules

      public List<Class<com.google.inject.Module>> getModules()
      Note that multiple instances could be installed for some modules, but returned list will contain just module type (no matter how many instances were actually installed).
      Returns:
      types of all registered and enabled guice modules (including normal and overriding) or empty list
    • getModuleIds

      public List<ItemId<com.google.inject.Module>> getModuleIds()
      Note that this list could be larger then getModules() because multiple module instances of the same class could be registered.
      Returns:
      ids of all registered and enabled guice modules (including normal and overriding) or empty list
      See Also:
    • getNormalModules

      public List<Class<com.google.inject.Module>> getNormalModules()
      Returns:
      types of all enabled normal guice modules or empty list
      See Also:
    • getNormalModuleIds

      public List<ItemId<com.google.inject.Module>> getNormalModuleIds()
      Note that this list could be larger then getNormalModules() because multiple module instances of the same class could be registered.
      Returns:
      types of all enabled normal guice modules or empty list
      See Also:
    • getOverridingModules

      public List<Class<com.google.inject.Module>> getOverridingModules()
      Returns:
      types of all enabled overriding guice modules or empty list
      See Also:
    • getOverridingModuleIds

      public List<ItemId<com.google.inject.Module>> getOverridingModuleIds()
      Note that this list could be larger then getOverridingModules() because multiple module instances of the same class could be registered.
      Returns:
      types of all enabled normal guice modules or empty list
      See Also:
    • getModulesDisabled

      public List<Class<com.google.inject.Module>> getModulesDisabled()
      Returns:
      types of manually disabled modules or empty list
    • getInstallers

      public List<Class<FeatureInstaller>> getInstallers()
      Returns:
      types of all registered installers (without disabled) or empty list
    • getInstallersFromScan

      public List<Class<FeatureInstaller>> getInstallersFromScan()
      Returns:
      installer types, resolved by classpath scan (without disabled) or empty list
    • getInstallersDisabled

      public List<Class<FeatureInstaller>> getInstallersDisabled()
      Returns:
      types of manually disabled installers or empty list
    • getInstallersOrdered

      public List<Class<FeatureInstaller>> getInstallersOrdered()
      Returned installers are ordered not by execution order (according to Order annotations).
      Returns:
      ordered list of installers or empty list
    • getExtensions

      public List<Class<Object>> getExtensions()
      Returns:
      all registered and enabled extension types (including resolved with classpath scan) or empty list
    • getExtensions

      public List<Class<Object>> getExtensions(Class<? extends FeatureInstaller> installer)
      Parameters:
      installer - installer type
      Returns:
      list of extensions installed by provided installer or empty list
    • getExtensionsFromScan

      public List<Class<Object>> getExtensionsFromScan()
      Returns:
      enabled extension types, resolved by classpath scan or empty list
    • getExtensionsFromBindings

      public List<Class<Object>> getExtensionsFromBindings()
      Returns:
      enabled extension types, resolved by guice bindings scan or empty list
    • getExtensionsRegisteredManually

      public List<Class<Object>> getExtensionsRegisteredManually()
      Returned extensions may be also found by classpath scan or in guice bindings.
      Returns:
      enabled extensions which was registered manually or empty list
    • getExtensionsRegisteredManauallyOnly

      public List<Class<Object>> getExtensionsRegisteredManauallyOnly()
      One extension could be installed manually then found by classpath scan and then found from guice binding. This method returns only extensions configured manually and never detected by other methods.
      Returns:
      list of enabled extensions, registered only manually or empty list
    • getExtensionsOrdered

      public List<Class<Object>> getExtensionsOrdered(Class<? extends FeatureInstaller> installer)
      Returned installers are ordered by execution order according to Order annotation. Note: not all installers supports ordering (in any case returned order is the same order as extensions were processed by installer).
      Parameters:
      installer - installer type
      Returns:
      ordered list of extensions installed by provided installer or empty list
    • getExtensionsDisabled

      public List<Class<Object>> getExtensionsDisabled()
      Returns:
      types of manually disabled extensions or empty list