KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > corba > service > GenerationService


1 /**
2  * copyright 2002 2003 Laboratoire d'Informatique Paris 6 (LIP6)
3  *
4  * This file is part of ModFact.
5  *
6  * ModFact is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * at your option) any later version.
10  *
11  * ModFact is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with ModFact; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */

20 package org.objectweb.modfact.corba.service;
21
22 import java.io.FileInputStream JavaDoc;
23 import java.io.FileNotFoundException JavaDoc;
24 import java.io.FileOutputStream JavaDoc;
25
26 public class GenerationService
27     extends org.objectweb.modfact.corba.service.cmdline.common.ModfactApplicationBase
28     implements
29         org.objectweb.modfact.corba.service.cmdline.io.ImportApplication,
30         org.objectweb.modfact.corba.service.cmdline.io.ExportApplication {
31
32     /** The IDL flag. */
33     private boolean idl = false;
34
35     /** The Java flag. */
36     private boolean java = false;
37
38     /** The DTD flag. */
39     private boolean dtd = false;
40
41     /** The XMI Import flag. */
42     private boolean xmiImport = false;
43
44     /** The XMI Export flag. */
45     private boolean xmiExport = false;
46
47     /** The server generation flag. */
48     private boolean server = false;
49
50     /** True if the ORB is IDL to Java language mapping compliant */
51     private boolean mappingValid = false;
52
53     /** The input file. */
54     private String JavaDoc input = null;
55
56     /** The output file. */
57     private String JavaDoc output = null;
58
59     /**
60      * Constructor of a GenerationService.
61      */

62     public GenerationService() {
63         super(
64             new org.objectweb.util.cmdline.lib.DefaultCommandLine(
65                 new String JavaDoc[] { "GenerationService" },
66                 new String JavaDoc[0],
67                 new String JavaDoc[] { "Tool to manage the MOF Repository" },
68                 true));
69         // Creates the GenerationService options
70
getCommandLine().addOption(
71             new org.objectweb.modfact.corba.service.cmdline.client.OptionIDL(
72                 this));
73         getCommandLine().addOption(
74             new org.objectweb.modfact.corba.service.cmdline.client.OptionJava(
75                 this));
76         getCommandLine().addOption(
77             new org.objectweb.modfact.corba.service.cmdline.client.OptionDTD(
78                 this));
79         getCommandLine().addOption(
80             new org
81
                .objectweb
82                 .modfact
83                 .corba
84                 .service
85                 .cmdline
86                 .client
87                 .OptionXMIImport(
88                 this));
89         getCommandLine().addOption(
90             new org
91
                .objectweb
92                 .modfact
93                 .corba
94                 .service
95                 .cmdline
96                 .client
97                 .OptionXMIExport(
98                 this));
99         getCommandLine().addOption(
100             new org
101
                .objectweb
102                 .modfact
103                 .corba
104                 .service
105                 .cmdline
106                 .client
107                 .OptionServer(
108                 this));
109         getCommandLine().addOption(
110             new org
111
                .objectweb
112                 .modfact
113                 .corba
114                 .service
115                 .cmdline
116                 .client
117                 .OptionIDLtoJavaMappingValid(this));
118         getCommandLine().addOption(
119             new org.objectweb.modfact.corba.service.cmdline.io.OptionInput(
120                 this));
121         getCommandLine().addOption(
122             new org.objectweb.modfact.corba.service.cmdline.io.OptionOutput(
123                 this));
124     }
125
126     /**
127      * Set the DTD flag.
128      *
129      * @param dtd
130      * TRUE to generate the DTD File.
131      */

132     public void setDTD(boolean dtd) {
133         this.dtd = dtd;
134     }
135
136     /**
137      * Set the IDL flag.
138      *
139      * @param idl
140      * TRUE to generate the IDL File.
141      */

142     public void setIDL(boolean idl) {
143         this.idl = idl;
144     }
145
146     /**
147      * Set the java flag.
148      *
149      * @param java
150      * TRUE to generate the Java Files.
151      */

152     public void setJava(boolean java) {
153         this.java = java;
154     }
155
156     /**
157      * Set the XMI Import flag.
158      *
159      * @param xmiImport
160      * TRUE to generate the XMI Importer.
161      */

162     public void setXMIImport(boolean xmiImport) {
163         this.xmiImport = xmiImport;
164     }
165
166     /**
167      * Set the XMI Export flag.
168      *
169      * @param xmiExport
170      * TRUE to generate the XMI Exporter.
171      */

172     public void setXMIExport(boolean xmiExport) {
173         this.xmiExport = xmiExport;
174     }
175
176     /**
177      * Set the Server generation flag.
178      *
179      * @param server
180      * TRUE to generate the repository server.
181      */

182     public void setServer(boolean server) {
183         this.server = server;
184     }
185
186     /**
187      * Set the flag to indicate if the ORB is IDL to Java language mapping
188      * compliant.
189      *
190      * @param mappingValid
191      * TRUE if it is compliant.
192      */

193     public void setMappingValid(boolean mappingValid) {
194         this.mappingValid = mappingValid;
195     }
196
197     /**
198      * Set the output file.
199      *
200      * @param output
201      * The output file.
202      */

203     public void setOutput(String JavaDoc output) {
204         this.output = output;
205     }
206
207     /**
208      * Set the input file.
209      *
210      * @param input
211      * The input filename.
212      */

213     public void setInputFile(String JavaDoc input) {
214         this.input = input;
215     }
216
217     /**
218      * Starts the main function.
219      *
220      * @param args
221      * The command line arguments.
222      */

223     public int start(String JavaDoc[] args) {
224         try {
225             Generation client = new Generation();
226             client.execute(
227                 idl,
228                 dtd,
229                 java,
230                 xmiImport,
231                 xmiExport,
232                 server,
233                 mappingValid,
234                 new FileInputStream JavaDoc(input),
235                 new FileOutputStream JavaDoc(output),
236                 orb_);
237             return 0;
238         } catch (FileNotFoundException JavaDoc ex) {
239             report_exception(ex);
240             return -1;
241         }
242     }
243
244     /**
245      * The main method.
246      *
247      * @param args
248      * The command line arguments.
249      */

250     public static void main(String JavaDoc[] args) {
251         GenerationService application = new GenerationService();
252         application.runMain(args);
253     }
254
255 }
256
Popular Tags