package com.griddynamics.jagger.xml;

import com.griddynamics.jagger.engine.e1.Provider;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * Processor, which set Prototype scope to all Providers in spring context
 * @author kgribov
 */
public class ProviderBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        String[] beanNames = beanFactory.getBeanNamesForType(Provider.class);
        for (String beanName : beanNames) {
            BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
            beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
        }
    }
}

@@ -866,16 +866,161 @@
 nName);%0A
+            // if user doesn't use scope attribute, we set prototype scope as default%0A            if (%22%22.equals(beanDefinition.getScope()))%7B%0A    
         
@@ -1080,16 +1080,30 @@
 OTYPE);%0A
+            %7D%0A
         

Check scope attribute value