KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > runtime > CIDLIDL


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@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): Mathieu Vadet.
23
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.ccm.runtime;
31
32 /**
33  ** <p>.</p>
34  **/

35 public class CIDLIDL
36 extends org.objectweb.corba.command.lib.CommandOnASTBase
37 {
38     //
39
private org.objectweb.util.cmdline.lib.DefaultOptionArgument _outdir;
40
41     // default constructor
42
public
43     CIDLIDL()
44     {
45         super(new org.objectweb.util.cmdline.lib.DefaultCommandLine(
46                    "cidl_idl",
47                    "declaration",
48                    "Generate the IDL mapping for a component/module from the OpenCCM IR3",
49                    true));
50
51         // Option: -d <outputdir>
52
_outdir = new org.objectweb.util.cmdline.lib.DefaultOptionArgument(
53                         new String JavaDoc[] { "-d", "--outputdir" }, "outputdir",
54                         new String JavaDoc[] { "Generate IDL file into directory <outputdir>" },
55                         null);
56
57         // mandatory option
58
_outdir.setMandatory(true);
59
60         getCommandLine().addOption(_outdir);
61     }
62
63     //
64
// org.objectweb.corba.command.api.Application
65
//
66

67     final public int
68     run(java.lang.String JavaDoc[] args)
69     {
70         // init the OpenCCM AST
71
if(!initAST()) {
72             return -1;
73         }
74
75         // obtain scope
76
String JavaDoc declname = args[0];
77         org.objectweb.corba.ast.api.Declaration decl = getAST().lookup(declname);
78
79         if(decl==null) {
80             getConsole().error("Declaration "+declname +" not found");
81             return -1;
82         }
83
84         //
85
getConsole().message("Generating implementations for " + declname + "...");
86         CIDLIDLGenerator gen = new CIDLIDLGenerator(getAST());
87
88         try {
89             gen.initialize(getConsole());
90             gen.generate(_outdir.getArgument(), decl, getConsole());
91         } catch(org.objectweb.corba.generator.common.lib.GenerationException ex) {
92             report_exception(ex);
93             return -1;
94         }
95
96         return 0;
97     }
98
99     //
100
// bootstrap
101
//
102

103     static public void
104     main(String JavaDoc[] args)
105     {
106         CIDLIDL cmd = new CIDLIDL();
107         cmd.runMain(args);
108     }
109 }
110
Popular Tags