KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > process > rsh > RSHJVMProcess


1 /*
2  * ################################################################
3  *
4  * ProActive: The Java(TM) library for Parallel, Distributed,
5  * Concurrent computing with Security and Mobility
6  *
7  * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8  * Contact: proactive-support@inria.fr
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  *
25  * Initial developer(s): The ProActive Team
26  * http://www.inria.fr/oasis/ProActive/contacts.html
27  * Contributor(s):
28  *
29  * ################################################################
30  */

31 package org.objectweb.proactive.core.process.rsh;
32
33 import org.objectweb.proactive.core.process.JVMProcess;
34 import org.objectweb.proactive.core.process.JVMProcessImpl;
35 import org.objectweb.proactive.core.util.MessageLogger;
36
37
38 /**
39  * <p>
40  * The RSHJVMProcess class is able to start any class, of the ProActive library,
41  * using rsh protocol. The difference between this class and RSHProcess class is that the target process
42  * for this class is automatically a JVMProcess, whereas for the RSHProcess, the target process has to be defined
43  * and can be any command and any process.
44  * </p><p>
45  * For instance:
46  * </p><pre>
47  * .......
48  * RSHProcess rsh = new RSHJVMProcess(new StandardOutputMessageLogger());
49  * rsh.setHostname("machine_name");
50  * rsh.startProcess();
51  * .....
52  * </pre>
53  * <p>
54  * This piece of code creates a new RSHJVMProcess. It allows to log on a remote machine with the rsh protocol and then,
55  * on this machine to create a Java Virtual Machine, by launching a ProActive java class.
56  * </p>
57  * @author ProActive Team
58  * @version 1.0, 2002/09/20
59  * @since ProActive 0.9.4
60  */

61 public class RSHJVMProcess extends RSHProcess implements JVMProcess {
62     protected JVMProcessImpl jvmProcess;
63
64     //
65
// -- CONSTRUCTORS -----------------------------------------------
66
//
67

68     /**
69      * Creates a new RSHJVMProcess
70      * Used with XML Descriptor
71      */

72     public RSHJVMProcess() {
73         super();
74     }
75
76     /**
77      * Creates a new RSHJVMProcess
78      * @param messageLogger The logger that handles input and error stream of the target JVMProcess
79      */

80     public RSHJVMProcess(MessageLogger messageLogger) {
81         this(messageLogger, messageLogger);
82     }
83
84     /**
85      * Creates a new RSHJVMProcess
86      * @param inputMessageLogger The logger that handles input stream of the target JVMProcess
87      * @param errorMessageLogger The logger that handles error stream of the target JVMProcess
88      */

89     public RSHJVMProcess(MessageLogger inputMessageLogger,
90         MessageLogger errorMessageLogger) {
91         super(new JVMProcessImpl(inputMessageLogger, errorMessageLogger));
92         jvmProcess = (JVMProcessImpl) targetProcess;
93     }
94
95     //
96
// -- PUBLIC METHODS -----------------------------------------------
97
//
98
public static void main(String JavaDoc[] args) {
99         try {
100             RSHProcess rsh = new RSHJVMProcess(new StandardOutputMessageLogger());
101             rsh.setHostname("solida");
102             rsh.startProcess();
103         } catch (Exception JavaDoc e) {
104             e.printStackTrace();
105         }
106     }
107
108     //
109
// -- implements JVMProcess -----------------------------------------------
110
//
111

112     /**
113      * Returns the classpath associated to the target JVMProcess
114      * @return String
115      */

116     public String JavaDoc getClasspath() {
117         return jvmProcess.getClasspath();
118     }
119
120     /**
121      * Sets the classpath for the target JVMProcess
122      * @param classpath The value of the classpath environment variable
123      */

124     public void setClasspath(String JavaDoc classpath) {
125         checkStarted();
126         jvmProcess.setClasspath(classpath);
127     }
128
129     /**
130      * Returns the java path associated the target JVMProcess
131      * @return String The path to the java command
132      */

133     public String JavaDoc getJavaPath() {
134         return jvmProcess.getJavaPath();
135     }
136
137     /**
138      * Sets the java path for the target JVMProcess
139      * @param javaPath The value of the path to execute 'java' command
140      */

141     public void setJavaPath(String JavaDoc javaPath) {
142         checkStarted();
143         jvmProcess.setJavaPath(javaPath);
144     }
145
146     /** Returns the boot classpath of the target JVMProcess
147      * @return String the boot classpath of the java command
148      */

149     public String JavaDoc getBootClasspath() {
150         checkStarted();
151         return jvmProcess.getBootClasspath();
152     }
153
154     /**
155      * Sets the boot classpath for the target JVMProcess
156      * @param bootClasspath The boot classpath of the java command
157      */

158     public void setBootClasspath(String JavaDoc bootClasspath) {
159         checkStarted();
160         jvmProcess.setBootClasspath(bootClasspath);
161     }
162
163     /**
164      * Returns the location (path) to the policy file for the target JVMProcess
165      * @return String The path to the policy file
166      */

167     public String JavaDoc getPolicyFile() {
168         return jvmProcess.getPolicyFile();
169     }
170
171     /**
172      * Sets the location of the policy file for the target JVMProcess
173      * @param policyFilePath The value of the path to the policy file
174      */

175     public void setPolicyFile(String JavaDoc policyFile) {
176         checkStarted();
177         jvmProcess.setPolicyFile(policyFile);
178     }
179
180     public String JavaDoc getLog4jFile() {
181         return jvmProcess.getLog4jFile();
182     }
183
184     public void setLog4jFile(String JavaDoc log4jFile) {
185         checkStarted();
186         jvmProcess.setLog4jFile(log4jFile);
187     }
188
189     /**
190      * Returns the class name that the target JVMProcess is about to start
191      * @return String The value of the class that the target JVMProcess is going to start
192      */

193     public String JavaDoc getClassname() {
194         return jvmProcess.getClassname();
195     }
196
197     /**
198      * Sets the value of the class to start for the target JVMProcess
199      * @param classname The name of the class to start
200      */

201     public void setClassname(String JavaDoc classname) {
202         checkStarted();
203         jvmProcess.setClassname(classname);
204     }
205
206     /**
207      * Returns parameters associated to the class that the target JVMProcess is going to start
208      * @return String The value of the parameters of the class
209      */

210     public String JavaDoc getParameters() {
211         return jvmProcess.getParameters();
212     }
213
214     /**
215      * Sets the parameters of the class to start with the given value for the target JVMProcess
216      * @param parameters Paramaters to be given in order to start the class
217      */

218     public void setParameters(String JavaDoc parameters) {
219         checkStarted();
220         jvmProcess.setParameters(parameters);
221     }
222
223     /**
224      * Sets the parameters of the jvm to start with the given parameters for the target JVMProcess
225      * @param parameters Paramaters to be given in order to start the jvm
226      */

227     public void setJvmOptions(String JavaDoc parameters) {
228         jvmProcess.setJvmOptions(parameters);
229     }
230
231     //
232
// -- PROTECTED METHODS -----------------------------------------------
233
//
234
//
235
// -- PRIVATE METHODS -----------------------------------------------
236
//
237
}
238
Popular Tags