01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.base.splash;
19:
20: import java.awt.EventQueue;
21:
22: import org.ofbiz.base.start.Start;
23: import org.ofbiz.base.start.StartupException;
24: import org.ofbiz.base.start.StartupLoader;
25:
26: public class SplashLoader implements StartupLoader, Runnable {
27:
28: public static final String module = SplashLoader.class.getName();
29: private static SplashScreen screen = null;
30: private Start.Config config = null;
31:
32: /**
33: * Load a startup class
34: *
35: * @param config Startup config
36: * @param args Input arguments
37: * @throws org.ofbiz.base.start.StartupException
38: *
39: */
40: public void load(Start.Config config, String args[])
41: throws StartupException {
42: this .config = config;
43:
44: Thread t = new Thread(this );
45: t.setName(this .toString());
46: t.setDaemon(false);
47: t.run();
48: }
49:
50: /**
51: * Start the startup class
52: *
53: * @throws org.ofbiz.base.start.StartupException
54: *
55: */
56: public void start() throws StartupException {
57: }
58:
59: /**
60: * Stop the container
61: *
62: * @throws org.ofbiz.base.start.StartupException
63: *
64: */
65: public void unload() throws StartupException {
66: SplashLoader.close();
67: }
68:
69: public static SplashScreen getSplashScreen() {
70: return screen;
71: }
72:
73: public static void close() {
74: if (screen != null) {
75: EventQueue.invokeLater(new SplashScreenCloser());
76: }
77: }
78:
79: public void run() {
80: if (config.splashLogo != null) {
81: screen = new SplashScreen(config.splashLogo);
82: screen.splash();
83: }
84: }
85:
86: private static final class SplashScreenCloser implements Runnable {
87: public void run() {
88: screen.close();
89: screen = null;
90: }
91: }
92: }
|