Class FactoryBeanProvider

  • All Implemented Interfaces:
    BeanInitializer, BeanProvider

    public class FactoryBeanProvider
    extends LifeCycleBeanProvider

    A specialized life-cycle supporting BeanProvider implementation for creating new bean instances on each invocation.

    Each 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 Detail

      • FactoryBeanProvider

        public FactoryBeanProvider​(BeanProvider createProvider,
                                   Invokable initinv)
        Creates a new instance of FactoryBeanProvider and 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 of FactoryBeanProvider and 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:
        setLockID in interface BeanProvider
        Overrides:
        setLockID in class LifeCycleBeanProvider
        Parameters:
        lid - the ID of the locking transaction
        See Also:
        BeanProvider.getLockID()