KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > oscache > web > CheckDeployment


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.oscache.web;
6
7 import java.io.FileNotFoundException JavaDoc;
8 import java.io.IOException JavaDoc;
9
10 import java.net.ConnectException JavaDoc;
11 import java.net.URL JavaDoc;
12 import java.net.URLConnection JavaDoc;
13
14 /**
15  * User: hani
16  * Date: Jun 12, 2003
17  * Time: 3:34:20 PM
18  */

19 public class CheckDeployment {
20     public static void main(String JavaDoc[] args) {
21         if (args.length == 0) {
22             throw new IllegalArgumentException JavaDoc("No url specified to check");
23         }
24
25         try {
26             if (!args[0].endsWith("/")) {
27                 args[0] = args[0] + "/";
28             }
29
30             URL JavaDoc url = new URL JavaDoc(args[0] + "oscache.txt");
31             URLConnection JavaDoc c = url.openConnection();
32             c.getInputStream();
33             System.exit(0);
34         } catch (java.net.MalformedURLException JavaDoc e) {
35             System.out.println("Invalid url for oscache webapp:" + args[0]);
36         } catch (ConnectException JavaDoc ex) {
37             System.out.println("Error connecting to server at '" + args[0] + "', ensure that the webserver for the oscache example application is running");
38         } catch (FileNotFoundException JavaDoc e) {
39             System.out.println("Error connecting to webapp at '" + args[0] + "', ensure that the example-war app is deployed correctly at the specified url");
40         } catch (IOException JavaDoc e) {
41             System.out.println("Error connecting to webapp at '" + args[0] + "', ensure that the example-war app is deployed correctly at the specified url");
42         }
43
44         System.exit(1);
45     }
46 }
47
Popular Tags