Class ReloadableBeanFactoryImpl

  • All Implemented Interfaces:
    Resettable, org.springframework.beans.factory.FactoryBean

    public class ReloadableBeanFactoryImpl
    extends Object
    implements Resettable, org.springframework.beans.factory.FactoryBean
    This factory wraps a FactoryBean delegate. Instead of returning the produced object directly, it wraps that object in a proxy. Under normal circumstances, this will be transparent to the user and the class will behave like a regular FactoryBean (and the returned object like a regular object).

    The difference is that the proxies returned from this factory can be made to point to a different object, freshly retrieved from the FactoryBean. This lets us reload OSGi services without touching existing references to old services in Spring beans that are already wired.

    If factory is created using ReloadableBeanFactoryImpl(Class, Object...) constructor, the new bean will be retrieved from a new FactoryBean object (it's the recommended way of using this class, because it will deal with stateful FactoryBeans).

    ReloadableBeanFactoriesImpl bean processor automatically registers all instances of Resettable and will call reload on each of them when asked. This happens during hotswap import.

    • Field Detail

      • bean

        protected final io.atlassian.util.concurrent.ResettableLazyReference<Object> bean
      • factoryBean

        protected volatile org.springframework.beans.factory.FactoryBean factoryBean
      • proxyReference

        protected final io.atlassian.util.concurrent.ResettableLazyReference<Object> proxyReference
    • Constructor Detail

      • ReloadableBeanFactoryImpl

        public ReloadableBeanFactoryImpl​(Class<?> cls,
                                         Object... args)
        Use this one to be able to reload bean and factory that will be created from class constructor with provided arguments
        Parameters:
        cls - factory bean class
        args - constructor arguments to create factory bean
    • Method Detail

      • getObject

        public Object getObject()
                         throws Exception
        Specified by:
        getObject in interface org.springframework.beans.factory.FactoryBean
        Throws:
        Exception
      • getObjectType

        public Class getObjectType()
        Specified by:
        getObjectType in interface org.springframework.beans.factory.FactoryBean
      • isSingleton

        public boolean isSingleton()
        Specified by:
        isSingleton in interface org.springframework.beans.factory.FactoryBean
      • reset

        public void reset()
        Specified by:
        reset in interface Resettable