Class ContextReplacementUtility


  • public class ContextReplacementUtility
    extends java.lang.Object
    Utility class to replace existing beans in the context and update their references.
    • Method Detail

      • replace

        public <T> boolean replace​(T bean,
                                   T instantiatedBean,
                                   java.util.Set<IRebinabable> rebindalbeObjects)
        Replace all references to the bean in other registered beans and replace it in the context. If the bean is not instanciated and stored in the context false will be returned. This may happen for lazy beans that are not yet instantiated or beans of Scope prototype which are not stored in the context.
        Type Parameters:
        T - type of the bean
        Parameters:
        bean - that will replace the existing bean
        instantiatedBean - bean currently in the context
        rebindalbeObjects - set of beans that are rebindable
        Returns:
        true if all references and the instance in the context were replaced.
      • replaceInContext

        <T> void replaceInContext​(T replacement,
                                  T instantiatedBean)
      • replaceWiredBean

        <T> void replaceWiredBean​(java.lang.Object b,
                                  T bean,
                                  T instanciatedBean,
                                  java.util.Set<IRebinabable> rebindalbeObjects)
        Replace the instance instanciatedBean of type T in b that is wired with bean. T is a singleton bean.
        Type Parameters:
        T - type of the bean
        Parameters:
        b - Bean in which the new bean should be replaced
        bean - that there reference should be replaced with.
        instanciatedBean - bean currently in the context
        rebindalbeObjects - set of beans that are rebindable
      • getFieldType

        private java.lang.Class getFieldType​(java.lang.reflect.Field field)
      • isSerializableBean

        private boolean isSerializableBean​(java.lang.Class clazz)
      • getAllInstantiatedBeans

        java.util.List<java.lang.Object> getAllInstantiatedBeans()