Class HiveMind


  • public class HiveMind
    extends Object
    HiveMind maintains the collection of Hives. There can only be one HiveMind in each virtual machine. As the HiveMind is supposed to be created and configured early during the lifetime of an application none of its methods are synchronized.
    Author:
    marrink
    • Method Detail

      • getHive

        public static Hive getHive​(Object queen)
        Returns the Hive stored with the key.
        Parameters:
        queen - the key
        Returns:
        the Hive or null if no Hive is registered with that key
      • registerHive

        public static void registerHive​(Object queen,
                                        HiveFactory factory)
        Registers a new Hive for anybody knowing the right key to be retrieved. It is not possible to overwrite a registration without first unregistering the previous Hive.
        Parameters:
        queen - the key to store the Hive with.
        factory - the factory that will produce the Hive.
        Throws:
        IllegalArgumentException - if the factory is null
        IllegalArgumentException - if an attempt is made to overwrite the registration.
        RuntimeException - if the factory does not produce a Hive.
        See Also:
        unregisterHive(Object)
      • unregisterHive

        public static Hive unregisterHive​(Object queen)
        Removes the registration of a single Hive.
        Parameters:
        queen - the key the Hive is registered with
        Returns:
        the registered Hive or null if none was registered with the key.