KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > codegen > ServiceUtil


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 package org.enhydra.kelp.common.codegen;
24
25 // ToolBox imports
26
import org.enhydra.tool.codegen.ProjectGenerator;
27 import org.enhydra.tool.codegen.GeneratorException;
28 import org.enhydra.tool.codegen.internal.ServiceOptionSet;
29 import org.enhydra.tool.codegen.internal.ServiceGenerator;
30
31 // Kelp imports
32
import org.enhydra.kelp.KelpInfo;
33 import org.enhydra.kelp.common.node.OtterNode;
34 import org.enhydra.kelp.common.node.OtterProject;
35 import org.enhydra.kelp.common.node.OtterFolderNode;
36 import org.enhydra.kelp.common.node.OtterJavaFileNode;
37 import org.enhydra.kelp.common.node.OtterTextFileNode;
38 import org.enhydra.kelp.common.node.OtterNodeFactory;
39
40 // Standard imports
41
import java.awt.Component JavaDoc;
42 import java.io.File JavaDoc;
43 import java.io.FilenameFilter JavaDoc;
44 import java.util.Vector JavaDoc;
45 import java.util.ResourceBundle JavaDoc;
46
47 //
48
public class ServiceUtil extends ProjectGenUtil {
49
50     // string not to be resourced
51
private final static String JavaDoc DEFAULT_COMMAND_NAME = "service"; // nores
52

53     //
54
public ServiceUtil() throws CodeGenException {
55         super(new ServiceGenerator());
56     }
57
58     public ServiceUtil(OtterProject project) throws CodeGenException {
59         super(project, new ServiceGenerator());
60     }
61
62     public ServiceUtil(OtterProject project, ServiceGenerator gen) throws CodeGenException {
63         super(project, gen);
64     }
65
66
67     public static ProjectGenerator createGenerator() {
68         return new ServiceGenerator();
69     }
70
71     public static String JavaDoc getCommandName() {
72         String JavaDoc commandName = DEFAULT_COMMAND_NAME;
73
74         if (KelpInfo.isClassPathComplete()) {
75             commandName = ServiceGenerator.COMMAND_NAME;
76         }
77         return commandName;
78     }
79
80     /**
81      * Method declaration
82      *
83      * @return
84      */

85     public static String JavaDoc getDisplayName() {
86         String JavaDoc displayName = res.getString("Web_Application");
87
88         if (KelpInfo.isClassPathComplete()) {
89             displayName = ServiceGenerator.displayName;
90         }
91         return displayName;
92     }
93
94     // override ProjectGenUtil
95
protected void initOptions() throws GeneratorException {
96         String JavaDoc serviceName = new String JavaDoc();
97         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
98         super.initOptions();
99
100         serviceName = getGenerator().getOptionSet().lookup(ServiceOptionSet.PROJECT).getValue();
101         buf.append(Character.toUpperCase(serviceName.charAt(0)));
102         if (serviceName.length() > 1) {
103           buf.append(serviceName.substring(1));
104         }
105         serviceName = buf.toString();
106         getGenerator().getOptionSet().lookup(ServiceOptionSet.SERVICE).setValue(serviceName);
107         getGenerator().getOptionSet().lookup(ServiceOptionSet.MBEAN).setValue(true);
108     }
109
110 }
111
Popular Tags