|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.di.impl.RestrictedDependencyProvider
public class RestrictedDependencyProvider
An implementation of the DependencyProvider interface, which does not
support external dependencies.
This class allows the execution of simple Invokable objects, which do
not require access to other beans stored in a BeanContext. The
methods defined by the ClassLoaderProvider interface are fully
implemented (by delegating to a wrapped ClassLoaderProvider). But
other methods for dealing with dependencies throw an exception. This makes it
possible to execute simple invocation scripts (e.g. defined by a
ChainedInvocation), including access to local variables. However,
other bean providers cannot be accessed.
A use case for this class is the execution of a shutdown script by a bean
provider that is no longer needed. At the time the shutdown script is invoked
the corresponding BeanContext (or BeanStore) may already be
partly destroyed, so access to other beans is not safe. Nevertheless
arbitrary methods on the affected bean can be invoked.
When creating an instance of this class a ClassLoaderProvider object
must be provided. All methods dealing with classes and class loaders are
passed to this object. The other methods are implemented by simply throwing
an exception.
| Field Summary |
|---|
| Fields inherited from interface net.sf.jguiraffe.di.ClassLoaderProvider |
|---|
CONTEXT_CLASS_LOADER |
| Constructor Summary | |
|---|---|
RestrictedDependencyProvider(ClassLoaderProvider clp)
Creates a new instance of RestrictedDependencyProvider and
initializes it with the specified ClassLoaderProvider. |
|
| Method Summary | |
|---|---|
void |
addInitializer(BeanInitializer initializer)
Adds a BeanInitializer. |
void |
beanCreated(java.lang.Object bean,
BeanProvider provider)
Notifies this dependency provider about a newly created bean. |
java.util.Set<java.lang.String> |
classLoaderNames()
Returns a set with the names of all class loaders registered at this object. |
java.lang.ClassLoader |
getClassLoader(java.lang.String name)
Returns the class loader that was registered under the given name. |
ClassLoaderProvider |
getClassLoaderProvider()
Returns the wrapped ClassLoaderProvider. |
java.lang.ClassLoader |
getDefaultClassLoader()
Returns the default class loader. |
java.lang.Object |
getDependentBean(Dependency dependency)
Returns a dependent bean. |
boolean |
isBeanAvailable(Dependency dependency)
Checks whether a bean is available. |
java.lang.Class<?> |
loadClass(java.lang.String name,
java.lang.String loaderRef)
Loads a class using the specified class loader. |
void |
registerClassLoader(java.lang.String name,
java.lang.ClassLoader loader)
Registers a class loader under a name. |
void |
setCreationBeanContext(BeanContext context)
Sets the context that is responsible for a bean creation event. |
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 RestrictedDependencyProvider(ClassLoaderProvider clp)
RestrictedDependencyProvider and
initializes it with the specified ClassLoaderProvider.
clp - the ClassLoaderProvider (must not be null)
java.lang.IllegalArgumentException - if the ClassLoaderProvider is
null| Method Detail |
|---|
public ClassLoaderProvider getClassLoaderProvider()
ClassLoaderProvider.
ClassLoaderProviderpublic void addInitializer(BeanInitializer initializer)
BeanInitializer. This implementation just throws an
exception.
addInitializer in interface DependencyProviderinitializer - the initializer
public void beanCreated(java.lang.Object bean,
BeanProvider provider)
beanCreated in interface DependencyProviderbean - the new beanprovider - the responsible bean providerpublic java.lang.Object getDependentBean(Dependency dependency)
Dependency with a null bean store. If a bean provider is
returned, this provider's bean is queried. This way certain Dependency implementations can be served, while others cause an
exception.
getDependentBean in interface DependencyProviderdependency - the dependency to resolve
InjectionException - if the Dependency cannot be resolvedpublic boolean isBeanAvailable(Dependency dependency)
isBeanAvailable in interface DependencyProviderdependency - the dependency to the bean
DependencyProvider.addInitializer(BeanInitializer)public void setCreationBeanContext(BeanContext context)
setCreationBeanContext in interface DependencyProvidercontext - the contextpublic 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 name is unknownpublic java.lang.ClassLoader getDefaultClassLoader()
ClassLoaderProvider.
getDefaultClassLoader in interface ClassLoaderProvider
public java.lang.Class<?> loadClass(java.lang.String name,
java.lang.String loaderRef)
ClassLoaderProvider.
loadClass in interface ClassLoaderProvidername - the name of the class to loadloaderRef - the name of the class loader
InjectionException - if an error occurs
public void registerClassLoader(java.lang.String name,
java.lang.ClassLoader loader)
ClassLoaderProvider.
registerClassLoader in interface ClassLoaderProvidername - the nameloader - the class loaderpublic void setDefaultClassLoader(java.lang.ClassLoader loader)
ClassLoaderProvider.
setDefaultClassLoader in interface ClassLoaderProviderloader - the new default class loader
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||