KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > scripts > IR3toXMI


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle
23                       Mathieu Vadet
24                       Tran Huynh (tran.huynh@fr.thalesgroup.com)
25 Contributor(s): .
26
27 ====================================================================*/

28
29 package org.objectweb.ccm.scripts;
30
31 /**
32  * This class is called by the ir3_xmi shell script.
33  */

34 public class IR3toXMI
35     extends org.objectweb.openccm.corba.Application {
36
37     /**
38      * Default constructor.
39      */

40     public IR3toXMI() {
41     }
42
43     /**
44      * The main bootstrap method.
45      *
46      * @param args The command line arguments.
47      */

48     public static void
49     main(java.lang.String JavaDoc[] args) {
50         IR3toXMI ir3 = new IR3toXMI();
51         ir3.start(args);
52     }
53
54     /**
55      * Overridden org.objectweb.openccm.corba.Application methods.
56      */

57
58     /**
59      * This method runs the application.
60      *
61      * @param args The command line arguments.
62      *
63      * @return The exit code.
64      */

65     public int
66     run(java.lang.String JavaDoc[] args) {
67         // Obtain the Interface Repository.
68
org.objectweb.openccm.ir3.api.ComponentRepository repositoryRef =
69             org.objectweb.openccm.ir3.api.ComponentRepositoryHelper.narrow(
70                 org.objectweb.openccm.corba.TheInterfaceRepository.getRepository());
71
72         // Create an OpenCCM XMI Compiler
73
XMICompiler compiler = new XMICompiler(
74             new IR3XMIOptionsManager(org.objectweb.ccm.scripts.Version.label,
75                                      "ir3_xmi"),
76                                      org.objectweb.ccm.scripts.Version.label);
77
78         // Run the compiler.
79
boolean ok = compiler.run(args);
80         if (!ok) {
81             return -1;
82         }
83
84         // Set the default filename and the default XMI DTD
85
String JavaDoc filename = "stdout";
86         String JavaDoc xmidtd = "xmi.dtd";
87
88         // Create an options manager.
89
IR3XMIOptionsManager manager = compiler.getManager();
90
91         // Deals with the options.
92
if (manager.isSet("-o")) {
93             filename = manager.get("-o")[0];
94         }
95
96         if (manager.isSet("-dtd")) {
97             xmidtd = manager.get("-dtd")[0];
98         }
99
100         // Start an IDL3 Repository
101
org.objectweb.ccm.IDL3.Repository rep =
102             new org.objectweb.ccm.IDL3.Repository(
103                 repositoryRef.as_IDL3_repository());
104
105         try {
106             org.objectweb.ccm.visitorIDL3.xmi.IDL3_XMI mi =
107                 new org.objectweb.ccm.visitorIDL3.xmi.IDL3_XMI(rep);
108
109             // Generate XMI
110
mi.generate(manager.getObjectName(), filename, xmidtd);
111         } catch(fr.lifl.cim.jidlscript.lang.JISError ex) {
112             System.err.println(ex.exception.toString());
113             return 1;
114         }
115
116         return 0;
117     }
118 }
119
Popular Tags