KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > client > ServerConnectionIdentifier


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.deployment.client;
25
26 import com.sun.enterprise.admin.jmx.remote.DefaultConfiguration;
27
28 /**
29  * This class defines all necessary information to
30  * connect to a particular application server deployment
31  * backend.
32  *
33  * @author Jerome Dochez
34  */

35 public class ServerConnectionIdentifier {
36     
37         /**
38      * Holds value of property hostName.
39      */

40     private String JavaDoc hostName;
41     
42     /**
43      * Holds value of property hostPort.
44      */

45     private int hostPort;
46     
47     /**
48      * Holds value of property userName.
49      */

50     private String JavaDoc userName;
51     
52     /**
53      * Holds value of property password.
54      */

55     private String JavaDoc password;
56     
57     /**
58      * Holds value of property protocol.
59      */

60     private String JavaDoc protocol;
61
62     private boolean secure = false;
63
64     private ServerConnectionEnvironment env;
65     
66     /** Creates a new instance of ServerConnectionIdentifier */
67     public ServerConnectionIdentifier() {
68     }
69     
70     /**
71      * Getter for property hostName.
72      * @return Value of property hostName.
73      */

74     public String JavaDoc getHostName() {
75         return this.hostName;
76     }
77     
78     /**
79      * Setter for property hostName.
80      * @param hostName New value of property hostName.
81      */

82     public void setHostName(String JavaDoc hostName) {
83         this.hostName = hostName;
84     }
85     
86     /**
87      * Getter for property hostPort.
88      * @return Value of property hostPort.
89      */

90     public int getHostPort() {
91         return this.hostPort;
92     }
93     
94     /**
95      * Setter for property hostPort.
96      * @param hostPort New value of property hostPort.
97      */

98     public void setHostPort(int hostPort) {
99         this.hostPort = hostPort;
100     }
101     
102     /**
103      * Getter for property userName.
104      * @return Value of property userName.
105      */

106     public String JavaDoc getUserName() {
107         return this.userName;
108     }
109     
110     /**
111      * Setter for property userName.
112      * @param userName New value of property userName.
113      */

114     public void setUserName(String JavaDoc userName) {
115         this.userName = userName;
116     }
117     
118     /**
119      * Getter for property password.
120      * @return Value of property password.
121      */

122     public String JavaDoc getPassword() {
123         return this.password;
124     }
125
126     /**
127      * Setter for property password.
128      * @param password New value of property password.
129      */

130     public void setPassword(String JavaDoc password) {
131         this.password = password;
132     }
133     
134     public void setSecure(boolean secure) {
135         this.secure = secure;
136     }
137
138     public boolean isSecure() {
139         return this.secure;
140     }
141
142     public ServerConnectionEnvironment getConnectionEnvironment() {
143         if (env == null) {
144             env = new ServerConnectionEnvironment();
145         }
146         return env;
147     }
148
149     public void setConnectionEnvironment(ServerConnectionEnvironment env) {
150         this.env = env;
151     }
152     
153     /**
154      * Getter for property protocol.
155      * the protocol can only be two values:
156      * either DefaultConfiguration.S1_HTTPS_PROTOCOL, if secure
157      * or DefaultConfiguration.S1_HTTP_PROTOCOL, if not secure
158      * @return Value of property protocol.
159      */

160     public String JavaDoc getProtocol() {
161         if (isSecure()) {
162             return DefaultConfiguration.S1_HTTPS_PROTOCOL;
163         } else {
164             return DefaultConfiguration.S1_HTTP_PROTOCOL;
165         }
166     }
167     
168     /**
169     * @return true if I am the equals to the other object
170     */

171     public boolean equals(Object JavaDoc other) {
172         if (other instanceof ServerConnectionIdentifier) {
173             ServerConnectionIdentifier dci = (ServerConnectionIdentifier) other;
174             if (hostName==null) {
175                 return false;
176             } else {
177                 if (!hostName.equals(dci.hostName))
178                     return false;
179             }
180             if (hostPort!=dci.hostPort) {
181                 return false;
182             }
183             if (!getConnectionEnvironment().equals(dci.getConnectionEnvironment())) {
184                 return false;
185             }
186         if (protocol==null) {
187         return dci.protocol==null;
188             } else {
189         return protocol.equals(dci.protocol);
190             }
191         } else {
192             return false;
193         }
194     }
195     
196     public String JavaDoc toString() {
197         return getUserName()+"("+ getPassword()+")@(" + getHostName()
198             + "):(" + getHostPort()+")" + ":" + getProtocol();
199     }
200 }
201
Popular Tags