2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

View Javadoc

1   /* 
2    * ========================================================================
3    * 
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   * 
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * 
19   * ========================================================================
20   */
21  package org.apache.cactus.integration.ant;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.codehaus.cargo.ant.CargoTask;
27  
28  /**
29   * Ant data type that represents a set of J2EE containers.
30   * 
31   * @version $Id: ContainerSet.java 238810 2004-02-29 10:05:26Z vmassol $
32   */
33  public class ContainerSet 
34  {
35  
36      // Instance Variables ------------------------------------------------------
37  
38      /**
39       * The list of nested container and containerset elements.
40       */
41      private List cargos = new ArrayList();
42  
43      /**
44       * The timeout in milliseconds. 
45       */
46      private long timeout = -1;
47  
48      /**
49       * The proxy port. 
50       */
51      private int proxyPort = -1;
52  
53      // Public Methods ----------------------------------------------------------
54  
55      /**
56       * Adds a nested generic container to the set of containers.
57       * 
58       * @param theElement The generic cargo element to add
59       */
60      public final void addCargo(CargoElement theElement)
61      {
62          this.cargos.add(theElement);
63      }
64      /**
65       * @return CargoTask - the created cargo task.
66       */
67      public CargoTask createCargo()
68      {
69          CargoTask task = new CargoTask();
70          cargos.add(task);
71          return task;
72      }
73  
74      /**
75       * Returns an iterator over the nested container elements, in the order
76       * they appear in the build file.
77       * 
78       * @return An iterator over the nested container elements
79       */
80      public final CargoElement[] getCargos()
81      {
82          CargoElement[] result = new CargoElement[cargos.size()];
83          for (int i = 0; i < cargos.size(); i++)
84          {
85              result[i] = (CargoElement) cargos.get(i);
86          }
87          return result;
88      }
89  
90      /**
91       * Returns the timeout after which connecting to a container will be
92       * given up, or <code>-1</code> if no timeout has been set.
93       * 
94       * @return The timeout in milliseconds
95       */
96      public final long getTimeout()
97      {
98          return this.timeout;
99      }
100 
101     /**
102      * Sets the timeout after which connecting to a container will be given
103      * up.
104      * 
105      * @param theTimeout The timeout in milliseconds
106      */
107     public final void setTimeout(long theTimeout)
108     {
109         this.timeout = theTimeout;
110     }
111 
112     /**
113      * Returns the proxy port, or <code>-1</code> if no proxy port has been set.
114      * 
115      * @return The proxy port
116      */
117     public final int getProxyPort()
118     {
119         return this.proxyPort;
120     }
121 
122     /**
123      * Sets the proxy port which will be used by the test caller instead 
124      * of the real container port. This can be used to insert protocol 
125      * tracers between the test caller and the container.
126      * 
127      * @param theProxyPort The proxy port to set
128      */
129     public final void setProxyPort(int theProxyPort)
130     {
131         this.proxyPort = theProxyPort;
132     }
133 
134 }