KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > config > schema > test > SpringApplicationContextConfigBuilderImpl


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc[] { "paths", "beans" });
14   }
15
16   public static SpringApplicationContextConfigBuilder newMinimalInstance() {
17     return new SpringApplicationContextConfigBuilderImpl();
18   }
19
20   public String JavaDoc toString() {
21     return elementGroup("application-context", new String JavaDoc[] { "paths", "beans" });
22   }
23
24   public void setPaths(String JavaDoc[] paths) {
25     SpringApplicationContextPathConfigBuilder[] pcb = new SpringApplicationContextPathConfigBuilder[paths.length];
26     for (int i = 0; i < paths.length; i++) {
27       String JavaDoc 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 JavaDoc 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   // beans
52

53 }
54
Popular Tags