001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023:
024: package org.enhydra.kelp.common.deployer;
025:
026: // ToolBox imports
027: import org.enhydra.tool.ToolBoxInfo;
028:
029: // Kelp imports
030: import org.enhydra.kelp.common.Constants;
031: import org.enhydra.kelp.common.PathUtil;
032: import org.enhydra.kelp.common.node.OtterProject;
033:
034: // Standard imports
035: import java.io.File;
036: import java.io.FileWriter;
037: import java.io.PrintWriter;
038:
039: public class StartServerGenerator {
040: private OtterProject project = null;
041: private File directory;
042: private File file = null;
043:
044: /**
045: * Constructor declaration
046: *
047: *
048: * @param p
049: */
050: public StartServerGenerator(OtterProject p) {
051: project = p;
052: }
053:
054: /**
055: * Method declaration
056: *
057: *
058: * @return
059: */
060: public File getFile() {
061: String path = project.getSourcePathArray()[0];
062: File dir = new File(path);
063: file = new File(dir, Constants.FILE_START_SERVER);
064: return file;
065: }
066:
067: /**
068: * Write a StartServer.java file for launching and stopping the server
069: * with a simple graphical interface. This is useful in environments such
070: * as the JDeveloper where you cannot run an arbitrary class from a project.
071: *
072: * @throws IOException
073: */
074: public void create() throws java.io.IOException {
075: if ((!getFile().exists()) || project.isDeployOverwrite()) {
076: PrintWriter out = new PrintWriter(new FileWriter(getFile()));
077:
078: // strings not to be translated
079: out.println(' ');
080: out.println("// ");
081: out
082: .println("// You can run this class to start the Enhydra ");
083: out.println("// application server from your IDE.");
084: out.println("// ");
085: out
086: .println("// Note: The <enhydra_root>/tool/lib/toolbox.jar ");
087: out
088: .println("// must be in your class path to compile or run ");
089: out.println("// this class.");
090: out.println("// ");
091: out.println(' ');
092: out
093: .println("public class StartServer extends org.enhydra.tool.boot.StartServer {"); //nores
094: out.println(' ');
095: out.println(" public static void main(String[] args) {"); // nores
096: out
097: .println(" org.enhydra.tool.boot.StartServer.main(args);");
098: out.println(" }");
099: out.println(' ');
100: out.println('}');
101: out.println(' ');
102: out.flush();
103: out.close();
104: }
105: }
106:
107: }
|