public interface DependencyProvider extends ClassLoaderProvider
Definition of an interface that provides access to dependencies defined by a
BeanProvider
.
This interface is used by a BeanProvider
implementation for resolving its dependencies to other beans. An
implementation of this interface is passed to the bean provider's
getBean()
method, allowing access to the required
dependencies. By extending the ClassLoaderProvider
interface
functionality for dealing with dynamic class loading is also available through
this interface.
Note that this interface is used internally by the framework. Clients
probably won't have to deal with it directly. It is only of importance for
custom implementations of the BeanProvider
interface.
CONTEXT_CLASS_LOADER
Modifier and Type | Method and Description |
---|---|
void |
addInitializer(BeanInitializer initializer)
Registers a
BeanInitializer . |
void |
beanCreated(Object bean,
BeanProvider provider)
Notifies this
DependencyProvider about the creation of a bean. |
Object |
getDependentBean(Dependency dependency)
Returns the dependency bean for the specified dependency.
|
InvocationHelper |
getInvocationHelper()
Returns a reference to the current
InvocationHelper object. |
boolean |
isBeanAvailable(Dependency dependency)
Checks whether the bean specified by the given
Dependency
is currently available. |
void |
setCreationBeanContext(BeanContext context)
Sets the
BeanContext that is responsible for a
BeanCreationEvent notification. |
classLoaderNames, getClassLoader, getDefaultClassLoaderName, loadClass, registerClassLoader, setDefaultClassLoaderName
Object getDependentBean(Dependency dependency)
getDependencies()
method.dependency
- the dependency pointing to the bean in questionInjectionException
- if the bean cannot be resolvedboolean isBeanAvailable(Dependency dependency)
Dependency
is currently available. This method can be used by complex bean providers
to find out whether an initialization of their managed bean is now
possible. Because of cyclic dependencies it may be the case that a
required dependency cannot be resolved now. The affected bean provider
can then register itself as an initializer and try again after
the creation phase has completed.dependency
- the dependency pointing to the bean in questionInjectionException
- if the dependency cannot be resolvedaddInitializer(BeanInitializer)
void addInitializer(BeanInitializer initializer)
BeanInitializer
. This object will be called
at the end of the transaction when all beans have been created. This
gives complex bean providers an opportunity of trying some
initializations again that were not possible before because of cyclic
dependencies. A concrete implementation has to ensure that the
initializers registered here are always called before the current
transaction ends - no matter whether it succeeds or fails.initializer
- the initializer to registervoid beanCreated(Object bean, BeanProvider provider)
DependencyProvider
about the creation of a bean.
This method has to be called by BeanProvider
implementations when
a new bean has been completely created. It allows the framework to
perform some post processing, e.g. enhanced initialization of the new
bean or notification of context listeners.bean
- the newly created beanprovider
- the BeanProvider
responsible for this beanvoid setCreationBeanContext(BeanContext context)
BeanContext
that is responsible for a
BeanCreationEvent
notification. This method can be used by
implementations of the BeanContext
interface that wrap other
contexts, e.g. a combined bean context. Such wrapping contexts usually
delegate to other contexts when a bean is requested. If such a request
causes a new bean to be created, the corresponding BeanCreationEvent
per default has the wrapped context as its source, and
also a BeanContextClient
object will be initialized with this
context. However, it may be appropriate to set the wrapping context as
source. This can be achieved by registering a
BeanCreationListener
at the wrapped contexts. In the event
handling method the setCreationBeanContext()
can be called with
the wrapping context as parameter. Then correct creation context is known
and can also be passed to a BeanContextClient
.context
- the BeanContext
responsible for a bean creationInvocationHelper getInvocationHelper()
InvocationHelper
object. This
helper object can be used by bean providers for more advanced operations
related to reflection, e.g. method invocations or data type conversions.
Especially the data type conversion facilities provided by
InvocationHelper
may be of interest. The object returned by an
implementation should be a central instance, i.e. the same instance that
has been used for registering custom converter implementations.InvocationHelper
objectCopyright © 2016 The JGUIraffe Team. All rights reserved.