KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > deployer > StartServerGenerator


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Paul Mahar
21  *
22  */

23
24 package org.enhydra.kelp.common.deployer;
25
26 // ToolBox imports
27
import org.enhydra.tool.ToolBoxInfo;
28
29 // Kelp imports
30
import org.enhydra.kelp.common.Constants;
31 import org.enhydra.kelp.common.PathUtil;
32 import org.enhydra.kelp.common.node.OtterProject;
33
34 // Standard imports
35
import java.io.File JavaDoc;
36 import java.io.FileWriter JavaDoc;
37 import java.io.PrintWriter JavaDoc;
38
39 public class StartServerGenerator {
40     private OtterProject project = null;
41     private File JavaDoc directory;
42     private File JavaDoc file = null;
43
44     /**
45      * Constructor declaration
46      *
47      *
48      * @param p
49      */

50     public StartServerGenerator(OtterProject p) {
51         project = p;
52     }
53
54     /**
55      * Method declaration
56      *
57      *
58      * @return
59      */

60     public File JavaDoc getFile() {
61         String JavaDoc path = project.getSourcePathArray()[0];
62         File JavaDoc dir = new File JavaDoc(path);
63         file = new File JavaDoc(dir, Constants.FILE_START_SERVER);
64         return file;
65     }
66
67     /**
68      * Write a StartServer.java file for launching and stopping the server
69      * with a simple graphical interface. This is useful in environments such
70      * as the JDeveloper where you cannot run an arbitrary class from a project.
71      *
72      * @throws IOException
73      */

74     public void create() throws java.io.IOException JavaDoc {
75         if ((!getFile().exists()) || project.isDeployOverwrite()) {
76             PrintWriter JavaDoc out = new PrintWriter JavaDoc(new FileWriter JavaDoc(getFile()));
77
78             // strings not to be translated
79
out.println(' ');
80             out.println("// ");
81             out.println("// You can run this class to start the Enhydra ");
82             out.println("// application server from your IDE.");
83             out.println("// ");
84             out.println("// Note: The <enhydra_root>/tool/lib/toolbox.jar ");
85             out.println("// must be in your class path to compile or run ");
86             out.println("// this class.");
87             out.println("// ");
88             out.println(' ');
89             out.println("public class StartServer extends org.enhydra.tool.boot.StartServer {"); //nores
90
out.println(' ');
91             out.println(" public static void main(String[] args) {"); // nores
92
out.println(" org.enhydra.tool.boot.StartServer.main(args);");
93             out.println(" }");
94             out.println(' ');
95             out.println('}');
96             out.println(' ');
97             out.flush();
98             out.close();
99         }
100     }
101
102
103 }
104
Popular Tags