KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ecm > taskdefs > JacORBIDLtoJavaTask


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.ecm.taskdefs;
31
32 /**
33  ** <p>Concrete implementation of the <tt>IDLtoJavaTask</tt> for JacORB.</p>
34  **/

35 public class JacORBIDLtoJavaTask
36 extends IDLtoJavaTask
37 {
38     //
39

40     // default constructor
41
public
42     JacORBIDLtoJavaTask()
43     {
44         //
45
}
46
47     //
48
// abstract operations implementation
49
//
50

51     final protected void
52     compileIDL(java.io.File JavaDoc idlfile, java.io.File JavaDoc compileto,
53                java.io.File JavaDoc[] includedirs, String JavaDoc prefix)
54     {
55         // use java task
56
org.apache.tools.ant.Task task = getProject().createTask("java");
57         org.apache.tools.ant.taskdefs.Java java = (org.apache.tools.ant.taskdefs.Java)task;
58         java.setClassname("org.jacorb.idl.parser");
59         java.setFork(true);
60         java.setFailonerror(true);
61
62         // create classpath
63
org.apache.tools.ant.types.Path cp = java.createClasspath();
64         // put path to JacORBOpenORB jar in cp
65
// NOTE: use version independent path of JacORB for that
66
cp.setRefid(new org.apache.tools.ant.types.Reference("JacORB.class.path"));
67         org.apache.tools.ant.types.Commandline.Argument args = java.createArg();
68
69         // build arg line
70
// NOTE: include JacORB IDL directory by default
71
OSHelper.pathConvert(getProject(), "os.JacORB.idl.dir", "JacORB.idl.dir");
72         OSHelper.pathConvert(getProject(), "os.JacORB.idl.omg.dir", "JacORB.idl.omg.dir");
73         String JavaDoc argline = "-D__JACORB__"+
74             " -I"+getProject().getProperty("os.JacORB.idl.dir")+
75             " -I"+getProject().getProperty("os.JacORB.idl.omg.dir");
76
77         // add included directories
78
for (int i=0;i<includedirs.length;i++) {
79             argline = argline+" -I"+includedirs[i].getPath();
80         }
81
82         // add "-jdk14 i2jline -d compileto idlfile"
83
// -jdk14 do compatibility checks for JDK 1.4
84
// -d set output directory
85

86         //
87
String JavaDoc i2jline = " -i2jpackage CORBA:org.omg.CORBA "+
88             " -i2jpackage CosNaming:org.omg.CosNaming "+
89             " -i2jpackage CosTransactions:org.omg.CosTransactions "+
90             " -i2jpackage CosPersistentState:org.omg.CosPersistentState "+
91             " -i2jpackage CosTrading:org.omg.CosTrading "+
92             " -i2jpackage CosTradingRepos:org.omg.CosTradingRepos "+
93             " -i2jpackage CosTradingDynamic:org.omg.CosTradingDynamic "+
94             " -i2jpackage Components:org.omg.Components "+
95             // TODO: use external config for that !
96
" -i2jpackage objectweb:org.objectweb "+
97             " -i2jpackage ECA:org.coach.ECA "+
98             " -i2jpackage ECM:org.coach.ECM ";
99
100         argline = argline+i2jline+" -W 1 -d "+compileto.getPath()+" "+idlfile.getPath();
101         //log("[compileIDL] argline: "+argline);
102
args.setLine(argline);
103
104         // execute
105
java.execute();
106     }
107 }
108
Popular Tags