Package org.eclipse.sisu.inject
Class DefaultBeanLocator
java.lang.Object
org.eclipse.sisu.inject.DefaultBeanLocator
- All Implemented Interfaces:
BeanLocator,MutableBeanLocator
Default
MutableBeanLocator that locates qualified beans across a dynamic group of BindingPublishers.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConcurrentMap<Long,RankedBindings> private final Map<WatchedBeans,Object> private final ImplicitBindingsprivate final RankedSequence<BindingPublisher>private final Long[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(com.google.inject.Injector injector, int rank) Adds the given rankedInjectorand distributes itsBindings.booleanadd(BindingPublisher publisher) Adds the given rankedBindingPublisherand distributes itsBindings.(package private) voidautoPublish(com.google.inject.Injector injector) Automatically publishes anyInjectorthat contains a binding to thisBeanLocator.voidclear()Removes all knownBindingPublishers and theirBindings.private RankedBindingsfetchBindings(com.google.inject.TypeLiteral type, Long[] idReturn) Fetches any bindings currently associated with the given type.locate(com.google.inject.Key key) Finds bean implementations that match the given qualified bindingKey.Snapshot of currently registeredBindingPublishers.voidremove(com.google.inject.Injector injector) Removes the givenInjectorand itsBindings.booleanremove(BindingPublisher publisher) Removes the givenBindingPublisherand itsBindings.(package private) static voidstaticAutoPublish(MutableBeanLocator locator, com.google.inject.Injector injector) voidTracks bean implementations that match the given qualified bindingKey.
-
Field Details
-
publishers
-
cachedBindings
-
cachedWatchers
-
implicitBindings
-
typeIdHolder
-
-
Constructor Details
-
DefaultBeanLocator
public DefaultBeanLocator()
-
-
Method Details
-
locate
Description copied from interface:BeanLocatorFinds bean implementations that match the given qualified bindingKey.- Specified by:
locatein interfaceBeanLocator- Parameters:
key- The qualified key- Returns:
- Sequence of bean entries that match the given key
-
watch
Description copied from interface:BeanLocatorTracks bean implementations that match the given qualified bindingKey.Uses the
Mediatorpattern to send events to an arbitrary watcher object.- Specified by:
watchin interfaceBeanLocator- Parameters:
key- The qualified keymediator- The event mediatorwatcher- The bean watcher
-
add
Description copied from interface:MutableBeanLocatorAdds the given rankedBindingPublisherand distributes itsBindings.- Specified by:
addin interfaceMutableBeanLocator- Parameters:
publisher- The new publisher- Returns:
trueif the publisher was added; otherwisefalse
-
remove
Description copied from interface:MutableBeanLocatorRemoves the givenBindingPublisherand itsBindings.- Specified by:
removein interfaceMutableBeanLocator- Parameters:
publisher- The old publisher- Returns:
trueif the publisher was removed; otherwisefalse
-
publishers
Description copied from interface:MutableBeanLocatorSnapshot of currently registeredBindingPublishers.- Specified by:
publishersin interfaceMutableBeanLocator- Returns:
- The registered
BindingPublishers
-
clear
public void clear()Description copied from interface:MutableBeanLocatorRemoves all knownBindingPublishers and theirBindings.- Specified by:
clearin interfaceMutableBeanLocator
-
add
public void add(com.google.inject.Injector injector, int rank) Description copied from interface:MutableBeanLocatorAdds the given rankedInjectorand distributes itsBindings. Marked as deprecated because most clients should not call this method; any injector with an instance binding to aBeanLocatoris automatically added to that locator as part of the bootstrapping process.- Specified by:
addin interfaceMutableBeanLocator- Parameters:
injector- The new injectorrank- The assigned rank; should reflect the injector'sRankingFunction.maxRank()
-
remove
public void remove(com.google.inject.Injector injector) Description copied from interface:MutableBeanLocatorRemoves the givenInjectorand itsBindings.- Specified by:
removein interfaceMutableBeanLocator- Parameters:
injector- The old injector
-
fetchBindings
Fetches any bindings currently associated with the given type.- Parameters:
type- The generic typeidReturn- Optional holder, returns the assigned type id- Returns:
- Associated bindings;
nullif this is a new type
-
autoPublish
@Inject void autoPublish(com.google.inject.Injector injector) Automatically publishes anyInjectorthat contains a binding to thisBeanLocator.- Parameters:
injector- The injector
-
staticAutoPublish
@Inject static void staticAutoPublish(MutableBeanLocator locator, com.google.inject.Injector injector)
-