KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > messenger > ServerPort


1 /**
2  * $RCSfile: ServerPort.java,v $
3  * $Revision: 1.4 $
4  * $Date: 2005/05/23 18:25:24 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.messenger;
13
14 import java.util.Iterator JavaDoc;
15 import java.util.ArrayList JavaDoc;
16
17 /**
18  * Represents a port on which the server will listen for connections.
19  * Used to aggregate information that the rest of the system needs
20  * regarding the port while hiding implementation details.
21  *
22  * @author Iain Shigeoka
23  */

24 public class ServerPort {
25
26     private int port;
27     private String JavaDoc interfaceName;
28     private ArrayList JavaDoc names;
29     private String JavaDoc address;
30     private boolean secure;
31     private String JavaDoc algorithm;
32     private Type type;
33
34     public ServerPort(int port, String JavaDoc interfaceName, String JavaDoc name, String JavaDoc address,
35             boolean isSecure, String JavaDoc algorithm, Type type)
36     {
37         this.port = port;
38         this.interfaceName = interfaceName;
39         this.names = new ArrayList JavaDoc(1);
40         this.names.add(name);
41         this.address = address;
42         this.secure = isSecure;
43         this.algorithm = algorithm;
44         this.type = type;
45     }
46
47     /**
48      * Returns the port number that is being used.
49      *
50      * @return the port number this server port is listening on.
51      */

52     public int getPort() {
53         return port;
54     }
55
56     public String JavaDoc getInterfaceName() {
57         return interfaceName;
58     }
59
60     /**
61      * Returns the logical domains for this server port. As multiple
62      * domains may point to the same server, this helps to define what
63      * the server considers "local".
64      *
65      * @return The server domain name(s) as Strings
66      */

67     public Iterator JavaDoc getDomainNames() {
68         return names.iterator();
69     }
70
71     /**
72      * Returns the dot separated IP address for the server.
73      *
74      * @return The dot separated IP address for the server
75      */

76     public String JavaDoc getIPAddress() {
77         return address;
78     }
79
80     /**
81      * Determines if the connection is secure.
82      *
83      * @return True if the connection is secure
84      */

85     public boolean isSecure() {
86         return secure;
87     }
88
89     /**
90      * Returns the basic protocol/algorithm being used to secure
91      * the port connections. An example would be "SSL" or "TLS".
92      *
93      * @return The protocol used or null if this is not a secure server port
94      */

95     public String JavaDoc getSecurityType() {
96         return algorithm;
97     }
98
99     /**
100      * Returns true if other servers can connect to this port for s2s communication.
101      *
102      * @return true if other servers can connect to this port for s2s communication.
103      */

104     public boolean isServerPort() {
105         return type == Type.server;
106     }
107
108     /**
109      * Returns true if clients can connect to this port.
110      *
111      * @return true if clients can connect to this port.
112      */

113     public boolean isClientPort() {
114         return type == Type.client;
115     }
116
117     /**
118      * Returns true if external components can connect to this port.
119      *
120      * @return true if external components can connect to this port.
121      */

122     public boolean isComponentPort() {
123         return type == Type.component;
124     }
125
126     public static enum Type {
127         client,
128
129         server,
130
131         component;
132     }
133 }
134
Popular Tags