View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2012 Sabre Holdings.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  
20  package org.eclipse.jetty.ant.types;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * Specifies a jetty configuration <code>&lt;connectors/&gt;</code> element for Ant build file.
27   */
28  public class Connectors
29  {
30      private List<Connector> connectors = new ArrayList<Connector>();
31      private List<Connector> defaultConnectors = new ArrayList<Connector>();
32  
33      /**
34       * Default constructor.
35       */
36      public Connectors() {
37          this(8080, 30000);
38      }
39  
40      /**
41       * Constructor.
42       *
43       * @param port The port that the default connector will listen on
44       * @param maxIdleTime The maximum idle time for the default connector
45       */
46      public Connectors(int port, int maxIdleTime)
47      {
48          defaultConnectors.add(new Connector(port, maxIdleTime));
49      }
50  
51      /**
52       * Adds a connector to the list of connectors to deploy.
53       *
54       * @param connector A connector to add to the list
55       */
56      public void add(Connector connector)
57      {
58          connectors.add(connector);
59      }
60  
61      /**
62       * Returns the list of known connectors to deploy.
63       *
64       * @return The list of known connectors
65       */
66      public List<Connector> getConnectors()
67      {
68          return connectors;
69      }
70  
71      /**
72       * Gets the default list of connectors to deploy when no connectors
73       * were explicitly added to the list.
74       *
75       * @return The list of default connectors
76       */
77      public List<Connector> getDefaultConnectors()
78      {
79          return defaultConnectors;
80      }
81  
82  }