public class SingletonBeanProvider extends LifeCycleBeanProvider
A specialized life-cycle supporting BeanProvider implementation for
creating singleton beans.
When the getBean() method of an instance of this class is called for
the first time, all dependencies are resolved, and a new bean instance is
created (using the specified creation bean provider). Following calls to
getBean() always return this same bean instance. In fact, this
provider then behaves like a constant bean provider: it does not declare any
dependencies any more and does not need any synchronization support (i.e. the
getLockID() method will always return null). This means that
providers of this type can be efficiently used in a multi-threaded
environment once they are initialized.
Instances of this class can also be initialized with an Invokable to
be called when the bean is no more needed. This Invokable is
triggered by the shutdown() method. This mechanism makes it possible
to perform cleanup when a bean store is closed.
| Constructor and Description |
|---|
SingletonBeanProvider(BeanProvider createProvider)
Creates a new instance of
SingletonBeanProvider and
initializes it with the bean provider for creating a bean instance. |
SingletonBeanProvider(BeanProvider createProvider,
Invokable initinv)
Creates a new instance of
SingletonBeanProvider and
initializes it with the bean provider for creating a bean instance and
the invocation object for performing initialization. |
SingletonBeanProvider(BeanProvider createProvider,
Invokable initInv,
Invokable shutdownInv)
Creates a new instance of
SingletonBeanProvider and initializes
it with the bean provider for creating a bean instance and Invokable objects for initializing and releasing the bean managed by
this provider. |
| Modifier and Type | Method and Description |
|---|---|
Object |
getBean(DependencyProvider dependencyProvider)
Returns the bean managed by this bean provider.
|
Set<Dependency> |
getDependencies()
Returns the dependencies of this bean provider.
|
Long |
getLockID()
Returns the ID of the locking transaction.
|
Invokable |
getShutdownHandler()
Returns the
Invokable object that is called when this provider is
shut down. |
void |
shutdown(DependencyProvider depProvider)
Tells this provider that it is no more needed.
|
canInitialize, createBean, doCreateBean, fetchBean, fetchInitializedBeanInstance, getBeanClass, getBeanCreator, getBeanInitializer, hasBean, initBean, initialize, isBeanAvailable, resetBean, setLockID, toStringpublic SingletonBeanProvider(BeanProvider createProvider, Invokable initInv, Invokable shutdownInv)
SingletonBeanProvider and initializes
it with the bean provider for creating a bean instance and Invokable objects for initializing and releasing the bean managed by
this provider.createProvider - the bean provider used for creating a new bean
instance (must not be null)initInv - the (optional) invocation object for performing
initializationshutdownInv - the (optional) Invokable object to be called
on shutdownIllegalArgumentException - if the bean provider is undefinedpublic SingletonBeanProvider(BeanProvider createProvider, Invokable initinv)
SingletonBeanProvider and
initializes it with the bean provider for creating a bean instance and
the invocation object for performing initialization.createProvider - the bean provider used for creating a new bean
instance (must not be null)initinv - the (optional) invocation object for performing
initializationIllegalArgumentException - if the bean provider is undefinedpublic SingletonBeanProvider(BeanProvider createProvider)
SingletonBeanProvider and
initializes it with the bean provider for creating a bean instance.createProvider - the bean provider used for creating a new bean
instance (must not be null)IllegalArgumentException - if the bean provider is undefinedpublic Invokable getShutdownHandler()
Invokable object that is called when this provider is
shut down. This can be null if no shutdown handler was set.Invokable to be called on shutdownpublic Object getBean(DependencyProvider dependencyProvider)
dependencyProvider - the dependency providerInjectionException - if an error occurspublic Set<Dependency> getDependencies()
getDependencies in interface BeanProvidergetDependencies in class LifeCycleBeanProviderDependencypublic Long getLockID()
getLockID in interface BeanProvidergetLockID in class LifeCycleBeanProviderpublic void shutdown(DependencyProvider depProvider)
shutdown in interface BeanProvidershutdown in class LifeCycleBeanProviderdepProvider - the DependencyProviderCopyright © 2016 The JGUIraffe Team. All rights reserved.