KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > remoting > Launcher


1 package hudson.remoting;
2
3 import java.io.OutputStream JavaDoc;
4 import java.io.IOException JavaDoc;
5 import java.io.InputStream JavaDoc;
6 import java.util.concurrent.ExecutorService JavaDoc;
7 import java.util.concurrent.Executors JavaDoc;
8
9 /**
10  * Entry point for running a {@link Channel} that uses stdin/stdout.
11  *
12  * <p>
13  * This can be used as the main class for launching a channel on
14  * a separate JVM.
15  *
16  * @author Kohsuke Kawaguchi
17  */

18 public class Launcher {
19     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
20         // this will prevent programs from accidentally writing to System.out
21
// and messing up the stream.
22
OutputStream JavaDoc os = System.out;
23         System.setOut(System.err);
24         main(System.in,os);
25         System.exit(0);
26     }
27
28     public static void main(InputStream JavaDoc is, OutputStream JavaDoc os) throws IOException JavaDoc, InterruptedException JavaDoc {
29         ExecutorService JavaDoc executor = Executors.newCachedThreadPool();
30         Channel channel = new Channel("channel", executor, is, os);
31         System.err.println("channel started");
32         channel.join();
33         System.err.println("channel stopped");
34     }
35 }
36
Popular Tags