KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > base > splash > SplashLoader


1 /*
2  * $Id: SplashLoader.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.base.splash;
26
27 import java.awt.EventQueue JavaDoc;
28
29 import org.ofbiz.base.start.Start;
30 import org.ofbiz.base.start.StartupException;
31 import org.ofbiz.base.start.StartupLoader;
32
33 /**
34  *
35  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
36  * @version $Rev: 5462 $
37  * @since 3.3
38  */

39 public class SplashLoader implements StartupLoader, Runnable JavaDoc {
40
41     public static final String JavaDoc module = SplashLoader.class.getName();
42     private static SplashScreen screen = null;
43     private Start.Config config = null;
44
45     /**
46      * Load a startup class
47      *
48      * @param config Startup config
49      * @param args Input arguments
50      * @throws org.ofbiz.base.start.StartupException
51      *
52      */

53     public void load(Start.Config config, String JavaDoc args[]) throws StartupException {
54         this.config = config;
55
56         Thread JavaDoc t = new Thread JavaDoc(this);
57         t.setName(this.toString());
58         t.setDaemon(false);
59         t.run();
60     }
61
62     /**
63      * Start the startup class
64      *
65      * @throws org.ofbiz.base.start.StartupException
66      *
67      */

68     public void start() throws StartupException {
69     }
70
71     /**
72      * Stop the container
73      *
74      * @throws org.ofbiz.base.start.StartupException
75      *
76      */

77     public void unload() throws StartupException {
78         SplashLoader.close();
79     }
80
81     public static SplashScreen getSplashScreen() {
82         return screen;
83     }
84
85     public static void close() {
86         if (screen != null) {
87             EventQueue.invokeLater(new SplashScreenCloser());
88         }
89     }
90
91     public void run() {
92         if (config.splashLogo != null) {
93             screen = new SplashScreen(config.splashLogo);
94             screen.splash();
95         }
96     }
97
98     private static final class SplashScreenCloser implements Runnable JavaDoc {
99         public void run() {
100             screen.close();
101             screen = null;
102         }
103     }
104 }
105
Popular Tags