1 4 package com.tc.config.schema.test; 5 6 import com.tc.config.schema.builder.SpringApplicationContextConfigBuilder; 7 import com.tc.config.schema.builder.SpringBeanConfigBuilder; 8 9 10 public class SpringApplicationContextConfigBuilderImpl extends BaseConfigBuilder implements SpringApplicationContextConfigBuilder { 11 12 protected SpringApplicationContextConfigBuilderImpl() { 13 super(5, new String [] { "paths", "beans" }); 14 } 15 16 public static SpringApplicationContextConfigBuilder newMinimalInstance() { 17 return new SpringApplicationContextConfigBuilderImpl(); 18 } 19 20 public String toString() { 21 return elementGroup("application-context", new String [] { "paths", "beans" }); 22 } 23 24 public void setPaths(String [] paths) { 25 SpringApplicationContextPathConfigBuilder[] pcb = new SpringApplicationContextPathConfigBuilder[paths.length]; 26 for (int i = 0; i < paths.length; i++) { 27 String path = paths[i]; 28 pcb[i] = new SpringApplicationContextPathConfigBuilderImpl(path); 29 } 30 setPaths(pcb); 31 } 32 33 public void setPaths(SpringApplicationContextPathConfigBuilder[] paths) { 34 setProperty("paths", selfTaggingArray(paths)); 35 } 36 37 public SpringBeanConfigBuilder addBean(String beanName) { 38 if (!isSet("beans")) { 39 setProperty("beans", selfTaggingArray(new SpringBeanConfigBuilder[0])); 40 } 41 SpringBeanConfigBuilder springBean = new SpringBeanConfigBuilderImpl(beanName); 42 SpringBeanConfigBuilder[] existingBeans = (SpringBeanConfigBuilder[]) ((SelfTaggingArray)getRawProperty("beans")).values(); 43 SpringBeanConfigBuilder[] newBeans = new SpringBeanConfigBuilder[existingBeans.length + 1]; 44 System.arraycopy(existingBeans, 0, newBeans, 0, existingBeans.length); 45 newBeans[existingBeans.length] = springBean; 46 setProperty("beans", selfTaggingArray(newBeans)); 47 return springBean; 48 } 49 50 51 53 } 54 | Popular Tags |