1 /*
2 Bloof - visualize the evolution of your software project
3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de>
4 http://bloof.sf.net/
5
6 This file was part of JavaCVS by Nicholas Allen ( nallen@freenet.co.uk ).
7
8 This program is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 $RCSfile: ExternalProcessServerConnection.java,v $
21 Created on $Date: 2003/06/28 06:51:42 $
22 */
23
24 package net.sf.bloof.scm.cvsplugin;
25
26 import java.io.IOException;
27 import java.io.InputStream;
28 import java.io.OutputStream;
29
30 /***
31 * Defines a server connection to the local machine. This is done by executing
32 * the server on the local machine and redirecting the input and output of the server.
33 * @author Nicholas Allen
34 * @author Lukasz Pekacki
35 */
36 public class ExternalProcessServerConnection extends CvsConnection {
37 /***
38 * Creates a local server connection by running the supplied command.
39 * @param aCvsAccess Access to CVS
40 * @throws CvsConnectionException if it does not work
41 */
42 public ExternalProcessServerConnection(CvsAccess aCvsAccess) throws CvsConnectionException {
43 this(aCvsAccess.getLocation(), aCvsAccess.getExternalCommand());
44 }
45 /***
46 * Creates a local server connection by running the supplied command.
47 * @param aLocation Location of the CVS repository root
48 * @param aServerCommand command to be run
49 * @throws CvsConnectionException if it does not work
50 */
51 public ExternalProcessServerConnection(RepositoryLocation aLocation, String aServerCommand)
52 throws CvsConnectionException {
53 super(aLocation);
54 displayStatus("Executing \"" + aServerCommand + "\"");
55
56 try {
57 mProcess = Runtime.getRuntime().exec(aServerCommand);
58 } catch (IOException e) {
59 throw new CvsConnectionException(e);
60 }
61 }
62
63 /***
64 * Closes the connection
65 */
66 public synchronized void close() {
67 if (mProcess != null) {
68 mProcess.destroy();
69 }
70 mProcess = null;
71 }
72 /***
73 * Gets the stream used for displaying error messages. If <code>null</code> then there is not error stream
74 * @return InputStream
75 */
76 public InputStream getErrorStream() {
77 return mProcess.getErrorStream();
78 }
79
80 /***
81 * Gets the input stream from which the client should read server responses from
82 * @return InputStream
83 */
84 public InputStream getInputStream() {
85 return mProcess.getInputStream();
86 }
87
88 /***
89 * Gets the output stream over which the client should send its requests to the server
90 * @return OutputStream
91 */
92 public OutputStream getOutputStream() {
93 return mProcess.getOutputStream();
94 }
95 private Process mProcess;
96
97 }
This page was automatically generated by Maven