001: /*
002: DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.gravy.model.deployment;
043:
044: import org.netbeans.jemmy.JemmyException;
045: import org.netbeans.modules.visualweb.gravy.Util;
046: import org.netbeans.modules.visualweb.gravy.TestUtils;
047: import org.netbeans.modules.visualweb.gravy.model.ExternalProcess;
048: import org.netbeans.modules.visualweb.gravy.dataconnectivity.ServerNavigatorOperator;
049:
050: /**
051: * Common class for all application servers.
052: */
053:
054: public class ApplicationServer implements DeploymentTarget,
055: ExternalProcess {
056:
057: public final static String SERVER_START = "Start";
058: public final static String SERVER_START_DEBUG = "Start in Debug Mode";
059: public final static String SERVER_RESTART = "Restart";
060: public final static String SERVER_STOP = "Stop";
061: public final static String SERVER_REMOVE = "Remove";
062: public final static String SERVER_CUSTOMIZE = "Customize";
063: public final static String SERVER_VIEW_CONSOLE = "View Admin Console";
064: public final static String PROPERTIES = "Properties";
065: public final static String REFRESH = "Refresh";
066: public final static String APPLICATION_UNDEPLOY = "Undeploy";
067:
068: public String SERVER_VIEW_LOG;
069: public String APPLICATION_DISABLE;
070: public String APPLICATION_ENABLE;
071:
072: /**
073: * Prefix before application node in the list of web applications.
074: */
075: public String app_pref;
076:
077: /**
078: * Path to web applications.
079: */
080: public String web_applications_path;
081:
082: /**
083: * Path to JDBC resources.
084: */
085: public String jdbc_resources_path;
086:
087: /**
088: * Array of items of Application Server's popup menu.
089: */
090: public String[][] server_popup;
091:
092: /**
093: * Array of items of application's popup menu.
094: */
095: public String[] application_popup;
096:
097: /**
098: * Array of items of resource's popup menu.
099: */
100: public String[] resource_popup;
101:
102: /**
103: * Prefix for request to load application in browser.
104: */
105: public String requestPrefix;
106:
107: /**
108: * Descriptor of deployment target.
109: */
110: private DeploymentTargetDescriptor DTDescriptor;
111:
112: /**
113: * Get descriptor of Application Server.
114: * @return descriptor of Application Server.
115: */
116: public DeploymentTargetDescriptor getDescriptor() {
117: return DTDescriptor;
118: }
119:
120: /**
121: * Set descriptor of Application Server.
122: * @param DTDescriptor New descriptor of Application Server.
123: */
124: protected void setDescriptor(DeploymentTargetDescriptor DTDescriptor) {
125: this .DTDescriptor = DTDescriptor;
126: }
127:
128: /**
129: * Deploy project to this server.
130: * @param project Project to deploy.
131: */
132: public void deploy(Object project) {
133: try {
134: Util.getMainWindow().btDeploy().push();
135: } catch (Exception e) {
136: throw new JemmyException(
137: "Application can't be deployed to " + getName()
138: + "!", e);
139: }
140: TestUtils.wait(20000);
141: }
142:
143: /**
144: * Start Application Server.
145: */
146: public void start() {
147: try {
148: ServerNavigatorOperator.startServer(getName());
149: } catch (Exception e) {
150: throw new JemmyException(getName() + " can't be started!",
151: e);
152: }
153: }
154:
155: /**
156: * Stop Application Server.
157: */
158: public void stop() {
159: try {
160: ServerNavigatorOperator.stopServer(getName());
161: } catch (Exception e) {
162: throw new JemmyException(getName() + " can't be stopped!",
163: e);
164: }
165: }
166:
167: /**
168: * Instance of Application Server is compared with deployment target, passed with parameter.
169: * @param dt Object for comparison.
170: * @return true if Object equals to ApplicationServer.
171: */
172: public boolean equals(Object dt) {
173: if ((dt instanceof DeploymentTarget)
174: && ((DeploymentTarget) dt).getName().equals(
175: this .getName())) {
176: return true;
177: }
178: return false;
179: }
180:
181: /**
182: * Get name of Application Server.
183: * @return name.
184: */
185: public String getName() {
186: String serverType = DTDescriptor
187: .getProperty(DTDescriptor.SERVER_TYPE_KEY);
188: return DTDescriptor.getProperty(DTDescriptor.NAME_KEY
189: + serverType);
190: }
191: }
|