Class BundleSupport


  • public final class BundleSupport
    extends java.lang.Object
    Utility class to work with registered ConfiguredBundle objects within dropwizard Bootstrap object.
    Since:
    01.08.2015
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<T> findBundles​(io.dropwizard.setup.Bootstrap bootstrap, java.lang.Class<T> type)  
      static void initBundles​(ConfigurationContext context)
      Process initialization for initially registered and all transitive bundles.
      static <T> java.util.List<T> removeDuplicates​(java.util.List<T> list)
      Remove duplicates in list by rule: only one instance of type must be present in list.
      static <T> java.util.List<T> removeTypes​(java.util.List<T> list, java.util.List<java.lang.Class<? extends T>> filter)
      Filter list from objects of type present in filter list.
      static void runBundles​(ConfigurationContext context)
      Run all enabled bundles.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • initBundles

        public static void initBundles​(ConfigurationContext context)
        Process initialization for initially registered and all transitive bundles.
        • Executing initial bundles initialization (registered in GuiceBundle and by bundle lookup)
        • During execution bundles may register other bundles (through GuiceyBootstrap)
        • Execute registered bundles and repeat from previous step until no new bundles registered
        Bundles duplicates are checked by type: only one bundle instance may be registered.
        Parameters:
        context - bundles context
      • runBundles

        public static void runBundles​(ConfigurationContext context)
                               throws java.lang.Exception
        Run all enabled bundles.
        Parameters:
        context - bundles context
        Throws:
        java.lang.Exception - if something goes wrong
      • removeDuplicates

        public static <T> java.util.List<T> removeDuplicates​(java.util.List<T> list)
        Remove duplicates in list by rule: only one instance of type must be present in list.
        Type Parameters:
        T - required bundle type
        Parameters:
        list - bundles list
        Returns:
        list cleared from duplicates
      • removeTypes

        public static <T> java.util.List<T> removeTypes​(java.util.List<T> list,
                                                        java.util.List<java.lang.Class<? extends T>> filter)
        Filter list from objects of type present in filter list.
        Type Parameters:
        T - required type
        Parameters:
        list - list to filter
        filter - types to filter
        Returns:
        filtered list
      • findBundles

        public static <T> java.util.List<T> findBundles​(io.dropwizard.setup.Bootstrap bootstrap,
                                                        java.lang.Class<T> type)
        Type Parameters:
        T - required bundle type
        Parameters:
        bootstrap - dropwizard bootstrap instance
        type - required bundle type (or marker interface)
        Returns:
        list of bundles of specified type