KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > j2ee > DeploymentManagerProperties


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.websphere6.j2ee;
20
21 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
22 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceCreationException;
23 import org.netbeans.modules.j2ee.websphere6.WSURIManager;
24 import org.netbeans.modules.j2ee.websphere6.WSDeploymentManager;
25 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
26
27 /**
28  *
29  * @author dlm198383
30  */

31 public class DeploymentManagerProperties {
32
33     /**
34      * Username property, its value is used by the deployment manager.
35      */

36     public static final String JavaDoc USERNAME_ATTR = "username"; //NOI18N
37

38     /**
39      * Password property, its value is used by the deployment manager.
40      */

41     public static final String JavaDoc PASSWORD_ATTR = "password"; //NOI18N
42

43     
44     /**
45      * Display name property, its value is used by IDE to represent server instance.
46      */

47     public static final String JavaDoc DISPLAY_NAME_ATTR = "displayName"; //NOI18N
48

49     /**
50      * Location of the app server instance property, its value is used by IDE to represent server instance.
51      */

52     public static final String JavaDoc LOCATION_ATTR = "LOCATION"; //NOI1
53

54     /**
55      * Port property, its value is used by the deployment manager.
56      */

57     public static final String JavaDoc PORT_ATTR = "port";
58     
59     
60     private InstanceProperties instanceProperties;
61     private WSDeploymentManager WSDM;
62     /** Creates a new instance of DeploymentManagerProperties */
63     public DeploymentManagerProperties(DeploymentManager dm) {
64         
65         WSDM = (WSDeploymentManager)dm;
66         
67         instanceProperties = WSURIManager.getInstanceProperties(WSDM.getHost(),WSDM.getPort());
68         
69         if (instanceProperties==null){
70             try {
71                 
72                 instanceProperties = WSURIManager.createInstanceProperties(
73                         WSDM.getHost(),
74                         WSDM.getPort(),
75                         WSDM.getUsername(),
76                         WSDM.getPassword(),
77                         WSDM.getHost()+":"+WSDM.getPort());
78             } catch (InstanceCreationException e){
79                 
80             }
81         }
82     }
83     
84     /**
85      * Getter for property location. can be null if the dm is remote
86      * @return Value of property location.
87      */

88     
89     
90     /**
91      * Getter for property password. can be null if the DM is a disconnected DM
92      * @return Value of property password.
93      */

94     public java.lang.String JavaDoc getPassword() {
95         if (instanceProperties==null)
96             return null;
97         return instanceProperties.getProperty(InstanceProperties.PASSWORD_ATTR) ;
98     }
99     
100     /**
101      * Setter for property password.
102      * @param password New value of property password.
103      */

104     public void setPassword(java.lang.String JavaDoc password) {
105         instanceProperties.setProperty(InstanceProperties.PASSWORD_ATTR, password);
106         
107     }
108     
109     
110     /**
111      * Getter for property UserName. can be null for a disconnected DM.
112      * @return Value of property UserName.
113      */

114     public java.lang.String JavaDoc getUserName() {
115         if (instanceProperties==null)
116             return null;
117         return instanceProperties.getProperty(InstanceProperties.USERNAME_ATTR) ;
118     }
119     
120     /**
121      * Setter for property UserName.
122      * @param UserName New value of property UserName.
123      */

124     public void setUserName(java.lang.String JavaDoc UserName) {
125         instanceProperties.setProperty(InstanceProperties.USERNAME_ATTR, UserName);
126         
127     }
128     /**
129      * Ask the server instance to reset cached deployment manager, J2EE
130      * management objects and refresh it UI elements.
131      */

132     public void refreshServerInstance(){
133         instanceProperties.refreshServerInstance();
134     }
135     
136     public String JavaDoc getPort() {
137         if (instanceProperties==null)
138             return "8880";
139         return instanceProperties.getProperty(PORT_ATTR) ;
140     }
141     
142     public void setPort(String JavaDoc port) {
143         if(port.trim().matches("[0-9]+"))
144         {
145         instanceProperties.setProperty(PORT_ATTR, port);
146         WSDM.setPort(port);
147         }
148     }
149     
150     public String JavaDoc getDisplayName() {
151         if (instanceProperties == null) {
152             return null;
153         }
154         return instanceProperties.getProperty(InstanceProperties.DISPLAY_NAME_ATTR);
155     }
156     
157     public String JavaDoc getUrl() {
158         if (instanceProperties == null) {
159             return null;
160         }
161         return instanceProperties.getProperty(InstanceProperties.URL_ATTR);
162     }
163     
164     public InstanceProperties getInstanceProperties() {
165         return instanceProperties;
166     }
167     
168     public String JavaDoc getServerRoot() {
169         return WSDM.getServerRoot();
170     }
171     
172     public void setServerRoot(String JavaDoc serverRoot) {
173         WSDM.setServerRoot(serverRoot);
174     }
175     public String JavaDoc getDomainRoot() {
176         return WSDM.getDomainRoot();
177     }
178     public void setDomainRoot(String JavaDoc domainRoot) {
179         WSDM.setDomainRoot(domainRoot);
180     }
181     public void setHost(String JavaDoc host) {
182         WSDM.setHost(host);
183     }
184     public void setServerName(String JavaDoc name) {
185         WSDM.setServerName(name);
186     }
187     public void setConfigXmlPath(String JavaDoc path) {
188         WSDM.setConfigXmlPath(path);
189     }
190     public void setIsLocal(String JavaDoc isLocal) {
191         WSDM.setIsLocal(isLocal);
192     }
193     public String JavaDoc getIsLocal() {
194         return WSDM.getIsLocal();
195     }
196     
197     
198 }
199
Popular Tags