KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > Stop


1 /*
2  * Copyright (c) 2005 Your Corporation. All Rights Reserved.
3  */

4
5 package org.jfox.ioc;
6
7 import java.net.URLConnection JavaDoc;
8 import java.net.URL JavaDoc;
9
10 /**
11  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
12  */

13
14 public class Stop {
15
16     private static String JavaDoc protocol = "http";
17     private static String JavaDoc port = "8080";
18     private static String JavaDoc host = "localhost";
19     private static String JavaDoc servletUrl = "/console/servlet/org.jfox.ioc.management.http.InvokeServlet?componentname=org.jfox.ioc.common.ShutdownHook&operHashCode=-1250380938475170858";
20
21     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
22         System.out.println("usage: stop [server]");
23         if(args == null || args.length == 0) {
24             System.out.println("default stop jfoxco ioc kernel locahost!");
25         }
26         else {
27             host = args[0];
28             System.out.println("stop jfoxco ioc kernel " + host + "!");
29         }
30
31         String JavaDoc _url = protocol + "://" + host + ":" + port + "/" + servletUrl;
32
33         URL JavaDoc url = new URL JavaDoc(_url);
34
35         URLConnection JavaDoc conn = url.openConnection();
36         conn.setDoInput(true);
37         try {
38             conn.connect();
39             
40         }
41         catch(Exception JavaDoc e) {
42             System.out.println("cannot connect server " + host + ".");
43             System.exit(0);
44         }
45         try {
46
47             conn.getContent();
48         }
49         catch(Exception JavaDoc e) {
50 // e.printStackTrace();
51
}
52
53         System.out.println("stop " + host + " successfully.");
54
55     }
56 }
57
Popular Tags