| 1 | /* |
| 2 | * @(#) $Id: SlugHelper.java,v 1.1.1.1 2006/03/19 06:09:42 rossen Exp $ |
| 3 | * |
| 4 | * Copyright (c) 2006, WebHydra.com |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions are met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * * Neither the name of the WebHydra.com nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this software |
| 17 | * without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | package com.webhydra.slug; |
| 33 | |
| 34 | import com.webhydra.slug.process.ProcessStatus; |
| 35 | import com.webhydra.slug.SlugInitializationException; |
| 36 | import com.webhydra.slug.process.ISlugRunner; |
| 37 | import com.webhydra.slug.process.SluggishProcess; |
| 38 | import javax.servlet.http.HttpServletRequest; |
| 39 | import javax.servlet.http.HttpSession; |
| 40 | |
| 41 | /** |
| 42 | * Provide conviniet access to the running <code>SluggisProcess</code>ess. |
| 43 | * @author rossen |
| 44 | */ |
| 45 | public class SlugHelper { |
| 46 | |
| 47 | // Consumption calls |
| 48 | |
| 49 | /** |
| 50 | * Consume <code>SluggishProcess</code> from default runner. |
| 51 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 52 | * @param request current HTTP request. |
| 53 | * @param pid <code>PID</code> of the proccess. |
| 54 | * @return consumed <code>SluggishProcess</code> or null if provided runner |
| 55 | * can not be foud or there is not a process with provided <code>PID</code> |
| 56 | * for specified <code>session</code>. |
| 57 | * with provided <code>PID</code> for specified <code>session</code>. |
| 58 | * @see #consumeProcess(String, String, String) |
| 59 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 60 | */ |
| 61 | public static SluggishProcess consumeProcess(HttpServletRequest request, String pid) throws SlugInitializationException |
| 62 | { |
| 63 | return consumeProcess(request.getSession(), pid); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Consume <code>SluggishProcess</code> from default runner. |
| 68 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 69 | * @param session current HTTP session. |
| 70 | * @param pid <code>PID</code> of the proccess. |
| 71 | * @return consumed <code>SluggishProcess</code> or null if provided runner |
| 72 | * can not be foud or there is not a process with provided <code>PID</code> |
| 73 | * for specified <code>session</code>. |
| 74 | * with provided <code>PID</code> for specified <code>session</code>. |
| 75 | * @see #consumeProcess(String, String, String) |
| 76 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 77 | */ |
| 78 | public static SluggishProcess consumeProcess(HttpSession session, String pid) throws SlugInitializationException |
| 79 | { |
| 80 | return consumeProcess(session.getId(), pid); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Consume <code>SluggishProcess</code> from default runner. |
| 85 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 86 | * @param sessionId <code>session</code> Id. |
| 87 | * @param pid <code>PID</code> of the proccess. |
| 88 | * @return consumed <code>SluggishProcess</code> or null if provided runner |
| 89 | * can not be foud or there is not a process with provided <code>PID</code> |
| 90 | * for specified <code>session</code>. |
| 91 | * with provided <code>PID</code> for specified <code>session</code>. |
| 92 | * @see #consumeProcess(String, String, String) |
| 93 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 94 | */ |
| 95 | public static SluggishProcess consumeProcess(String sessionId, String pid) throws SlugInitializationException |
| 96 | { |
| 97 | String runnerName = SlugConfig.getInstance().getDefaultRunnerName(); |
| 98 | return consumeProcess(runnerName, sessionId, pid); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Consume <code>SluggishProcess</code> |
| 103 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 104 | * |
| 105 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 106 | * @param request current HTTP request. |
| 107 | * @param pid <code>PID</code> of the proccess. |
| 108 | * @return consumed <code>SluggishProcess</code> or null if provided runner |
| 109 | * can not be foud or there is not a process with provided <code>PID</code> |
| 110 | * for specified <code>session</code>. |
| 111 | * with provided <code>PID</code> for specified <code>session</code>. |
| 112 | * @see #consumeProcess(String, String, String) |
| 113 | */ |
| 114 | public static SluggishProcess consumeProcess(String runnerName, HttpServletRequest request, String pid) |
| 115 | { |
| 116 | return consumeProcess(runnerName, request.getSession(), pid); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Consume <code>SluggishProcess</code> |
| 121 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 122 | * |
| 123 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 124 | * @param session current HTTP session. |
| 125 | * @param pid <code>PID</code> of the proccess. |
| 126 | * @return consumed <code>SluggishProcess</code> or null if provided runner |
| 127 | * can not be foud or there is not a process with provided <code>PID</code> |
| 128 | * for specified <code>session</code>. |
| 129 | * with provided <code>PID</code> for specified <code>session</code>. |
| 130 | * @see #consumeProcess(String, String, String) |
| 131 | */ |
| 132 | public static SluggishProcess consumeProcess(String runnerName, HttpSession session, String pid) |
| 133 | { |
| 134 | return consumeProcess(runnerName, session.getId(), pid); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Consume <code>SluggishProcess</code> |
| 139 | * |
| 140 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 141 | * @param sessionId session ID. |
| 142 | * @param pid <code>PID</code> of the proccess. |
| 143 | * @return consumed <code>SluggishProcess</code> or null if provided runner |
| 144 | * can not be foud or there is not a process with provided <code>PID</code> |
| 145 | * for specified <code>session</code>. |
| 146 | */ |
| 147 | public static SluggishProcess consumeProcess(String runnerName, String sessionId, String pid) |
| 148 | { |
| 149 | SluggishProcess sp = null; |
| 150 | ISlugRunner runner = SlugConfig.getInstance().getRunner(runnerName); |
| 151 | if (runner != null) |
| 152 | { |
| 153 | sp = runner.consumeProcess(sessionId, pid); |
| 154 | } |
| 155 | return sp; |
| 156 | } |
| 157 | |
| 158 | // Status calls |
| 159 | |
| 160 | /** |
| 161 | * Retrieve <code>ProcessStatus</code> of a <code>SluggishProcess</code> from default runner. |
| 162 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 163 | * @param request current HTTP request. |
| 164 | * @param pid <code>PID</code> of the proccess. |
| 165 | * @return <code>ProcessStatus</code> for spefigied process or null if |
| 166 | * provided runner can not be foud or there is not a process |
| 167 | * with provided <code>PID</code> for specified <code>session</code>. |
| 168 | * @see #getStatus(String, String, String) |
| 169 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 170 | */ |
| 171 | public static ProcessStatus getStatus(HttpServletRequest request, String pid) throws SlugInitializationException |
| 172 | { |
| 173 | String runnerName = SlugConfig.getInstance().getDefaultRunnerName(); |
| 174 | return getStatus(request.getSession(), pid); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Retrieve <code>ProcessStatus</code> of a <code>SluggishProcess</code> from default runner. |
| 179 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 180 | * @param session current HTTP session. |
| 181 | * @param pid <code>PID</code> of the proccess. |
| 182 | * @return <code>ProcessStatus</code> for spefigied process or null if |
| 183 | * provided runner can not be foud or there is not a process |
| 184 | * with provided <code>PID</code> for specified <code>session</code>. |
| 185 | * @see #getStatus(String, String, String) |
| 186 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 187 | */ |
| 188 | public static ProcessStatus getStatus(HttpSession session, String pid) throws SlugInitializationException |
| 189 | { |
| 190 | return getStatus(session.getId(), pid); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Retrieve <code>ProcessStatus</code> of a <code>SluggishProcess</code> from default runner. |
| 195 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 196 | * @param sessionId <code>session</code> ID. |
| 197 | * @param pid <code>PID</code> of the proccess. |
| 198 | * @return <code>ProcessStatus</code> for spefigied process or null if |
| 199 | * provided runner can not be foud or there is not a process |
| 200 | * with provided <code>PID</code> for specified <code>session</code>. |
| 201 | * @see #getStatus(String, String, String) |
| 202 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 203 | */ |
| 204 | public static ProcessStatus getStatus(String sessionId, String pid) throws SlugInitializationException |
| 205 | { |
| 206 | String runnerName = SlugConfig.getInstance().getDefaultRunnerName(); |
| 207 | return getStatus(runnerName, sessionId, pid); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Retrieve <code>ProcessStatus</code> of a <code>SluggishProcess</code> from default runner. |
| 212 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 213 | * |
| 214 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 215 | * @param request current HTTP request. |
| 216 | * @param pid <code>PID</code> of the proccess. |
| 217 | * @return <code>ProcessStatus</code> for spefigied process or null if |
| 218 | * provided runner can not be foud or there is not a process |
| 219 | * with provided <code>PID</code> for specified <code>session</code>. |
| 220 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 221 | * @see #getStatus(String, String, String) |
| 222 | */ |
| 223 | public static ProcessStatus getStatus(String runnerName, HttpServletRequest request, String pid) |
| 224 | { |
| 225 | return getStatus(runnerName, request.getSession(), pid); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Retrieve <code>ProcessStatus</code> of a <code>SluggishProcess</code> from default runner. |
| 230 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 231 | * |
| 232 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 233 | * @param session current HTTP session. |
| 234 | * @param pid <code>PID</code> of the proccess. |
| 235 | * @return <code>ProcessStatus</code> for spefigied process or null if |
| 236 | * provided runner can not be foud or there is not a process |
| 237 | * with provided <code>PID</code> for specified <code>session</code>. |
| 238 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 239 | * @see #getStatus(String, String, String) |
| 240 | */ |
| 241 | public static ProcessStatus getStatus(String runnerName, HttpSession session, String pid) |
| 242 | { |
| 243 | return getStatus(runnerName, session.getId(), pid); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Retrieve <code>ProcessStatus</code> of a <code>SluggishProcess</code> from default runner. |
| 248 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 249 | * |
| 250 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 251 | * @param sessionId <code>session</code> ID. |
| 252 | * @param pid <code>PID</code> of the proccess. |
| 253 | * @return <code>ProcessStatus</code> for spefigied process or null if |
| 254 | * provided runner can not be foud or there is not a process |
| 255 | * with provided <code>PID</code> for specified <code>session</code>. |
| 256 | * @see ISlugRunner#checkProcess(String, String) |
| 257 | */ |
| 258 | public static ProcessStatus getStatus(String runnerName, String sessionId, String pid) |
| 259 | { |
| 260 | ProcessStatus ps = null; |
| 261 | ISlugRunner runner = SlugConfig.getInstance().getRunner(runnerName); |
| 262 | if (runner != null) |
| 263 | { |
| 264 | ps = runner.checkProcess(sessionId, pid); |
| 265 | } |
| 266 | return ps; |
| 267 | } |
| 268 | |
| 269 | // Cancelation calls |
| 270 | |
| 271 | /** |
| 272 | * Cancel <code>SluggishProcess</code> from default runner. |
| 273 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 274 | * @param request current HTTP request. |
| 275 | * @param pid <code>PID</code> of the proccess. |
| 276 | * @return canceled <code>SluggishProcess</code> or null if provided runner |
| 277 | * can not be foud or there is not a process with provided <code>PID</code> |
| 278 | * for specified <code>session</code>. |
| 279 | * with provided <code>PID</code> for specified <code>session</code>. |
| 280 | * @see #cancelProcess(String, String, String) |
| 281 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 282 | */ |
| 283 | public static SluggishProcess cancelProcess(HttpServletRequest request, String pid) throws SlugInitializationException |
| 284 | { |
| 285 | return cancelProcess(request.getSession(), pid); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Cancel <code>SluggishProcess</code> from default runner. |
| 290 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 291 | * @param session current HTTP session. |
| 292 | * @param pid <code>PID</code> of the proccess. |
| 293 | * @return canceled <code>SluggishProcess</code> or null if provided runner |
| 294 | * can not be foud or there is not a process with provided <code>PID</code> |
| 295 | * for specified <code>session</code>. |
| 296 | * with provided <code>PID</code> for specified <code>session</code>. |
| 297 | * @see #cancelProcess(String, String, String) |
| 298 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 299 | */ |
| 300 | public static SluggishProcess cancelProcess(HttpSession session, String pid) throws SlugInitializationException |
| 301 | { |
| 302 | return cancelProcess(session.getId(), pid); |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * Cancel <code>SluggishProcess</code> from default runner. |
| 307 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 308 | * @param sessionId <code>session</code> ID. |
| 309 | * @param pid <code>PID</code> of the proccess. |
| 310 | * @return canceled <code>SluggishProcess</code> or null if provided runner |
| 311 | * can not be foud or there is not a process with provided <code>PID</code> |
| 312 | * for specified <code>session</code>. |
| 313 | * with provided <code>PID</code> for specified <code>session</code>. |
| 314 | * @see #cancelProcess(String, String, String) |
| 315 | * @exception SlugInitializationException if Slug is not properly initialized. |
| 316 | */ |
| 317 | public static SluggishProcess cancelProcess(String sessionId, String pid) throws SlugInitializationException |
| 318 | { |
| 319 | String runnerName = SlugConfig.getInstance().getDefaultRunnerName(); |
| 320 | return cancelProcess(runnerName, sessionId, pid); |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * Cancel <code>SluggishProcess</code> |
| 325 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 326 | * |
| 327 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 328 | * @param request current HTTP request. |
| 329 | * @param pid <code>PID</code> of the proccess. |
| 330 | * @return canceled <code>SluggishProcess</code> or null if provided runner |
| 331 | * can not be foud or there is not a process with provided <code>PID</code> |
| 332 | * for specified <code>session</code>. |
| 333 | * with provided <code>PID</code> for specified <code>session</code>. |
| 334 | * @see #cancelProcess(String, String, String) |
| 335 | */ |
| 336 | public static SluggishProcess cancelProcess(String runnerName, HttpServletRequest request, String pid) |
| 337 | { |
| 338 | return cancelProcess(runnerName, request.getSession(), pid); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Cancel<code>SluggishProcess</code> |
| 343 | * This method is simple wrapper arround consumeProcess(String, String, String). |
| 344 | * |
| 345 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 346 | * @param session current HTTP session. |
| 347 | * @param pid <code>PID</code> of the proccess. |
| 348 | * @return canceled <code>SluggishProcess</code> or null if provided runner |
| 349 | * can not be foud or there is not a process with provided <code>PID</code> |
| 350 | * for specified <code>session</code>. |
| 351 | * with provided <code>PID</code> for specified <code>session</code>. |
| 352 | * @see #cancelProcess(String, String, String) |
| 353 | */ |
| 354 | public static SluggishProcess cancelProcess(String runnerName, HttpSession session, String pid) |
| 355 | { |
| 356 | return cancelProcess(runnerName, session.getId(), pid); |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * Cancel <code>SluggishProcess</code> |
| 361 | * |
| 362 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 363 | * @param sessionId session ID. |
| 364 | * @param pid <code>PID</code> of the proccess. |
| 365 | * @return canceled <code>SluggishProcess</code> or null if provided runner |
| 366 | * can not be foud or there is not a process with provided <code>PID</code> |
| 367 | * for specified <code>session</code>. |
| 368 | * @see ISlugRunner#cancelProcess(String, String) |
| 369 | */ |
| 370 | public static SluggishProcess cancelProcess(String runnerName, String sessionId, String pid) |
| 371 | { |
| 372 | SluggishProcess sp = null; |
| 373 | ISlugRunner runner = SlugConfig.getInstance().getRunner(runnerName); |
| 374 | if (runner != null) |
| 375 | { |
| 376 | sp = runner.cancelProcess(sessionId, pid); |
| 377 | } |
| 378 | return sp; |
| 379 | } |
| 380 | |
| 381 | // Runnig calls |
| 382 | |
| 383 | /** |
| 384 | * Add provided <code>SluggishProcess</code> to the specified default <code>ISlugRunner</code>. |
| 385 | * Adds provided <code>SluggishProcess</code> to the default |
| 386 | * <code>ISlugRunner</code> and schedule it for running. |
| 387 | * This function is wrapper arround runProcess(String, String, SluggishProcess) |
| 388 | * |
| 389 | * @param request current HTTP request. |
| 390 | * @param proc <code>SluggishProcess</code> to run. |
| 391 | * @return Process' <code>PID</code> or null if it can not be started. |
| 392 | * @see #runProcess(String, String, SluggishProcess) |
| 393 | */ |
| 394 | public static String runProcess(HttpServletRequest request, SluggishProcess proc) throws SlugInitializationException |
| 395 | { |
| 396 | return runProcess(request.getSession(), proc); |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * Add provided <code>SluggishProcess</code> to the specified default <code>ISlugRunner</code>. |
| 401 | * Adds provided <code>SluggishProcess</code> to the default |
| 402 | * <code>ISlugRunner</code> and schedule it for running. |
| 403 | * This function is wrapper arround runProcess(String, String, SluggishProcess) |
| 404 | * |
| 405 | * @param session current HTTP session. |
| 406 | * @param proc <code>SluggishProcess</code> to run. |
| 407 | * @return Process' <code>PID</code> or null if it can not be started. |
| 408 | * @see #runProcess(String, String, SluggishProcess) |
| 409 | */ |
| 410 | public static String runProcess(HttpSession session, SluggishProcess proc) throws SlugInitializationException |
| 411 | { |
| 412 | return runProcess(session.getId(), proc); |
| 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Add provided <code>SluggishProcess</code> to the specified default <code>ISlugRunner</code>. |
| 417 | * Adds provided <code>SluggishProcess</code> to the default |
| 418 | * <code>ISlugRunner</code> and schedule it for running. |
| 419 | * This function is wrapper arround runProcess(String, String, SluggishProcess) |
| 420 | * |
| 421 | * @param sessionId <code>session</code> ID. |
| 422 | * @param proc <code>SluggishProcess</code> to run. |
| 423 | * @return Process' <code>PID</code> or null if it can not be started. |
| 424 | * @see #runProcess(String, String, SluggishProcess) |
| 425 | */ |
| 426 | public static String runProcess(String sessionId, SluggishProcess proc) throws SlugInitializationException |
| 427 | { |
| 428 | String runnerName = SlugConfig.getInstance().getDefaultRunnerName(); |
| 429 | return runProcess(runnerName, sessionId, proc); |
| 430 | } |
| 431 | |
| 432 | /** |
| 433 | * Add provided <code>SluggishProcess</code> to the specified <code>ISlugRunner</code>. |
| 434 | * Adds provided <code>SluggishProcess</code> to the specified |
| 435 | * <code>ISlugRunner</code> and schedule it for running. |
| 436 | * This function is wrapper arround runProcess(String, String, SluggishProcess) |
| 437 | * |
| 438 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 439 | * @param request current HTTP request. |
| 440 | * @param proc <code>SluggishProcess</code> to run. |
| 441 | * @return Process' <code>PID</code> or null if it can not be started. |
| 442 | * @see #runProcess(String, String, SluggishProcess) |
| 443 | */ |
| 444 | public static String runProcess(String runnerName, HttpServletRequest request, SluggishProcess proc) |
| 445 | { |
| 446 | return runProcess(runnerName, request.getSession(), proc); |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * Add provided <code>SluggishProcess</code> to the specified <code>ISlugRunner</code>. |
| 451 | * Adds provided <code>SluggishProcess</code> to the specified |
| 452 | * <code>ISlugRunner</code> and schedule it for running. |
| 453 | * This function is wrapper arround runProcess(String, String, SluggishProcess) |
| 454 | * |
| 455 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 456 | * @param session current HTTP session. |
| 457 | * @param proc <code>SluggishProcess</code> to run. |
| 458 | * @return Process' <code>PID</code> or null if it can not be started. |
| 459 | * @see #runProcess(String, String, SluggishProcess) |
| 460 | */ |
| 461 | public static String runProcess(String runnerName, HttpSession session, SluggishProcess proc) |
| 462 | { |
| 463 | return runProcess(runnerName, session.getId(), proc); |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Add provided <code>SluggishProcess</code> to the specified <code>ISlugRunner</code>. |
| 468 | * Adds provided <code>SluggishProcess</code> to the specified |
| 469 | * <code>ISlugRunner</code> and schedule it for running. |
| 470 | * |
| 471 | * @param runnerName name of the <code>ISlugRunner</code>. |
| 472 | * @param sessionId session ID. |
| 473 | * @param proc <code>SluggishProcess</code> to run. |
| 474 | * @return Process' <code>PID</code> or null if it can not be started. |
| 475 | * @see ISlugRunner#add(SluggishProcess, String) |
| 476 | */ |
| 477 | public static String runProcess(String runnerName, String sessionId, SluggishProcess proc) |
| 478 | { |
| 479 | String pid = null; |
| 480 | ISlugRunner runner = SlugConfig.getInstance().getRunner(runnerName); |
| 481 | if (runner != null) |
| 482 | { |
| 483 | pid = runner.add(proc, sessionId); |
| 484 | } |
| 485 | return pid; |
| 486 | } |
| 487 | } |