KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2005 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): Philippe Merle.
24
25 ====================================================================
26 $Id: IR3Start.java,v 1.3 2005/06/07 15:52:59 merle Exp $
27 ====================================================================*/

28
29 package org.objectweb.openccm.task;
30
31 // Packaga dependencies
32
import java.io.File JavaDoc;
33 import java.util.Map JavaDoc;
34
35 /**
36  * This task run the OpenCCM Interface Repository
37  * and feeds IFR and Components idl files.
38  *
39  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
40  *
41  * @version 0.1
42  */

43 public class IR3Start
44      extends LauncherApplication
45 {
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51

52     /** The file to write IOR in. */
53     private String JavaDoc ior_file_;
54
55     /** To disable OMG IDL2.x mappings. */
56     private boolean no_mappings_;
57
58     // ==================================================================
59
//
60
// Constructors.
61
//
62
// ==================================================================
63

64     /**
65      * The default constructor.
66      *
67      * @param project_properties - Properties of the Ant Project.
68      */

69     public IR3Start(Map JavaDoc project_properties)
70     {
71         // Call Launcher constructor
72
super(project_properties);
73         
74         // Init internal states
75
ior_file_ = project_properties_.getProperty("OpenCCM_CONFIG_DIR") + "/IR3.IOR";
76         no_mappings_ = false;
77     }
78
79     // ==================================================================
80
//
81
// Internal methods.
82
//
83
// ==================================================================
84

85     // ==================================================================
86
//
87
// Public methods.
88
//
89
// ==================================================================
90

91     /**
92      * Configure the task.
93      */

94     public void
95     configure()
96     {
97         String JavaDoc idl_dir = null;
98
99         addProperty( "OpenCCM_CONFIG_DIR",
100                      project_properties_.getProperty("OpenCCM_CONFIG_DIR") );
101         addArgument("--ior-file");
102         addArgument(ior_file_);
103         if (no_mappings_)
104         {
105             addArgument("--no-mappings");
106         }
107
108         setXmlFile( project_properties_.getProperty("OpenCCM_HOMEDIR") + "/xml/launcher/IR3Server.xml" );
109     }
110     
111     /**
112      * Callback method to insert code after
113      * application launched.
114      */

115     public void
116     post_exec()
117     {
118         // Wait for the IR3 IOR
119
File JavaDoc file = new File JavaDoc(ior_file_);
120         while ( (!file.exists()) )
121         {
122             // Sleep 1 second and recheck if the file exists.
123
try { Thread.sleep(1000); } catch(Exception JavaDoc exc) { }
124         }
125     }
126
127     /**
128      * Stop the launcher application process.
129      */

130     public void
131     stop()
132     {
133         super.stop();
134         
135         // Remove the IOR file
136
File JavaDoc file = new File JavaDoc(ior_file_);
137         file.delete();
138     }
139
140     /**
141      * Set the name of the file to write IOR in.
142      *
143      * @param ior_file - The IOR file name.
144      */

145     public void
146     setIorfile(String JavaDoc ior_file)
147     {
148         this.ior_file_ = ior_file;
149     }
150
151     /**
152      * To disable OMG IDL2.x mappings.
153      *
154      * @param b - If true, disables OMG IDL2.x mappings.
155      */

156     public void
157     setNo_mappings(boolean b)
158     {
159         this.no_mappings_ = b;
160     }
161 }
162
Popular Tags