1 20 package org.apache.cactus.integration.ant; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 25 import org.apache.cactus.integration.ant.container.Container; 26 import org.apache.cactus.integration.ant.container.ContainerFactory; 27 import org.apache.cactus.integration.ant.container.ContainerWrapper; 28 import org.apache.cactus.integration.ant.container.GenericContainer; 29 import org.apache.tools.ant.BuildException; 30 import org.apache.tools.ant.DynamicConfigurator; 31 import org.apache.tools.ant.types.DataType; 32 33 38 public class ContainerSet extends DataType implements DynamicConfigurator 39 { 40 41 43 46 private ContainerFactory factory = new ContainerFactory(); 47 48 51 private List containers = new ArrayList (); 52 53 56 private long timeout = -1; 57 58 61 private int proxyPort = -1; 62 63 65 68 public final Object createDynamicElement(String theName) 69 throws BuildException 70 { 71 if (isReference()) 72 { 73 throw noChildrenAllowed(); 74 } 75 Container container = this.factory.createContainer(theName); 76 this.containers.add(container); 77 return container; 78 } 79 80 83 public final void setDynamicAttribute(String theName, String theValue) 84 throws BuildException 85 { 86 if (isReference()) 87 { 88 throw tooManyAttributes(); 89 } 90 throw new BuildException("Attribute [" + theName 91 + "] not supported"); 92 } 93 94 96 101 public final void addGeneric(GenericContainer theContainer) 102 { 103 this.containers.add(theContainer); 104 } 105 106 112 public final Container[] getContainers() 113 { 114 Container[] containers = (Container[]) 115 this.containers.toArray(new Container[this.containers.size()]); 116 if (this.proxyPort > 0) 117 { 118 for (int i = 0; i < containers.length; i++) 119 { 120 containers[i] = new ContainerWrapper(containers[i]) 121 { 122 public int getPort() 123 { 124 return proxyPort; 125 } 126 }; 127 } 128 } 129 return containers; 130 } 131 132 138 public final long getTimeout() 139 { 140 return this.timeout; 141 } 142 143 149 public final void setTimeout(long theTimeout) 150 { 151 this.timeout = theTimeout; 152 } 153 154 159 public final int getProxyPort() 160 { 161 return this.proxyPort; 162 } 163 164 171 public final void setProxyPort(int theProxyPort) 172 { 173 this.proxyPort = theProxyPort; 174 } 175 176 } 177 | Popular Tags |