KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > task > CIDLtoCIF


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@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): Christophe Demarey.
23 Contributor(s): ________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.task;
28
29 // Package dependencies
30
import java.util.Iterator JavaDoc;
31 import java.util.Map JavaDoc;
32
33
34 /**
35  * This task generates :
36  * - local OMG IDL interfaces mapping for OMG CIDL definitions
37  * - Java component and home executor skeletons implementing previous interfaces
38  * - Java class dependencies files for each CIDL composition
39  *
40  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
41  *
42  * @version 0.1
43  */

44 public class CIDLtoCIF
45      extends CompilerBase
46   implements Runnable JavaDoc
47 {
48     // ==================================================================
49
//
50
// Internal states.
51
//
52
// ==================================================================
53

54     /** The output file name. */
55     private String JavaDoc dest_file_;
56
57     /** List of prefix to ignore. */
58     private java.util.List JavaDoc no_prefix_;
59
60     /** List of user files to include. */
61     private java.util.List JavaDoc user_includes_;
62
63     /** The output directory for Java Mapping. */
64     private String JavaDoc output_directory_;
65
66     /** The output directory for Dependencies. */
67     private String JavaDoc dependencies_directory_;
68
69     // ==================================================================
70
//
71
// Constructors.
72
//
73
// ==================================================================
74

75     /**
76      * The default constructor.
77      *
78      * @param project_properties - Properties of the Ant Project.
79      */

80     public CIDLtoCIF(Map JavaDoc project_properties)
81     {
82         // Call CompilerBase constructor
83
super(project_properties);
84         
85         // Init internal states
86
dest_file_ = "generated_cif.idl";
87         user_includes_ = new java.util.ArrayList JavaDoc();
88         no_prefix_ = new java.util.ArrayList JavaDoc();
89         output_directory_ = "generated";
90         dependencies_directory_ = "dependencies";
91     }
92     
93     // ==================================================================
94
//
95
// Internal methods.
96
//
97
// ==================================================================
98

99     // ==================================================================
100
//
101
// Public methods.
102
//
103
// ==================================================================
104

105     /**
106      * Configure the task.
107      */

108     public void
109     configure()
110     {
111         Iterator JavaDoc it = null;
112         
113         // Call the CompilerBase configure method
114
super.configure();
115         
116         setXmlFile( project_properties_.getProperty("OpenCCM_HOMEDIR") + "/xml/launcher/CIDLtoCIF.xml" );
117         addProperty( "OpenCCM_CONFIG_DIR",
118                      project_properties_.getProperty("OpenCCM_CONFIG_DIR") );
119         // Add destination file
120
addArgument("-o");
121         addArgument(dest_file_);
122         // Add user include declarations
123
for (it = user_includes_.iterator(); it.hasNext(); )
124         {
125             addArgument("-ipath");
126             addArgument( (String JavaDoc) it.next() );
127         }
128         // Add user include declarations
129
for (it = no_prefix_.iterator(); it.hasNext(); )
130         {
131             addArgument("--noprefix");
132             addArgument( (String JavaDoc) it.next() );
133         }
134         // Add the output directory
135
addArgument("-d");
136         addArgument(output_directory_);
137         // Add the dependencies directory
138
addArgument("-dep");
139         addArgument(dependencies_directory_);
140     }
141
142     /**
143      * Set Java mapping output directory.
144      *
145      * @param outputdir - The output directory name.
146      */

147     public void
148     setDestfile(String JavaDoc filename)
149     {
150         dest_file_ = filename;
151     }
152     
153     /**
154      * Set Java mapping output directory.
155      *
156      * @param outputdir - The output directory name.
157      */

158     public void
159     setDestdir(String JavaDoc destdir)
160     {
161         output_directory_ = destdir;
162     }
163     
164     /**
165      * Set Java mapping output directory.
166      *
167      * @param outputdir - The output directory name.
168      */

169     public void
170     setDependenciesdir(String JavaDoc depdir)
171     {
172         dependencies_directory_ = depdir;
173     }
174     
175     /**
176      * Add a user include declaration in the generated file.
177      *
178      * @param str - The declaration name to include.
179      */

180     public void
181     addConfiguredUserinclude(StringType str)
182     {
183         user_includes_.add(str.getName());
184     }
185
186     /**
187      * Add a prefix to ignore in dependencies.
188      *
189      * @param str - The declaration name to include.
190      */

191     public void
192     addConfiguredIgnoreprefix(StringType str)
193     {
194         no_prefix_.add(str.getName());
195     }
196 }
197
Popular Tags