RestrictedBindingSource.
Enforcement happens in two phases:
PermitMapConstruction encapsulates this process, and the PermitMap is the end
result.
check,
which uses the PermitMap(s) built during Binder configuration.
Note
None of this is thread-safe because it's only used while the Injector is being built, which happens on a single thread.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static interface | BindingSourceRestriction.
Mapping between an element source and its permit annotations. |
| pack-priv static class | BindingSourceRestriction.
Builds the map from each module to all the permit annotations on its module stack. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ImmutableList | check(GuiceInternal guiceInternal, List<Element> elements)
Returns all the restriction violations found on the given Module Elements, as error messages. |
| private static ImmutableList | |
| private static ImmutableList | |
| private static Optional | |
| private static void | |
| private static void | |
| private static Iterable | |
| private static ImmutableSet | |
| public static Optional | getMissingImplementationSuggestion(GuiceInternal guiceInternal, Key<?> key)
Returns a suggestion for how a restricted binding should be created in case it's missing. |
| private static Stream | |
| private static RestrictedBindingSource | |
| private static String | getViolationMessage(Key<?> key, String explanation, ImmutableSet<Class<? extends Annotation>> acceptablePermits, boolean annotationRestricted)
|
| private static boolean |
| logger | back to summary |
|---|---|
| private static final Logger logger | |
| BindingSourceRestriction | back to summary |
|---|---|
| private BindingSourceRestriction() | |
| check | back to summary |
|---|---|
| public static ImmutableList Returns all the restriction violations found on the given Module Elements, as error messages. Note: Intended to be used on Module Elements, not Injector Elements, ie. the result of
| |
| check | back to summary |
|---|---|
| private static ImmutableList | |
| check | back to summary |
|---|---|
| private static ImmutableList | |
| check | back to summary |
|---|---|
| private static Optional | |
| clear | back to summary |
|---|---|
| private static void clear(Element element) | |
| clear | back to summary |
|---|---|
| private static void clear(ElementSource elementSource) | |
| getAllModules | back to summary |
|---|---|
| private static Iterable | |
| getAllPermits | back to summary |
|---|---|
| private static ImmutableSet Get all permits on the element source chain. | |
| getMissingImplementationSuggestion | back to summary |
|---|---|
| public static Optional Returns a suggestion for how a restricted binding should be created in case it's missing. | |
| getPermits | back to summary |
|---|---|
| private static Stream | |
| getRestriction | back to summary |
|---|---|
| private static RestrictedBindingSource getRestriction(Key<?> key) | |
| getViolationMessage | back to summary |
|---|---|
| private static String getViolationMessage(Key<?> key, String explanation, ImmutableSet<Class<? extends Annotation>> acceptablePermits, boolean annotationRestricted) | |
| isExempt | back to summary |
|---|---|
| private static boolean isExempt(ElementSource elementSource, String exemptModulesRegex) | |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public ImmutableSet |
| clear | back to summary |
|---|---|
| public void clear() | |
| getPermits | back to summary |
|---|---|
| public ImmutableSet | |
Bindings refer to the module that created them via a ModuleSource. The map built
here maps a module's ModuleSource to all the RestrictedBindingSource.
annotations found on the path from the root of the module hierarchy to it. This path contains
all the modules that transitively install the module (including the module itself). This path
is also known as the module stack.
The map is built by piggybacking on the depth-first traversal of the module hierarchy during Binder configuration.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv ImmutableSet | |
| pack-priv final Map | |
| pack-priv final Deque | |
| pack-priv final BindingSourceRestriction. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv BindingSourceRestriction. | |
| pack-priv static boolean | |
| pack-priv void | |
| pack-priv void | pushModule(Class<?> module, ModuleSource moduleSource)
Called by the Binder prior to entering a module's configure method. |
| pack-priv void | restoreCurrentModulePermits(ModuleSource moduleSource)
Sets the permits on the current module installation path to the permits on the given module source so that subsequently installed modules may inherit them. |
| currentModulePermits | back to summary |
|---|---|
| pack-priv ImmutableSet<Class<? extends Annotation>> currentModulePermits | |
| modulePermits | back to summary |
|---|---|
| pack-priv final Map<ModuleSource, ImmutableSet<Class<? extends Annotation>>> modulePermits | |
| modulePermitsStack | back to summary |
|---|---|
| pack-priv final Deque<ImmutableSet<Class<? extends Annotation>>> modulePermitsStack | |
| permitMap | back to summary |
|---|---|
| pack-priv final BindingSourceRestriction. | |
| PermitMapConstruction | back to summary |
|---|---|
| pack-priv PermitMapConstruction() | |
| finish | back to summary |
|---|---|
| pack-priv void finish() Finishes the | |
| getPermitMap | back to summary |
|---|---|
| pack-priv BindingSourceRestriction. Returns a possibly unfinished map. The map should only be used after the construction is finished. | |
| isElementSourceCleared | back to summary |
|---|---|
pack-priv static boolean isElementSourceCleared(ElementSource elementSource)
| |
| popModule | back to summary |
|---|---|
| pack-priv void popModule() Called by the Binder when it exits a module's configure method. | |
| pushModule | back to summary |
|---|---|
| pack-priv void pushModule(Class<?> module, ModuleSource moduleSource) Called by the Binder prior to entering a module's configure method. | |
| restoreCurrentModulePermits | back to summary |
|---|---|
| pack-priv void restoreCurrentModulePermits(ModuleSource moduleSource) Sets the permits on the current module installation path to the permits on the given module source so that subsequently installed modules may inherit them. Used only for method scanning, so that modules installed by scanners inherit permits from the method's module. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Map |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public ImmutableSet | getPermits(ElementSource elementSource)
Implements com. |
| modulePermits | back to summary |
|---|---|
| pack-priv Map<ModuleSource, ImmutableSet<Class<? extends Annotation>>> modulePermits | |
| PermitMapImpl | back to summary |
|---|---|
| private PermitMapImpl() | |
| clear | back to summary |
|---|---|
| public void clear() Implements com.
| |
| getPermits | back to summary |
|---|---|
| public ImmutableSet Implements com.
| |