|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.di.impl.DefaultDependencyProvider
class DefaultDependencyProvider
An internally used implementation of the DependencyProvider
interface.
An instance of this class is created by the default
implementation at the beginning of a
transaction. Its task is to obtain and cache all dependencies of the
currently requested bean. This can fail if a dependency cannot be resolved or
one of the dependent bean providers is already locked by another transaction.
In this case the transaction has to be suspended.
BeanContext
If an instance could be successfully initialized, it allows access to all
dependent bean providers - and no more. So the
getDependentBean() method can be implemented in a meaningful
way.
This class works closely together with the default bean context implementation. From there it also obtains a map with the registered class loaders.
| Field Summary |
|---|
| Fields inherited from interface net.sf.jguiraffe.di.ClassLoaderProvider |
|---|
CONTEXT_CLASS_LOADER |
| Constructor Summary | |
|---|---|
DefaultDependencyProvider(ClassLoaderProvider loaderProvider)
Creates a new instance of DefaultDependencyProvider and
initializes it with the class loader provider to be used. |
|
| Method Summary | |
|---|---|
void |
addInitializer(BeanInitializer initializer)
Adds a bean initializer. |
java.util.Set<java.lang.String> |
classLoaderNames()
Returns a set with the names of all registered class loaders. |
java.lang.ClassLoader |
getClassLoader(java.lang.String name)
Returns the class loader with the given symbolic name. |
ClassLoaderProvider |
getClassLoaderProvider()
Returns the internally used class loader provider. |
java.lang.ClassLoader |
getDefaultClassLoader()
Returns the default class loader. |
(package private) java.util.Map<Dependency,BeanProvider> |
getDependencyMap()
Returns a map with the resolved dependencies. |
java.lang.Object |
getDependentBean(Dependency dependency)
Returns the bean of the bean provider specified by the given dependency. |
BeanProvider |
getDependentProvider(Dependency dependency)
Returns the bean provider specified by the given dependency. |
boolean |
initialize(Dependency dependency,
BeanStore store)
Initializes this object. |
void |
invokeInitializers()
Invokes all registered bean initializers. |
boolean |
isBeanAvailable(Dependency dependency)
Tests whether a bean is available. |
java.lang.Class<?> |
loadClass(java.lang.String name,
java.lang.String loaderRef)
Loads the class with the specified name using the class loader identified by the given symbolic reference. |
void |
lock(java.lang.Long lockID)
Marks all resolved dependencies as locked. |
void |
registerClassLoader(java.lang.String name,
java.lang.ClassLoader loader)
Registers a class loader under a symbolic name. |
void |
setDefaultClassLoader(java.lang.ClassLoader loader)
Sets the default class loader. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultDependencyProvider(ClassLoaderProvider loaderProvider)
DefaultDependencyProvider and
initializes it with the class loader provider to be used.
loaderProvider - the class loader provider| Method Detail |
|---|
public boolean initialize(Dependency dependency,
BeanStore store)
InjectionException exception is
thrown. The return value indicates whether all found bean providers are
unlocked. If a locked provider is found, the method is aborted, and
false is returned.
dependency - the initial dependency to resolvestore - the starting bean store
InjectionException - if a dependency cannot be resolvedpublic ClassLoaderProvider getClassLoaderProvider()
public void lock(java.lang.Long lockID)
initialize(). It sets
the lock IDs for all involved BeanProviders, so that they
cannot take part in another concurrent transaction. A second call to this
method with the argument null releases all locks.
lockID - the lock IDpublic BeanProvider getDependentProvider(Dependency dependency)
initialize() method.
dependency - the dependency
InjectionException - if the dependency cannot be resolvedpublic java.lang.Object getDependentBean(Dependency dependency)
initialize() method.
getDependentBean in interface DependencyProviderdependency - the dependency
InjectionException - if the dependency cannot be resolvedpublic java.util.Set<java.lang.String> classLoaderNames()
ClassLoaderProvider.
classLoaderNames in interface ClassLoaderProviderpublic java.lang.ClassLoader getClassLoader(java.lang.String name)
ClassLoaderProvider.
getClassLoader in interface ClassLoaderProvidername - the name of the class loader
InjectionException - if the class loader cannot be resolvedpublic java.lang.ClassLoader getDefaultClassLoader()
ClassLoaderProvider.
getDefaultClassLoader in interface ClassLoaderProvider
public void registerClassLoader(java.lang.String name,
java.lang.ClassLoader loader)
ClassLoaderProvider.
registerClassLoader in interface ClassLoaderProvidername - the symbolic name for the class loaderloader - the class loader to registerpublic void setDefaultClassLoader(java.lang.ClassLoader loader)
ClassLoaderProvider.
setDefaultClassLoader in interface ClassLoaderProviderloader - the new default class loader
public java.lang.Class<?> loadClass(java.lang.String name,
java.lang.String loaderRef)
ClassLoaderProvider.
loadClass in interface ClassLoaderProvidername - the class of the name to be loadedloaderRef - determines the class loader to be used
InjectionException - if the class cannot be loadedpublic void addInitializer(BeanInitializer initializer)
invokeInitializers() method.
addInitializer in interface DependencyProviderinitializer - the initializer to be added (may be null, then
this operation has no effect)public void invokeInitializers()
InjectionException - if an error occurspublic boolean isBeanAvailable(Dependency dependency)
isBeanAvailable in interface DependencyProviderdependency - the dependency
DependencyProvider.addInitializer(BeanInitializer)java.util.Map<Dependency,BeanProvider> getDependencyMap()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||