1 28 29 30 package org.objectweb.ecm.taskdefs; 31 32 60 public class IR3StopTask 61 extends org.apache.tools.ant.Task 62 { 63 private java.io.File _cfgdir; 65 66 public 68 IR3StopTask() 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 private void 111 ir3stop(java.io.File cfgdir) 112 throws org.apache.tools.ant.BuildException 113 { 114 org.apache.tools.ant.taskdefs.ExecTask cmd = null; 116 cmd = (org.apache.tools.ant.taskdefs.ExecTask)getProject().createTask("exec"); 117 118 String cmdname = null; 120 OSHelper.pathConvert(getProject(), "os.OpenCCM.install.bin.dir", "OpenCCM.install.bin.dir"); 122 String bindir = getProject().getProperty("os.OpenCCM.install.bin.dir"); 123 if (OSHelper.isUnix()) { 124 cmdname = bindir+"/ir3_stop"; 125 } 126 else if (OSHelper.isWindows()) { 127 cmdname = bindir+"\\ir3_stop.bat"; 128 } 129 130 cmd.setExecutable(cmdname); 131 132 org.apache.tools.ant.types.Environment.Variable openccm_homedir = null; 134 org.apache.tools.ant.types.Environment.Variable openccm_cfgdir = null; 135 136 OSHelper.pathConvert(getProject(), "os.OpenCCM.install.dir", "OpenCCM.install.dir"); 138 String homedir = getProject().getProperty("os.OpenCCM.install.dir"); 139 openccm_homedir = new org.apache.tools.ant.types.Environment.Variable(); 140 openccm_homedir.setKey("OpenCCM_HOMEDIR"); 141 openccm_homedir.setValue(homedir); 142 cmd.addEnv(openccm_homedir); 143 144 openccm_cfgdir = new org.apache.tools.ant.types.Environment.Variable(); 145 openccm_cfgdir.setKey("OpenCCM_CONFIG_DIR"); 146 openccm_cfgdir.setValue(cfgdir.getPath()); 147 cmd.addEnv(openccm_cfgdir); 148 149 cmd.execute(); 151 } 152 153 157 final public void 158 setCfgdir(java.io.File cfgdir) 159 { 160 _cfgdir = cfgdir; 161 } 162 163 167 final public void 168 execute() 169 throws org.apache.tools.ant.BuildException 170 { 171 validate(); 172 173 ir3stop(_cfgdir); 175 } 176 } 177 | Popular Tags |