KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > deploy > AdminInstance


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 /*
25  * AdminInstance.java
26  *
27  * Created on November 19, 2001, 12:15 PM
28  */

29
30 package com.sun.enterprise.tools.common.deploy;
31
32 import java.beans.*;
33 import java.util.*;
34 import java.util.List JavaDoc;
35 import javax.swing.JOptionPane JavaDoc;
36 import java.net.InetAddress JavaDoc;
37
38 import com.sun.enterprise.tools.common.LoginFailureException;
39
40 import com.sun.enterprise.tools.common.ui.UIMessenger;
41
42 /**
43  *
44  * @author nityad
45  * @version
46  */

47 public class AdminInstance extends Object JavaDoc implements java.io.Serializable JavaDoc {
48
49     
50     private String JavaDoc host_name;
51     private static String JavaDoc pw_editor;
52     transient private PropertyChangeSupport propertySupport;
53
54     private String JavaDoc name;
55     
56     private int port_no;
57     
58     private String JavaDoc path;
59     /** Holds value of property userName. */
60     private String JavaDoc userName;
61     private String JavaDoc password;
62     
63      
64     public AdminInstance(String JavaDoc host, int port, String JavaDoc path) {
65         this(host,port,path,null,null);
66     }
67     
68     public AdminInstance(String JavaDoc host, int port, String JavaDoc path, String JavaDoc userName, String JavaDoc password) {
69         propertySupport = new PropertyChangeSupport ( this );
70         this.host_name = host;
71         this.port_no = port;
72         this.name = host_name + ":" + port_no;//NOI18N
73
this.path = path;
74         this.userName = userName;
75         this.password = password;
76     }
77    
78        /** Getter for property userName.
79      * @return Value of property userName.
80  */

81     public String JavaDoc getUserName() {
82         return userName;
83     }
84     
85     /** Setter for property userName.
86      * @param userName New value of property userName.
87  */

88     public void setUserName(String JavaDoc value) {
89         String JavaDoc oldValue = host_name;
90         userName = value;
91         initPropertyChangeSupport();
92         propertySupport.firePropertyChange ("userName", oldValue, userName);//NOI18N
93
}
94         /** invisible Getter for property password.
95      * @return ****
96  */

97     public String JavaDoc getPrivatePassword() {
98         String JavaDoc pw = getPassword();
99         String JavaDoc passw = "";//NOI18N
100
for(int i=0; i<pw.length(); i++)
101             passw = passw + "*";//NOI18N
102
return passw;
103     }
104     /** Getter for property password.
105      * @return Value of property password.
106  */

107     public String JavaDoc getPassword() {
108         pw_editor = password;
109         return password;
110     }
111     
112     /** Setter for property password.
113      * @param password New value of property password.
114  */

115     public void setPassword(String JavaDoc value) {
116         String JavaDoc oldValue = password;
117         password = value;
118         initPropertyChangeSupport();
119         propertySupport.firePropertyChange ("password", oldValue, password);//NOI18N
120
}
121    public String JavaDoc getHost() {
122         return this.host_name;
123     }
124
125     public void setHost(String JavaDoc value) {
126         String JavaDoc oldValue = host_name;
127         this.host_name = value;
128         initPropertyChangeSupport();
129         propertySupport.firePropertyChange ("host", oldValue, host_name);//NOI18N
130
}
131
132     private void initPropertyChangeSupport(){
133          if(propertySupport==null)
134          propertySupport = new PropertyChangeSupport ( this );
135
136     }
137     public void addPropertyChangeListener (PropertyChangeListener listener) {
138         initPropertyChangeSupport();
139            
140         propertySupport.addPropertyChangeListener (listener);
141     }
142
143     public void removePropertyChangeListener (PropertyChangeListener listener) {
144         initPropertyChangeSupport();
145         propertySupport.removePropertyChangeListener (listener);
146     }
147
148  
149     public String JavaDoc getName() {
150         return this.name;
151     }
152     
153     public void setName(String JavaDoc value) {
154         String JavaDoc oldValue = name;
155         this.name = value;
156         initPropertyChangeSupport();
157         propertySupport.firePropertyChange ("name", oldValue, name);//NOI18N
158
}
159     
160     public int getPort() {
161         return this.port_no;
162     }
163     
164     public void setPort(int value) {
165         int oldValue = port_no;
166         this.port_no = value;
167         initPropertyChangeSupport();
168         propertySupport.firePropertyChange ("port", oldValue, port_no);//NOI18N
169
}
170     
171     public String JavaDoc getPath() {
172         return this.path;
173     }
174     
175     public void setPath(String JavaDoc value) {
176         String JavaDoc oldValue = path;
177         this.path = value;
178         initPropertyChangeSupport();
179         propertySupport.firePropertyChange ("path", oldValue, path);//NOI18N
180
}
181     
182     public static boolean AdminServName(String JavaDoc host, int port, List JavaDoc admin){
183        boolean exists = false;
184        String JavaDoc value = host + ":" + port;//NOI18N
185
for(int i=0; i<admin.size(); i++){
186         IAdminInstanceBean instance = (IAdminInstanceBean) admin.get(i);
187         String JavaDoc inst = instance.getName();
188         if(inst.equals(value))
189            exists = true;
190        }//for
191
return exists;
192     }
193 }
194
Popular Tags