KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > process > UniversalProcess


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;
32
33 import org.apache.log4j.Logger;
34
35 /**
36  * A class implementing this interface is able to start a process based on a command
37  * to execute. The command is built from arbitrary parameters (up to the implementation) and
38  * from the environment.
39  * The external process can be customized up to the moment it is started. Once started the call
40  * to methods to set the command throw an exception.
41  */

42 public interface UniversalProcess extends java.io.Serializable JavaDoc {
43         
44         
45     static Logger logger = Logger.getLogger(UniversalProcess.class.getName());
46     
47   /**
48    * Returns the current environment for this process. Each
49    * cell of the array contains the definition of one variable in a
50    * syntax that is system dependant.
51    * @return an array of string containing all environment variables or
52    * null if the environment is empty
53    */

54   public String JavaDoc[] getEnvironment();
55
56
57   /**
58    * Set the environment for this process. Each
59    * cell of the array contains the definition of one variable in a
60    * syntax that is system dependant.
61    * @param an array of string containing all environment variables or
62    * null if the environment is empty
63    */

64   public void setEnvironment(String JavaDoc[] environment);
65
66
67   /**
68    * Return the hostname target of this process.
69    * @return the hostname target of this process.
70    */

71   public String JavaDoc getHostname();
72
73
74   /**
75    * Set the hostname target of this process. By default the target host
76    * is the localhost.
77    * @param the target hostname.
78    */

79   public void setHostname(String JavaDoc hostname);
80   
81  
82   /**
83    * Return the username that will be used to run the command.
84    * @return the username that will be used to run the command.
85    */

86   public String JavaDoc getUsername();
87   
88   
89   /**
90    * Set the username that will be used to run the command.
91    * By default the current username owner of the JVM process is used.
92    * @param the target username or null to use the default one.
93    */

94   public void setUsername(String JavaDoc username);
95   
96
97   /**
98    * Returns the command that will be or has been execute by the process.
99    * @return the command of this external process
100    */

101   public String JavaDoc getCommand();
102
103
104   /**
105    * Starts the process by executing the command. The process can only
106    * be started once.
107    * @exception java.io.IOException if the process cannot be started.
108    */

109   public void startProcess() throws java.io.IOException JavaDoc;
110   
111   
112   /**
113    * Stops the running process. If called on a stopped process this
114    * method has no effect.
115    */

116   public void stopProcess();
117
118     
119     /**
120      * Causes the current thread to wait until this Process has terminated.
121      * This method returns immediately if the subprocess has already terminated.
122      * If the subprocess has not yet terminated, the calling thread will be blocked until the subprocess exits.
123      * @return int exit value
124      * @exception java.lang.InterruptedException if the current thread is interrupted by another thread while it is waiting.
125      * Then the wait is ended and an InterruptedException is thrown
126      */

127     public int waitFor() throws InterruptedException JavaDoc;
128     
129     
130   /**
131    * Returns true if and only if this process has been started. A process that has been
132    * started can be finished or running.
133    */

134   public boolean isStarted();
135
136
137   /**
138    * Returns true if and only if this process has been stopped. A process that has been
139    * stopped has been started and is no more running.
140    */

141   public boolean isFinished();
142   
143   // SECURITY
144
public void setCertificateLocation(String JavaDoc file);
145
146   public String JavaDoc getCertificateLocation();
147
148   public void setPrivateKeyLocation(String JavaDoc privatekey);
149
150   public String JavaDoc getPrivateKeyLocation();
151
152   public void setSecurityFile(String JavaDoc privatekey);
153
154   public String JavaDoc getSecurityFile();
155   
156 }
157
Popular Tags