01: /*
02: * BEGIN_HEADER - DO NOT EDIT
03: *
04: * The contents of this file are subject to the terms
05: * of the Common Development and Distribution License
06: * (the "License"). You may not use this file except
07: * in compliance with the License.
08: *
09: * You can obtain a copy of the license at
10: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
11: * See the License for the specific language governing
12: * permissions and limitations under the License.
13: *
14: * When distributing Covered Code, include this CDDL
15: * HEADER in each file and include the License file at
16: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
17: * If applicable add the following below this CDDL HEADER,
18: * with the fields enclosed by brackets "[]" replaced with
19: * your own identifying information: Portions Copyright
20: * [year] [name of copyright owner]
21: */
22:
23: /*
24: * @(#)ComponentStartup.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package com.sun.jbi.framework;
30:
31: /**
32: * This class is used to run a thread that performs component-related tasks
33: * at the beginning and end of JBI framework startup. At the beginning of the
34: * startup, a thread is created to run this class with a PREPARE command, which
35: * causes all shared libraries and components to be initialized. At the end of
36: * the startup, a thread is created to run this class with a START command,
37: * which causes all components to be brought to their desired states.
38: *
39: * The reason for operating this way is to prevent the initialization and
40: * startup of shared libraries and components from slowing down the startup of
41: * the appserver itself. This is especially important because the startup time
42: * for components is completely out of the control of JBI other than the timeout
43: * used to prevent a runaway component.
44: *
45: * @author Sun Microsystems, Inc.
46: */
47: public class ComponentStartup implements Runnable {
48: /**
49: * ComponentFramework instance provided by the constructor.
50: */
51: private ComponentFramework mCompFW;
52:
53: /**
54: * Startup command.
55: */
56: private int mCommand;
57:
58: /**
59: * Creates a new instance of ComponentStartup.
60: * @param compFW is the ComponentFramework instance.
61: * @param command is either <code>ComponentFramework.PREPARE</code> or
62: * <code>ComponentFramework.STARTUP</code>.
63: */
64: public ComponentStartup(ComponentFramework compFW, int command) {
65: mCompFW = compFW;
66: mCommand = command;
67: }
68:
69: /**
70: * The run method yields control to allow the appserver thread to run;
71: * when this thread regains control it will call the Component Framework
72: * to do shared library/component initialization and startup processing.
73: */
74: public void run() {
75: Thread.yield();
76: mCompFW.startupAll(mCommand);
77: }
78: }
|