Class FactoryBeanProvider
- java.lang.Object
-
- net.sf.jguiraffe.di.impl.providers.LifeCycleBeanProvider
-
- net.sf.jguiraffe.di.impl.providers.FactoryBeanProvider
-
- All Implemented Interfaces:
BeanInitializer,BeanProvider
public class FactoryBeanProvider extends LifeCycleBeanProvider
A specialized life-cycle supporting
implementation for creating new bean instances on each invocation.BeanProviderEach time an instance of this class is invoked in a transaction a new instance of the managed bean class will be created. The implementation ensures that reentrant calls in a transaction always return the same bean instance, so in each transaction exactly one bean is created.
- Version:
- $Id: FactoryBeanProvider.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description FactoryBeanProvider(BeanProvider createProvider)Creates a new instance ofFactoryBeanProviderand initializes it with the bean provider for creating a bean instance.FactoryBeanProvider(BeanProvider createProvider, Invokable initinv)Creates a new instance ofFactoryBeanProviderand initializes it with the bean provider for creating a bean instance and the invocation object for performing initialization.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectgetBean(DependencyProvider dependencyProvider)Returns the bean managed by this bean provider.voidsetLockID(Long lid)Sets the ID of the locking transaction.-
Methods inherited from class net.sf.jguiraffe.di.impl.providers.LifeCycleBeanProvider
canInitialize, createBean, doCreateBean, fetchBean, fetchInitializedBeanInstance, getBeanClass, getBeanCreator, getBeanInitializer, getDependencies, getLockID, hasBean, initBean, initialize, isBeanAvailable, resetBean, shutdown, toString
-
-
-
-
Constructor Detail
-
FactoryBeanProvider
public FactoryBeanProvider(BeanProvider createProvider, Invokable initinv)
Creates a new instance ofFactoryBeanProviderand initializes it with the bean provider for creating a bean instance and the invocation object for performing initialization.- Parameters:
createProvider- the bean provider used for creating a new bean instance (must not be null)initinv- the (optional) invocation object for performing initialization- Throws:
IllegalArgumentException- if the bean provider is undefined
-
FactoryBeanProvider
public FactoryBeanProvider(BeanProvider createProvider)
Creates a new instance ofFactoryBeanProviderand initializes it with the bean provider for creating a bean instance.- Parameters:
createProvider- the bean provider used for creating a new bean instance (must not be null)- Throws:
IllegalArgumentException- if the bean provider is undefined
-
-
Method Detail
-
getBean
public Object getBean(DependencyProvider dependencyProvider)
Returns the bean managed by this bean provider. This implementation will return a new bean instance for each transaction.- Parameters:
dependencyProvider- the dependency provider- Returns:
- the bean managed by this provider
-
setLockID
public void setLockID(Long lid)
Sets the ID of the locking transaction. This implementation resets the managed bean when a new transaction starts. This has the effect that a new bean instance will be created for this transaction.- Specified by:
setLockIDin interfaceBeanProvider- Overrides:
setLockIDin classLifeCycleBeanProvider- Parameters:
lid- the ID of the locking transaction- See Also:
BeanProvider.getLockID()
-
-