-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ddarriba
committed
Mar 3, 2016
1 parent
27a9f3a
commit 69919a8
Showing
15 changed files
with
1,557 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Main-Class: es.uvigo.darwin.jmodeltest.ModelTest | ||
Class-Path: lib/appframework-1.0.3.jar lib/prottest-3.4.1.jar lib/mpj. | ||
Class-Path: lib/appframework-1.0.3.jar lib/mpj. | ||
jar lib/pal.jar lib/alter.jar lib/swing-worker-1.1.jar. | ||
jar lib/freemarker.jar lib/BrowserLauncher2-all-1_3. | ||
jar lib/jfreechart-1.0.14.jar lib/jcommon-1.0.17.jar |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/java/es/uvigo/darwin/jmodeltest/exe/ExternalExecutionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
Copyright (C) 2009 Diego Darriba | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
package es.uvigo.darwin.jmodeltest.exe; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
/** | ||
* A thrid-party applications manager to control proccesses running on | ||
* the machine and kill them when necessary. | ||
* | ||
* @author Diego Darriba | ||
* @since 3.0 | ||
*/ | ||
public class ExternalExecutionManager { | ||
|
||
/** Unique instance of the manager */ | ||
private static ExternalExecutionManager instance; | ||
/** Collection of running processes */ | ||
private final Collection<Process> processes; | ||
|
||
/** | ||
* Instantiates a new execution manager | ||
*/ | ||
private ExternalExecutionManager() { | ||
this.processes = new ArrayList<Process>(); | ||
} | ||
|
||
/** | ||
* Gets the unique instance of the class | ||
* | ||
* @return the ExternalExecutionManager instance | ||
*/ | ||
public static ExternalExecutionManager getInstance() { | ||
if (instance == null) { | ||
instance = new ExternalExecutionManager(); | ||
} | ||
return instance; | ||
} | ||
|
||
/** | ||
* Adds a process in execution to the collection | ||
* | ||
* @param proc the running process | ||
* | ||
* @return true, if succesfully added the process | ||
*/ | ||
public boolean addProcess(Process proc) { | ||
boolean result = false; | ||
if (!processes.contains(proc)) { | ||
result = processes.add(proc); | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Removes a process from the collection | ||
* | ||
* @param proc the process to remove | ||
* | ||
* @return true, if succesfully removed the process | ||
*/ | ||
public boolean removeProcess(Process proc) { | ||
boolean result = false; | ||
if (processes.contains(proc)) { | ||
result = processes.remove(proc); | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Kills all running processes in the collection | ||
*/ | ||
public void killProcesses() { | ||
for (final Process proc : processes) { | ||
if (proc != null) { | ||
try { | ||
proc.exitValue(); | ||
} catch (IllegalThreadStateException e) { | ||
// The process is executing, so we should kill it | ||
Runtime.getRuntime().addShutdownHook( | ||
new Thread(new Runnable() { | ||
|
||
public void run() { | ||
proc.destroy(); | ||
} | ||
})); | ||
} | ||
} | ||
} | ||
processes.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.