public void add(Statement statement) { statements.add(statement); //we execute bean configuration statements in the order they are declared. if (statement instanceof InstantiationStatement) { InstantiationStatement is = (InstantiationStatement)statement; beanConfigurations.add(new BeanConfiguration(is)); } else { AssignmentStatement as = (AssignmentStatement)statement; //statements always apply to the most recently defined bean configuration with the same name, so we //have to traverse the configuration list starting at the end (most recent elements are appended): boolean addedToConfig = false; String beanName = as.getRootBeanName(); for( int i = beanConfigurations.size()-1; i >= 0; i--) { BeanConfiguration mostRecent = beanConfigurations.get(i); String mostRecentBeanName = mostRecent.getBeanName(); if (beanName.equals(mostRecentBeanName)) { mostRecent.add(as); addedToConfig = true; break; } } if (!addedToConfig) { // the AssignmentStatement must be for an existing bean that does not yet have a corresponding // configuration object (this would happen if the bean is in the default objects map). Because // BeanConfiguration instances don't exist for default (already instantiated) beans, // we simulate a creation of one to satisfy this processors implementation: beanConfigurations.add(new BeanConfiguration(as)); } } }
public void add(Statement statement) { statements.add(statement); //we execute bean configuration statements in the order they are declared. if (statement instanceof InstantiationStatement) { InstantiationStatement is = (InstantiationStatement)statement; beanConfigurations.add(new BeanConfiguration(is)); } else { AssignmentStatement as = (AssignmentStatement)statement; //statements always apply to the most recently defined bean configuration with the same name, so we //have to traverse the configuration list starting at the end (most recent elements are appended): boolean addedToConfig = false; String beanName = as.getRootBeanName(); for( int i = beanConfigurations.size()-1; i >= 0; i--) { BeanConfiguration mostRecent = beanConfigurations.get(i); String mostRecentBeanName = mostRecent.getBeanName(); if (beanName.equals(mostRecentBeanName)) { mostRecent.add(as); addedToConfig = true; break; } } if (!addedToConfig) { // the AssignmentStatement must be for an existing bean that does not yet have a corresponding // configuration object (this would happen if the bean is in the default objects map). Because // BeanConfiguration instances don't exist for default (already instantiated) beans, // we simulate a creation of one to satisfy this processors implementation: beanConfigurations.add(new BeanConfiguration(as)); } } }
private BeanConfiguration(AssignmentStatement as) { this.instantiationStatement = null; this.beanName = as.getRootBeanName(); add(as); }
private BeanConfiguration(AssignmentStatement as) { this.instantiationStatement = null; this.beanName = as.getRootBeanName(); add(as); }