Changeset 1035


Ignore:
Timestamp:
Apr 8, 2009, 12:06:41 AM (14 years ago)
Author:
Jari Häkkinen
Message:

Addresses #197. Abort functionality in place in abstract class.

Location:
plugins/base2/net.sf.basedb.pluginutilities/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.pluginutilities/trunk/build.xml

    r1031 r1035  
    4545  <property name="javac.encoding" value="UTF-8" />
    4646  <property name="depend.jars"
    47     value="http://base2.thep.lu.se/base/jars/2.5.0"
     47    value="http://base2.thep.lu.se/base/jars/2.6.0"
    4848    description="The location of the BASE core JARs that we depend on"
    4949  />
  • plugins/base2/net.sf.basedb.pluginutilities/trunk/src/net/sf/basedb/plugins/AbstractRunBinaryPlugin.java

    r1022 r1035  
    3838import net.sf.basedb.core.SpotBatcher;
    3939import net.sf.basedb.core.Transformation;
     40import net.sf.basedb.core.signal.SignalException;
     41import net.sf.basedb.core.signal.SignalHandler;
     42import net.sf.basedb.core.signal.SignalTarget;
     43import net.sf.basedb.core.signal.ThreadSignalHandler;
    4044import net.sf.basedb.util.Values;
    4145
     
    8185abstract public class AbstractRunBinaryPlugin
    8286  extends AbstractAnalysisPlugin
    83   implements InteractivePlugin 
     87  implements InteractivePlugin, SignalTarget
    8488{
    8589
     
    151155    throws InterruptedException, IOException
    152156  {
    153     if (debug_output) System.err.println("execute");
     157    checkInterrupted();
     158    if (debug_output)
     159    {
     160      System.err.println("executing:");
     161      for (String s: cmd) System.err.print(" "+s);
     162      System.err.println("");
     163    }
    154164    if (progress != null) progress.display(5, (about.getName() +
    155165                                               " waiting for external binary."));
     
    167177      bos.close();
    168178    }
     179    BufferedInputStream bis=new BufferedInputStream(p.getInputStream());
     180    try
     181    {
     182      if (debug_output) System.err.println("waiting for binary to finish");
     183      p.waitFor();
     184    }
     185    catch (InterruptedException se)
     186    {
     187      p.destroy();
     188      throw new InterruptedException("Aborted by user");
     189    }
    169190    if (subprocess_stdout!=null)
    170191    {
    171192      if (debug_output) System.err.println("reading stdout");
    172       BufferedInputStream bis=new BufferedInputStream(p.getInputStream());
    173193      FileWriter fw=new FileWriter(getExecDirectory() + java.io.File.separator +
    174194                                   subprocess_stdout);
     
    177197      fw.close();
    178198    }
    179     p.waitFor();
    180199    int status=p.exitValue();
    181200    if (status>0)
     
    293312
    294313
     314  public SignalHandler getSignalHandler()
     315  {
     316    signalHandler = new ThreadSignalHandler();
     317    return signalHandler;
     318  }
     319
     320
    295321  public boolean requiresConfiguration()
    296322  {
     
    302328  {
    303329    if (debug_output) System.err.println("ARBP: run");
     330    if (signalHandler != null) signalHandler.setWorkerThread(null);
    304331    progress=_progress;
    305332    DbControl dc=sc.newDbControl();
     
    309336      if (progress != null) progress.display(0, about.getName());
    310337      runBinary();
     338      checkInterrupted();
    311339      if (progress != null) progress.display(90, "Storing result");
    312340      storeResult(dc);
     341      checkInterrupted();
    313342      if (debug_output)
    314343      {
     
    400429  private java.io.File execDirectory;
    401430  private ProgressReporter progress=null;
     431  private ThreadSignalHandler signalHandler;
    402432
    403433  // debug settings. Note, if debug information is on, the exec
Note: See TracChangeset for help on using the changeset viewer.