Class PropertyBundleLookup

java.lang.Object
ru.vyarus.dropwizard.guice.bundle.lookup.PropertyBundleLookup
All Implemented Interfaces:
GuiceyBundleLookup

public class PropertyBundleLookup extends Object implements GuiceyBundleLookup
Use 'guicey.bundles' system property to lookup bundles. Property value must contain comma-separated list of complete bundle class names. Each bundle in list must have default no-args constructor.

Example: -Dguicey.bundles=com.foo.MyBundle1,com.foo.MyBundle2.

Static shortcut method may be used to set property value from code (for example, in unit tests to enable specific debug bundle): PropertyBundleLookup.enableBundles(MyBundle1.class, MyBundle2.class).

For example, last approach is used in guicey tests to enable HK2DebugBundle to check beans boundaries during tests.

Since:
16.01.2016
  • Field Details

  • Constructor Details

    • PropertyBundleLookup

      public PropertyBundleLookup()
  • Method Details

    • lookup

      public List<GuiceyBundle> lookup()
      Description copied from interface: GuiceyBundleLookup
      Called before guice injector creation to lookup additional bundles (in dropwizard run phase).
      Specified by:
      lookup in interface GuiceyBundleLookup
      Returns:
      list of found bundles or empty list
    • enableBundles

      @SafeVarargs public static void enableBundles(Class<? extends GuiceyBundle>... bundles)
      Sets system property value to provided classes. Shortcut is useful to set property from code, for example, in unit tests.
      Parameters:
      bundles - bundles to enable