Class DefaultBeanLocator

    • Field Detail

      • cachedBindings

        private final java.util.concurrent.ConcurrentMap<java.lang.Long,​RankedBindings> cachedBindings
      • cachedWatchers

        private final java.util.Map<WatchedBeans,​java.lang.Object> cachedWatchers
      • typeIdHolder

        private final java.lang.Long[] typeIdHolder
    • Constructor Detail

      • DefaultBeanLocator

        public DefaultBeanLocator()
    • Method Detail

      • locate

        public java.lang.Iterable<BeanEntry> locate​(com.google.inject.Key key)
        Description copied from interface: BeanLocator
        Finds bean implementations that match the given qualified binding Key.
        Specified by:
        locate in interface BeanLocator
        Parameters:
        key - The qualified key
        Returns:
        Sequence of bean entries that match the given key
      • watch

        public void watch​(com.google.inject.Key key,
                          Mediator mediator,
                          java.lang.Object watcher)
        Description copied from interface: BeanLocator
        Tracks bean implementations that match the given qualified binding Key.

        Uses the Mediator pattern to send events to an arbitrary watcher object.

        Specified by:
        watch in interface BeanLocator
        Parameters:
        key - The qualified key
        mediator - The event mediator
        watcher - The bean watcher
      • add

        public void add​(com.google.inject.Injector injector,
                        int rank)
        Description copied from interface: MutableBeanLocator
        Adds the given ranked Injector and distributes its Bindings. Marked as deprecated because most clients should not call this method; any injector with an instance binding to a BeanLocator is automatically added to that locator as part of the bootstrapping process.
        Specified by:
        add in interface MutableBeanLocator
        Parameters:
        injector - The new injector
        rank - The assigned rank; should reflect the injector's RankingFunction.maxRank()
      • remove

        public void remove​(com.google.inject.Injector injector)
        Description copied from interface: MutableBeanLocator
        Removes the given Injector and its Bindings.
        Specified by:
        remove in interface MutableBeanLocator
        Parameters:
        injector - The old injector
      • fetchBindings

        private RankedBindings fetchBindings​(com.google.inject.TypeLiteral type,
                                             java.lang.Long[] idReturn)
        Fetches any bindings currently associated with the given type.
        Parameters:
        type - The generic type
        idReturn - Optional holder, returns the assigned type id
        Returns:
        Associated bindings; null if this is a new type
      • autoPublish

        @Inject
        void autoPublish​(com.google.inject.Injector injector)
        Automatically publishes any Injector that contains a binding to this BeanLocator.
        Parameters:
        injector - The injector
      • staticAutoPublish

        @Inject
        static void staticAutoPublish​(MutableBeanLocator locator,
                                      com.google.inject.Injector injector)