1 28 29 30 package org.objectweb.ecm.taskdefs; 31 32 60 public class IR3StartTask 61 extends org.apache.tools.ant.Task 62 { 63 private java.io.File _cfgdir; 65 66 public 68 IR3StartTask() 69 { 70 _cfgdir = null; 72 } 73 74 78 79 private void 81 validate() 82 throws org.apache.tools.ant.BuildException 83 { 84 String msg = ""; 85 86 if (!OSHelper.isUnix() && !OSHelper.isWindows()) { 88 msg = "target os must be of unix or windows family"; 89 throw new org.apache.tools.ant.BuildException(msg); 90 } 91 92 if (_cfgdir==null) { 94 msg = "cfgdir attribute is missing"; 95 throw new org.apache.tools.ant.BuildException(msg); 96 } 97 if ((!_cfgdir.exists()) || (!_cfgdir.isDirectory())) { 98 msg = "Configuration directory does not exist or is not a directory"; 99 throw new org.apache.tools.ant.BuildException(msg); 100 } 101 102 String bindir = getProject().getProperty("OpenCCM.install.bin.dir"); 104 if (bindir==null) { 105 msg = "OpenCCM.install.bin.dir property must be set"; 106 throw new org.apache.tools.ant.BuildException(msg); 107 } 108 } 109 110 114 final public void 115 setCfgdir(java.io.File cfgdir) 116 { 117 _cfgdir = cfgdir; 118 } 119 120 124 final public void 125 execute() 126 throws org.apache.tools.ant.BuildException 127 { 128 validate(); 129 130 IR3StartWorker worker = new IR3StartWorker(getProject(), _cfgdir); 132 worker.start(); 133 134 java.io.File output = new java.io.File (_cfgdir.getPath(), "IR3.start"); 136 while (!output.exists()) { 137 try { Thread.currentThread().sleep(50); } catch (InterruptedException ex) {} 138 } 139 } 140 } 141 142 class IR3StartWorker 146 extends java.lang.Thread 147 { 148 private org.apache.tools.ant.Project _project; 150 private java.io.File _cfgdir; 151 152 public 154 IR3StartWorker(org.apache.tools.ant.Project project, 155 java.io.File cfgdir) 156 { 157 _project = project; 159 _cfgdir = cfgdir; 160 } 161 162 163 167 final public void 168 run() 169 { 170 try { 171 org.apache.tools.ant.taskdefs.ExecTask cmd = null; 173 cmd = (org.apache.tools.ant.taskdefs.ExecTask)_project.createTask("exec"); 174 175 String cmdname = null; 177 OSHelper.pathConvert(_project, "os.OpenCCM.install.bin.dir", "OpenCCM.install.bin.dir"); 179 String bindir = _project.getProperty("os.OpenCCM.install.bin.dir"); 180 if (OSHelper.isUnix()) { 181 cmdname = bindir+"/ir3_start"; 182 } 183 else if (OSHelper.isWindows()) { 184 cmdname = bindir+"\\ir3_start.bat"; 185 } 186 else { 187 String msg = "Unsupported OS"; 188 _project.log(msg, org.apache.tools.ant.Project.MSG_ERR); 189 } 190 191 cmd.setExecutable(cmdname); 192 193 org.apache.tools.ant.types.Environment.Variable openccm_homedir = null; 195 org.apache.tools.ant.types.Environment.Variable openccm_cfgdir = null; 196 197 OSHelper.pathConvert(_project, "os.OpenCCM.install.dir", "OpenCCM.install.dir"); 199 String homedir = _project.getProperty("os.OpenCCM.install.dir"); 200 openccm_homedir = new org.apache.tools.ant.types.Environment.Variable(); 201 openccm_homedir.setKey("OpenCCM_HOMEDIR"); 202 openccm_homedir.setValue(homedir); 203 cmd.addEnv(openccm_homedir); 204 205 openccm_cfgdir = new org.apache.tools.ant.types.Environment.Variable(); 206 openccm_cfgdir.setKey("OpenCCM_CONFIG_DIR"); 207 openccm_cfgdir.setValue(_cfgdir.getPath()); 208 cmd.addEnv(openccm_cfgdir); 209 210 cmd.execute(); 212 } catch (Exception ex) { 213 String msg = "Exception caught: "+ex.getMessage(); 214 _project.log(msg, org.apache.tools.ant.Project.MSG_ERR); 215 } 216 } 217 } 218 | Popular Tags |