01: package com.xoetrope.deploy;
02:
03: import java.net.URL; //import javax.jnlp.DownloadService;
04: //import javax.jnlp.ServiceManager;
05: //import javax.jnlp.UnavailableServiceException;
06:
07: import java.awt.event.WindowEvent;
08: import javax.swing.JApplet;
09: import javax.swing.JFrame;
10:
11: /**
12: * A class to clear out the jar files from the JNLP cache
13: *
14: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
15: * the GNU Public License (GPL), please see license.txt for more details. If
16: * you make commercial use of this software you must purchase a commercial
17: * license from Xoetrope.</p>
18: * <p> $Revision: 1.4 $</p>
19: */
20: public class XLauncher extends JApplet {
21: private static XLauncher applet;
22:
23: private XLauncher(String[] args) {
24: try {
25: Runtime.getRuntime().addShutdownHook(new MyShutdownHook());
26: } catch (Exception ex) {
27: ex.printStackTrace();
28: }
29: }
30:
31: private void doCleanup() {
32: // DownloadService ds;
33: //
34: // try {
35: // ds = ( DownloadService )ServiceManager.lookup( "javax.jnlp.DownloadService" );
36: // }
37: // catch ( UnavailableServiceException e ) {
38: // ds = null;
39: // }
40: //
41: // if ( ds != null ) {
42: // try {
43: // // determine if a particular resource is cached
44: // URL url = new URL( "http://www.xoetrope.com/jars/carousel.asp" );
45: // boolean cached = ds.isResourceCached( url, "1.0" );
46: // // remove the resource from the cache
47: // if ( cached ) {
48: // ds.removeResource( url, "1.0" );
49: // }
50: // // reload the resource into the cache
51: //// DownloadServiceListener dsl = ds.getDefaultProgressWindow();
52: //// ds.loadResource( url, "1.0", dsl );
53: // }
54: // catch ( Exception e ) {
55: // e.printStackTrace();
56: // }
57: // }
58: }
59:
60: /**
61: * Prepare for shutdown by saving the data.
62: */
63: public static void shutdown() {
64: applet.doCleanup();
65: }
66:
67: public void destroy() {
68: doCleanup();
69: }
70:
71: public void stop() {
72: doCleanup();
73: }
74:
75: /**
76: * Exit the application
77: */
78: public void windowClosing(WindowEvent e) {
79: shutdown();
80: System.exit(0);
81: }
82:
83: class MyShutdownHook extends Thread {
84: public void run() {
85: shutdown();
86: }
87: }
88:
89: /**
90: * main method to be invoked as an application
91: */
92: public static void main(String args[]) {
93: JFrame frame = new JFrame();
94: applet = new XLauncher(args);
95: frame.add(applet);
96: }
97: }
|