View Javadoc

1   /*
2    * Copyright (c) 1998-2002 The Jgroup Team.
3    *
4    * This program is free software; you can redistribute it and/or modify
5    * it under the terms of the GNU Lesser General Public License version 2 as
6    * published by the Free Software Foundation.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public License
14   * along with this program; if not, write to the Free Software
15   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16   *
17   */
18  
19  package jgroup.relacs.config;
20  
21  import jgroup.core.ConfigurationException;
22  
23  
24  /**
25   *  Class for holding bootstrap registry information.
26   *
27   *  @author Hein Meling
28   *  @author Alberto Montresor
29   *  @since Jgroup 1.1
30   */
31  public class BootstrapRegistryConfig 
32    implements ConfigurationObject
33  {
34  
35    ////////////////////////////////////////////////////////////////////////////////////////////
36    // Tags
37    ////////////////////////////////////////////////////////////////////////////////////////////
38    
39    private static final String PORT_ATTRIB = "port";
40  
41  
42    ////////////////////////////////////////////////////////////////////////////////////////////
43    // Default values
44    ////////////////////////////////////////////////////////////////////////////////////////////
45  
46    private static final int BOOTSTRAP_REGISTRY_PORT = 5671;
47  
48  
49    ////////////////////////////////////////////////////////////////////////////////////////////
50    // Fields
51    ////////////////////////////////////////////////////////////////////////////////////////////
52  
53    /** Registry port */
54    private int port;
55  
56  
57    ////////////////////////////////////////////////////////////////////////////////////////////
58    // Constructors
59    ////////////////////////////////////////////////////////////////////////////////////////////
60  
61    /**
62     *  Builds a new BootstrapRegistryConfig object, using default values.
63     */
64    public BootstrapRegistryConfig() 
65    {
66      this(BOOTSTRAP_REGISTRY_PORT);
67    }
68  
69  
70    /**
71     *  Builds a new BootstrapRegistryConfig object, using the specified port.
72     *  
73     *  @param port 
74     *    bootstrap registry port
75     */
76    public BootstrapRegistryConfig(int port)
77    {
78      this.port = port;
79    }
80  
81    
82    ////////////////////////////////////////////////////////////////////////////////////////////
83    // Methods from ConfigurationObject
84    ////////////////////////////////////////////////////////////////////////////////////////////
85  
86    /**
87     *  Parses the specified element.
88     */
89    public void parse(org.w3c.dom.Element elm)
90      throws ConfigurationException
91    {
92      port = ConfigParser.getIntAttrib(elm, PORT_ATTRIB, false);
93    }
94  
95  
96    ////////////////////////////////////////////////////////////////////////////////////////////
97    // Getter methods
98    ////////////////////////////////////////////////////////////////////////////////////////////
99  
100   /**
101    *  Returns the port number for the bootstrap registry service.
102    */
103   public int getPort()
104   {
105     return port;
106   }
107 
108 
109   ////////////////////////////////////////////////////////////////////////////////////////////
110   // Override methods in Object
111   ////////////////////////////////////////////////////////////////////////////////////////////
112 
113   /**
114    *  Returns a string representation of this object
115    */
116   public String toString()
117   {
118     return "[BootstrapRegistryConfig: port = " + port +"]";
119   }
120 
121 } // END BootstrapRegistryConfig