public class ComponentBag extends Object
contract provider
model
for the registered component type and stores it with the component registration.
The rules for managing components inside a component bag are derived from the
rules of JAX-RS Configurable
API. In short:
Modifier and Type | Field and Description |
---|---|
static Predicate<ContractProvider> |
BINDERS_ONLY
A filtering strategy that includes only models that contain
Binder provider contract. |
static Predicate<ContractProvider> |
EXCLUDE_EMPTY
A filtering strategy that excludes models with no recognized contracts.
|
static Predicate<ContractProvider> |
EXECUTOR_SERVICE_PROVIDER_ONLY
A filtering strategy that includes only models that contain
ExecutorServiceProvider provider contract. |
static BiPredicate<ContractProvider,InjectionManager> |
EXTERNAL_ONLY
A filtering strategy that includes only models that contain contract registrable by
InjectionManager . |
static Predicate<ContractProvider> |
INCLUDE_ALL
A filtering strategy that accepts any contract provider model.
|
static Predicate<ContractProvider> |
SCHEDULED_EXECUTOR_SERVICE_PROVIDER_ONLY
A filtering strategy that includes only models that contain
ScheduledExecutorServiceProvider provider contract. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all the component registrations and resets the component bag instance to
a state as if it was create anew.
|
ComponentBag |
copy()
Get a copy of this component bag.
|
static Predicate<ContractProvider> |
excludeMetaProviders(InjectionManager injectionManager)
A method creates the
Predicate which is able to filter all Jersey meta-providers along with the components which
is able to register the current used InjectionManager . |
Set<Class<?>> |
getClasses()
|
Set<Class<?>> |
getClasses(Predicate<ContractProvider> filter)
Get a subset of all registered component classes using the
filter predicate
to determine for each component class based on it's contract provider class model whether
it should be kept or filtered out. |
static <T> List<T> |
getFromBinders(InjectionManager injectionManager,
ComponentBag componentBag,
Function<Object,T> cast,
Predicate<Binding> filter)
If
T object is registered in ComponentBag using the Binder , T is not visible using the
methods for getting classes and instances getClasses(Predicate) and
getInstances(Predicate) . |
Set<Object> |
getInstances()
|
Set<Object> |
getInstances(Predicate<ContractProvider> filter)
Get a subset of all registered component instances using the
filter predicate
to determine for each component instance based on it's contract provider class model whether
it should be kept or filtered out. |
ContractProvider |
getModel(Class<?> componentClass)
Get a model for a given component class, or
null if no such component is registered
in the component bag. |
Set<Class<?>> |
getRegistrations()
Get an unmodifiable view of all component classes, for which a registration exists
(either class or instance based) in the component bag.
|
ComponentBag |
immutableCopy()
Get immutable copy of a component bag.
|
static ContractProvider |
modelFor(Class<?> componentClass)
Create a contract provider model by introspecting a component class.
|
static ComponentBag |
newInstance(Predicate<ContractProvider> registrationStrategy)
Create new empty component bag.
|
boolean |
register(Class<?> componentClass,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component class using a given registration strategy.
|
boolean |
register(Class<?> componentClass,
int priority,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component class as a contract provider with an explicitly specified binding priority.
|
boolean |
register(Class<?> componentClass,
Map<Class<?>,Integer> contracts,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component class as a contract provider for the specified contracts.
|
boolean |
register(Class<?> componentClass,
Set<Class<?>> contracts,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component class as a contract provider for the specified contracts.
|
boolean |
register(Object component,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component using a given registration strategy.
|
boolean |
register(Object component,
int priority,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component as a contract provider with an explicitly specified binding priority.
|
boolean |
register(Object component,
Map<Class<?>,Integer> contracts,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component as a contract provider for the specified contracts.
|
boolean |
register(Object component,
Set<Class<?>> contracts,
Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
Register a component as a contract provider for the specified contracts.
|
public static final BiPredicate<ContractProvider,InjectionManager> EXTERNAL_ONLY
InjectionManager
.
This filter predicate returns true
for all contract provider models
that represent an object which can be registered using specific InjectionManager
contract.
public static final Predicate<ContractProvider> BINDERS_ONLY
Binder
provider contract.
This filter predicate returns true
for all contract provider models
that represent a provider registered to provide Binder
contract.
public static final Predicate<ContractProvider> EXECUTOR_SERVICE_PROVIDER_ONLY
ExecutorServiceProvider
provider contract.
This filter predicate returns true
for all contract provider models
that represent a provider registered to provide ExecutorServiceProvider
contract.
public static final Predicate<ContractProvider> SCHEDULED_EXECUTOR_SERVICE_PROVIDER_ONLY
ScheduledExecutorServiceProvider
provider contract.
This filter predicate returns true
for all contract provider models
that represent a provider registered to provide ScheduledExecutorServiceProvider
contract.
public static final Predicate<ContractProvider> EXCLUDE_EMPTY
This filter predicate returns false
for all contract provider models
that are empty, i.e. do not contain any recognized contracts.
public static final Predicate<ContractProvider> INCLUDE_ALL
This filter predicate returns true
for any contract provider model.
public static Predicate<ContractProvider> excludeMetaProviders(InjectionManager injectionManager)
Predicate
which is able to filter all Jersey meta-providers along with the components which
is able to register the current used InjectionManager
.injectionManager
- current injection manager.Predicate
excluding Jersey meta-providers and the specific ones for a current InjectionManager
.public static ComponentBag newInstance(Predicate<ContractProvider> registrationStrategy)
registrationStrategy
- function driving the decision (based on the introspected
contract provider model
) whether
or not should the component class registration continue
towards a successful completion.public static <T> List<T> getFromBinders(InjectionManager injectionManager, ComponentBag componentBag, Function<Object,T> cast, Predicate<Binding> filter)
T
object is registered in ComponentBag
using the Binder
, T
is not visible using the
methods for getting classes and instances getClasses(Predicate)
and
getInstances(Predicate)
.
Method selects all bindings
and picks up the instances or creates
the instances from ClassBinding
(injection does not work at this moment).
injectionManager
- injection manager to create an object from T
class.componentBag
- component bag which provides registered binders.public boolean register(Class<?> componentClass, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
componentClass
- class to be introspected as a contract provider and registered, based
on the registration strategy decision.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Class<?> componentClass, int priority, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
componentClass
- class to be introspected as a contract provider and registered.priority
- explicitly specified binding priority for the provider contracts implemented
by the component.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Class<?> componentClass, Set<Class<?>> contracts, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
componentClass
- class to be introspected as a contract provider and registered.contracts
- contracts to bind the component class to.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Class<?> componentClass, Map<Class<?>,Integer> contracts, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
componentClass
- class to be introspected as a contract provider and registered.contracts
- contracts with their priorities to bind the component class to.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Object component, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
component
- instance to be introspected as a contract provider and registered, based
on the registration strategy decision.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Object component, int priority, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
component
- instance to be introspected as a contract provider and registered, based
on the registration strategy decision.priority
- explicitly specified binding priority for the provider contracts implemented
by the component.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Object component, Set<Class<?>> contracts, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
component
- instance to be introspected as a contract provider and registered, based
on the registration strategy decision.contracts
- contracts to bind the component to.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public boolean register(Object component, Map<Class<?>,Integer> contracts, Inflector<ContractProvider.Builder,ContractProvider> modelEnhancer)
component
- instance to be introspected as a contract provider and registered, based
on the registration strategy decision.contracts
- contracts with their priorities to bind the component to.modelEnhancer
- custom contract provider model enhancer.true
if the component registration was successful.public static ContractProvider modelFor(Class<?> componentClass)
componentClass
- component class to create contract provider model for.public Set<Class<?>> getClasses(Predicate<ContractProvider> filter)
filter
predicate
to determine for each component class based on it's contract provider class model whether
it should be kept or filtered out.filter
- function that decides whether a particular class should be returned
or not.public Set<Object> getInstances(Predicate<ContractProvider> filter)
filter
predicate
to determine for each component instance based on it's contract provider class model whether
it should be kept or filtered out.filter
- function that decides whether a particular class should be returned
or not.public Set<Class<?>> getRegistrations()
public ContractProvider getModel(Class<?> componentClass)
null
if no such component is registered
in the component bag.componentClass
- class of the registered component to retrieve the
contract provider model for.null
if no such component is registered.public ComponentBag copy()
public ComponentBag immutableCopy()
public void clear()
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.