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: * @(#)FastBinding.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: import javax.jbi.servicedesc.ServiceEndpoint;
34: import javax.jbi.messaging.InOnly;
35:
36: /**
37: * This binding is used to test framework restart processing. The start()
38: * method of ServiceUnitManager looks for an endpoint that should have been
39: * activated by SlowEngine. This should not result in an endpoint resolution
40: * errors since all service units should init() before start() is called.
41: *
42: * @author Sun Microsystems, Inc.
43: */
44: public class FastBinding extends BaseComponent {
45: /** Create a new instance of FastBinding */
46: public FastBinding() {
47: mComponentName = "test-fast-binding";
48: }
49:
50: /**
51: * Start the deployment.
52: * @param serviceUnitName the name of the Service Unit being started.
53: * @throws javax.jbi.management.DeploymentException if the Service Unit
54: * is not deployed, or is in an incorrect state.
55: */
56: @Override
57: public void start(String serviceUnitName)
58: throws javax.jbi.management.DeploymentException {
59: mLog.info("FastBinding is looking for an endpoint for service "
60: + serviceUnitName);
61:
62: ServiceEndpoint endpoint = mContext.getEndpoint(new QName(
63: serviceUnitName), serviceUnitName);
64:
65: if (endpoint == null) {
66: throw new javax.jbi.management.DeploymentException(
67: createErrorResult("start",
68: "Failed to locate endpoint for service "
69: + serviceUnitName));
70: }
71:
72: // Try to send an exchange (exposes broken service connections)
73: try {
74: InOnly inOnly = mContext.getDeliveryChannel()
75: .createExchangeFactory().createInOnlyExchange();
76: inOnly.setEndpoint(endpoint);
77: mContext.getDeliveryChannel().send(inOnly);
78: } catch (javax.jbi.messaging.MessagingException msgEx) {
79: throw new javax.jbi.management.DeploymentException(
80: createErrorResult("start", msgEx.toString()));
81: }
82: }
83: }
|