KickJava   Java API By Example, From Geeks To Geeks.

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


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;
20
21 import java.io.*;
22
23 import javax.enterprise.deploy.spi.*;
24 import javax.enterprise.deploy.spi.factories.*;
25 import javax.enterprise.deploy.spi.exceptions.*;
26
27 import org.openide.util.NbBundle;
28
29 import org.netbeans.modules.j2ee.websphere6.util.WSDebug;
30
31 /**
32  * The main entry point to the plugin. Keeps the required static data for the
33  * plugin and returns the DeploymentManagers required for deployment and
34  * configuration. Does not directly perform any interaction with the server.
35  *
36  * @author Kirill Sorokin
37  */

38 public class WSDeploymentFactory implements DeploymentFactory {
39     
40     // additional properties that are stored in the InstancePropeties object
41
public static final String JavaDoc SERVER_ROOT_ATTR = "serverRoot"; // NOI18N
42
public static final String JavaDoc DOMAIN_ROOT_ATTR = "domainRoot"; // NOI18N
43
public static final String JavaDoc IS_LOCAL_ATTR = "isLocal"; // NOI18N
44
public static final String JavaDoc HOST_ATTR = "host"; // NOI18N
45
public static final String JavaDoc PORT_ATTR = "port"; // NOI18N
46
public static final String JavaDoc DEBUGGER_PORT_ATTR = "debuggerPort"; // NOI18N
47
public static final String JavaDoc SERVER_NAME_ATTR = "serverName"; // NOI18N
48
public static final String JavaDoc CONFIG_XML_PATH = "configXmlPath"; // NOI18N
49
public static final String JavaDoc ADMIN_PORT_ATTR = "adminPort"; // NOI18N
50

51     public static final String JavaDoc USERNAME_ATTR = "username";
52     public static final String JavaDoc PASSWORD_ATTR = "password";
53     public static final String JavaDoc DEFAULT_HOST_PORT_ATTR="defaultHostPort";
54     
55     /**
56      * The singleton instance of the factory
57      */

58     private static WSDeploymentFactory instance;
59     
60     /**
61      * The singleton factory method
62      *
63      * @return the singleton instance of the factory
64      */

65     public static synchronized DeploymentFactory create() {
66         // if the instance is not initialized yet - create it
67
if (instance == null) {
68             instance = new WSDeploymentFactory();
69         }
70         
71         // return the instance
72
return instance;
73     }
74     
75     ////////////////////////////////////////////////////////////////////////////
76
// DeploymentFactory implementation
77
////////////////////////////////////////////////////////////////////////////
78
/**
79      * Returns a wrapper for the connected deployment manager
80      *
81      * @return a connected DeploymentManager implementation
82      */

83     public DeploymentManager getDeploymentManager(String JavaDoc uri, String JavaDoc username,
84             String JavaDoc password) throws DeploymentManagerCreationException {
85         if (WSDebug.isEnabled()) // debug output
86
WSDebug.notify("getDeploymentManager(" + uri + ", " + // NOI18N
87
username + ", " + password + ")"); // NOI18N
88

89         
90         // return a new deployment manager
91
return new WSDeploymentManager(uri, username, password);
92     }
93     
94     /**
95      * Returns a wrapper for the disconnecter deployment manager
96      *
97      * @return a disconnected DeploymentManager implementation
98      */

99     public DeploymentManager getDisconnectedDeploymentManager(String JavaDoc uri)
100             throws DeploymentManagerCreationException {
101         if (WSDebug.isEnabled()) // debug output
102
WSDebug.notify("getDisconnectedDeploymentManager(" + uri + // NOI18N
103
")"); // NOI18N
104

105         // return a new deployment manager
106
return new WSDeploymentManager(uri);
107     }
108     
109     /**
110      * Tells whether this deployment factory is capable to handle the server
111      * identified by the given URI
112      *
113      * @param uri the server URI
114      * @return can or cannot handle the URI
115      */

116     public boolean handlesURI(String JavaDoc uri) {
117         if (WSDebug.isEnabled()) // debug output
118
WSDebug.notify("handlesURI(" + uri + ")"); // NOI18N
119

120         //return uri == null ? false : uri.startsWith(
121
return uri == null ? false : (uri.indexOf(WSURIManager.WSURI)>-1); // NOI18N
122
}
123     
124     /**
125      * Returns the product version of the deployment factory
126      *
127      * @return the product version
128      */

129     public String JavaDoc getProductVersion() {
130         return NbBundle.getMessage(WSDeploymentFactory.class,
131                 "TXT_productVersion"); // NOI18N
132
}
133     
134     /**
135      * Returns the deployment factory dysplay name
136      *
137      * @return display name
138      */

139     public String JavaDoc getDisplayName() {
140         if (WSDebug.isEnabled()) // debug output
141
WSDebug.notify("getDisplayName()"); // NOI18N
142

143         return NbBundle.getMessage(WSDeploymentFactory.class,
144                 "TXT_displayName"); // NOI18N
145
}
146 }
Popular Tags