KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > launching > SootProcessRunner


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.soot.launching;
21
22 import java.lang.reflect.InvocationTargetException JavaDoc;
23
24 import org.eclipse.core.runtime.IProgressMonitor;
25 import org.eclipse.jface.operation.IRunnableWithProgress;
26 import org.eclipse.swt.widgets.*;
27
28 /**
29  * Handles launching Soot as a separate J*ava process.
30  * Not currently used.
31  */

32 public class SootProcessRunner implements IRunnableWithProgress {
33
34     private String JavaDoc cmd;
35     private SootClasspath sootClasspath;
36     private Display display;
37     private Process JavaDoc proc;
38     
39     public SootProcessRunner(Display display, String JavaDoc cmd, SootClasspath cp) {
40         setCmd(cmd);
41         setSootClasspath(cp);
42         setDisplay(display);
43     }
44     
45     
46     /**
47      * @see org.eclipse.jface.operation.IRunnableWithProgress#run(IProgressMonitor)
48      */

49     public void run(IProgressMonitor monitor)
50         throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
51         
52         try {
53                               
54             String JavaDoc exec1 = "java -cp \""+getSootClasspath().getSootClasspath()+"\" soot.Main -p jb use-original-names "+ getCmd();
55             setProc(Runtime.getRuntime().exec(exec1));
56             
57            
58             getProc().waitFor();
59         }
60         catch (Exception JavaDoc e1) {
61             System.out.println(e1.getMessage());
62         }
63     }
64
65     /**
66      * Returns the cmd.
67      * @return String
68      */

69     public String JavaDoc getCmd() {
70         return cmd;
71     }
72
73     /**
74      * Sets the cmd.
75      * @param cmd The cmd to set
76      */

77     public void setCmd(String JavaDoc cmd) {
78         this.cmd = cmd;
79     }
80
81     
82
83     /**
84      * Returns the sootClasspath.
85      * @return SootClasspath
86      */

87     public SootClasspath getSootClasspath() {
88         return sootClasspath;
89     }
90
91     /**
92      * Sets the sootClasspath.
93      * @param sootClasspath The sootClasspath to set
94      */

95     public void setSootClasspath(SootClasspath sootClasspath) {
96         this.sootClasspath = sootClasspath;
97     }
98
99     /**
100      * Returns the display.
101      * @return Display
102      */

103     public Display getDisplay() {
104         return display;
105     }
106
107     /**
108      * Sets the display.
109      * @param display The display to set
110      */

111     public void setDisplay(Display display) {
112         this.display = display;
113     }
114
115     /**
116      * Returns the proc.
117      * @return Process
118      */

119     public Process JavaDoc getProc() {
120         return proc;
121     }
122
123     /**
124      * Sets the proc.
125      * @param proc The proc to set
126      */

127     public void setProc(Process JavaDoc proc) {
128         this.proc = proc;
129     }
130
131 }
132
Popular Tags