01: /*
02: * @(#)IXCMain.java 1.5 03/01/16
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package IXCDemo;
29:
30: import java.io.IOException;
31: import com.sun.xlet.XletLifecycleHandler;
32: import com.sun.xlet.XletManager;
33:
34: /**
35: * Main launching class. This is a minimalistic test that hard-codes
36: * the launching of two Xlets. It then waits 20 seconds, destroys the
37: * client, waits 5 seconds, destroys the server, and terminates.
38: */
39:
40: public class IXCMain {
41: private static void sleep(long delay) {
42: long goal = System.currentTimeMillis() + delay;
43: while (delay > 0) {
44: try {
45: Thread.sleep(1000);
46: } catch (InterruptedException ignored) {
47: }
48: delay = goal - System.currentTimeMillis();
49: }
50: }
51:
52: public static void main(String args[]) {
53: XletLifecycleHandler client = null;
54: XletLifecycleHandler server = null;
55: try {
56: String classpath = System.getProperty("java.class.path",
57: ".");
58: // XletClassLoader does not see the classpath anymore
59: String path[] = { classpath };
60: //String path2[] = {"IXCDemo/ixcXlets/serverXlet", classpath};
61: client = XletManager.createXlet(
62: "IXCDemo.ixcXlets.clientXlet.PlaneClient", path,
63: null);
64: System.out.println("Manager: client created");
65: server = XletManager.createXlet(
66: "IXCDemo.ixcXlets.serverXlet.PlaneServer", path,
67: null);
68: System.out.println("Manager: server created");
69: } catch (IOException ex) {
70: ex.printStackTrace();
71: System.exit(1);
72: }
73: client.postInitXlet();
74: server.postInitXlet();
75: client.postStartXlet();
76: sleep(1000);
77: server.postStartXlet();
78: sleep(20000);
79: client.postDestroyXlet(true);
80: System.out.println("Manager: client destroyed");
81: client = null;
82: sleep(5000);
83: server.postDestroyXlet(true);
84: System.out.println("Manager: server destroyed");
85: System.out.println("Manager exiting");
86: server = null;
87: }
88: }
|