KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > ui > WS70URIManager


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
20 /*
21  * WS70URIManager.java
22  *
23  */

24
25 package org.netbeans.modules.j2ee.sun.ws7.ui;
26 import java.io.File JavaDoc;
27 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceCreationException;
28 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
29
30
31
32 /**
33  *
34  * @author Administrator
35  */

36 public class WS70URIManager {
37
38     public static final String JavaDoc WS70SERVERURI = "deployer:Sun:WebServer70::"; //NOI18N
39

40     /**
41      * Returns instance properties for the server instance.
42      *
43      * @param url the url connection string to get the instance deployment manager.
44      * @return the InstanceProperties object, null if instance does not exists.
45      */

46     
47     public static InstanceProperties getInstanceProperties(String JavaDoc serverLocation, String JavaDoc host, int port){
48         InstanceProperties instanceProperties =
49                 InstanceProperties.getInstanceProperties("["+serverLocation+"]"+WS70SERVERURI+host+":"+port);
50
51         return instanceProperties;
52     }
53     /**
54      * Create new instance and returns instance properties for the server instance.
55      *
56      * @param url the url connection string to get the instance deployment manager.
57      * @param username username which is used by the deployment manager.
58      * @param password password which is used by the deployment manager.
59      * @param displayName display name which is used by IDE to represent this
60      * server instance.
61      * @return the <code>InstanceProperties</code> object, <code>null</code> if
62      * instance does not exists.
63      * @exception InstanceCreationException when instance with same url already
64      * registered.
65      */

66     public static InstanceProperties createInstanceProperties(String JavaDoc serverLocation, String JavaDoc host, String JavaDoc port, String JavaDoc user, String JavaDoc password, String JavaDoc displayName) throws InstanceCreationException {
67         InstanceProperties instanceProperties = InstanceProperties.createInstanceProperties(
68                 "["+serverLocation+"]"+WS70SERVERURI+host+":"+port,
69                 user,
70                 password,displayName);
71         
72         return instanceProperties;
73     }
74     public static String JavaDoc getURIWithoutLocation(String JavaDoc uriwithlocation){
75         int index = uriwithlocation.lastIndexOf("]");
76         String JavaDoc retval = null;
77         if(index!=-1){
78             retval = uriwithlocation.substring(index+1);
79         }else{
80             retval = uriwithlocation;
81         }
82         return retval;
83     }
84     public static String JavaDoc getLocation(String JavaDoc url){
85         int index = url.lastIndexOf("]");
86         String JavaDoc retval = null;
87         if(index!=-1){
88             if(url.startsWith("[")){
89                 retval = url.substring(1, index);
90             }else{
91                 retval = url.substring(0, index);
92             }
93         }
94         return retval;
95     }
96     public static String JavaDoc getHostFromURI(String JavaDoc uri){
97         int index = uri.lastIndexOf("::");
98         String JavaDoc newUrl = null;
99         if(index!=-1){
100             newUrl = uri.substring(index+2);
101         }else{
102             newUrl = uri;
103         }
104         
105         String JavaDoc[] vals = newUrl.split(":");
106         return vals[0];
107         
108     }
109     public static String JavaDoc getPortFromURI(String JavaDoc uri){
110        int index = uri.lastIndexOf("::");
111         String JavaDoc newUrl = null;
112         if(index!=-1){
113             newUrl = uri.substring(index+2);
114         }else{
115             newUrl = uri;
116         }
117         
118         String JavaDoc[] vals = newUrl.split(":");
119         return vals[1];
120     }
121     
122 }
123
Popular Tags