KickJava   Java API By Example, From Geeks To Geeks.

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


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>Generator class for client-side and server-side interceptors.</p>
34  **/

35 public class CIDLCOPI
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     CIDLCOPI()
44     {
45         super(new org.objectweb.util.cmdline.lib.DefaultCommandLine(
46                    "ir3_copi",
47                    "declaration",
48                    "Generate the container interceptors for a component/module from the OpenCCM IR3",
49                    false));
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 container interceptors 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.Scope scope = null;
78         try {
79             scope = (org.objectweb.corba.ast.api.Scope)getAST().lookup(declname);
80         } catch(ClassCastException JavaDoc e) {
81             getConsole().error(declname+"must be a scope");
82             return -1;
83         }
84
85         if(scope==null) {
86             getConsole().error("Declaration "+declname +" not found");
87             return -1;
88         }
89
90         //
91
getConsole().message("Generating container interceptor for " + declname + "...");
92         CIDLCOPIGenerator gen = new CIDLCOPIGenerator(getAST());
93
94         try {
95             gen.generate(_outdir.getArgument(), scope);
96         } catch(org.objectweb.corba.generator.common.lib.GenerationException ex) {
97             report_exception(ex);
98             return -1;
99         }
100
101         getConsole().message("Interceptors generated in "+_outdir.getArgument()+".");
102
103         return 0;
104     }
105
106     //
107
// bootstrap
108
//
109

110     static public void
111     main(String JavaDoc[] args)
112     {
113         CIDLCOPI cmd = new CIDLCOPI();
114         cmd.runMain(args);
115     }
116 }
117
Popular Tags