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: * @(#)SlowEngine.java
25: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
26: *
27: * END_HEADER - DO NOT EDIT
28: */
29: package restart;
30:
31: import java.util.logging.Logger;
32: import javax.xml.namespace.QName;
33:
34: /**
35: * This engine is used to test framework restart processing. The init()
36: * method of ServiceUnitManager sleeps for a bit before activating
37: * an endpoint. This should not result in endpoint resolution errors from
38: * client components, since all service units should init() before any are
39: * started.
40: *
41: * @author Sun Microsystems, Inc.
42: */
43: public class SlowEngine extends BaseComponent {
44: /** How long we sleep in init() */
45: private static final int SLEEP_TIMER = 10000;
46:
47: /** Create a new instance of FastBinding */
48: public SlowEngine() {
49: mComponentName = "test-slow-engine";
50: }
51:
52: /**
53: * Initialize the deployment.
54: * @param serviceUnitName the name of the Service Unit being initialized.
55: * @param serviceUnitRootPath the full path to the Service Unit artifact
56: * root directory.
57: * @throws javax.jbi.management.DeploymentException if the Service Unit is
58: * not deployed, or is in an incorrect state.
59: */
60: @Override
61: public void init(String serviceUnitName, String serviceUnitRootPath)
62: throws javax.jbi.management.DeploymentException {
63: try {
64: mLog.info("Sleeping for " + SLEEP_TIMER
65: + "ms before initializing " + serviceUnitName);
66: Thread.sleep(SLEEP_TIMER);
67: mLog.info("Activating endpoint for " + serviceUnitName);
68: mContext.activateEndpoint(new QName(serviceUnitName),
69: serviceUnitName);
70: } catch (Exception ex) {
71: ex.printStackTrace();
72: throw new javax.jbi.management.DeploymentException(ex
73: .toString());
74: }
75: }
76: }
|