001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)Binding2Runtime.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.ui.ant.test.binding2.rt;
030:
031: import com.sun.jbi.management.ManagementMessageBuilder;
032: import java.util.logging.Logger;
033: import javax.jbi.JBIException;
034: import javax.jbi.component.Component;
035: import javax.jbi.component.ComponentContext;
036: import javax.jbi.component.ComponentLifeCycle;
037: import javax.jbi.component.ServiceUnitManager;
038: import javax.jbi.management.MBeanNames;
039: import javax.jbi.servicedesc.ServiceEndpoint;
040: import javax.management.MBeanServer;
041: import javax.management.ObjectName;
042: import javax.management.StandardMBean;
043:
044: /**
045: * This is an implementation of a Binding life cycle which starts a
046: * thread. The thread is the main implementation of the binding.
047: *
048: * @author Sun Microsystems, Inc.
049: */
050: public class Binding2Runtime implements Component, ComponentLifeCycle {
051:
052: /**
053: * Logger instance
054: */
055: private Logger mLog = Logger
056: .getLogger("com.sun.jbi.ui.ant.test.binding2");
057: /**
058: * Actual binding implementation
059: */
060: /**
061: * Local copy of the component ID
062: */
063: private String mComponentId;
064: /**
065: * fix it
066: */
067: private ComponentContext mContext;
068: /**
069: * fix it
070: */
071: private ManagementMessageBuilder mMgmtMsgBuilder;
072:
073: /**
074: * fix it
075: */
076: private Binding2Deployer mDeployer;
077:
078: /**
079: * Get the required life cycle control implementation for this component.
080: * @return the life cycle control implementation for this component.
081: */
082: public ComponentLifeCycle getLifeCycle() {
083: return this ;
084: }
085:
086: /**
087: * Get the Service Unit manager for this component. If this component
088: * does not support deployments, return <code>null</code>.
089: * @return the Service Unit manager for this component, or <code>null</code>
090: * if there is none.
091: */
092: public ServiceUnitManager getServiceUnitManager() {
093: return mDeployer;
094: }
095:
096: /**
097: * Resolve descriptor details for the specified reference, which is for a
098: * service provided by this component.
099: * @param ref the endpoint reference to be resolved.
100: * @return the description for the specified reference.
101: */
102: public org.w3c.dom.Document getServiceDescription(
103: ServiceEndpoint ref) {
104: return null;
105: }
106:
107: /**
108: * Initialize the Binding Component.
109: * @param context the JBI binding environment context created
110: * by the JBI framework
111: * @throws JBIException if an error occurs
112: */
113: public void init(ComponentContext context) throws JBIException {
114:
115: if (context == null) {
116: throw new JBIException("Null argument received for "
117: + "ComponentContext");
118: }
119:
120: this .mLog = Logger
121: .getLogger("com.sun.jbi.ui.ant.test.binding2");
122:
123: this .mContext = context;
124: this .mComponentId = context.getComponentName();
125:
126: try {
127: this .mMgmtMsgBuilder = ((com.sun.jbi.component.ComponentContext) mContext)
128: .getManagementMessageFactory()
129: .newBuildManagementMessage();
130: } catch (Exception e) {
131: throw new JBIException("Unable to create Mmgt Msg Builder",
132: e);
133: }
134:
135: createDeployer();
136:
137: mLog.info("Binding " + mComponentId + " initialized");
138:
139: }
140:
141: /**
142: * Get the JMX ObjectName for any additional MBean for this BC. If there
143: * is none, return null.
144: * @return ObjectName the JMX object name of the additional MBean or null
145: * if there is no additional MBean.
146: */
147: public ObjectName getExtensionMBeanName() {
148: return null;
149: }
150:
151: /**
152: * Start the Binding Component.
153: * @throws JBIException if an error occurs
154: */
155: public void start() throws JBIException {
156: mLog.info("Binding " + mComponentId + " started");
157: }
158:
159: /**
160: * Stop the Binding Component.
161: * @throws JBIException if an error occurs
162: */
163: public void stop() throws JBIException {
164: mLog.info("Binding " + mComponentId + " stopped");
165: }
166:
167: /**
168: * Shut down the Binding Component.
169: * @throws JBIException if an error occurs
170: */
171: public void shutDown() throws JBIException {
172: mLog.info("Binding " + mComponentId + " shut down");
173: }
174:
175: /**
176: * fix it
177: * @return fix it
178: */
179: public Logger getLogger() {
180: return this .mLog;
181: }
182:
183: /**
184: * fix it
185: * @return fix it
186: */
187: public String getId() {
188: return this .mComponentId;
189: }
190:
191: /**
192: * fix it
193: * @return fix it
194: */
195: public ComponentContext getContext() {
196: return this .mContext;
197: }
198:
199: /**
200: * fix it
201: * @return fix it
202: */
203: public ManagementMessageBuilder getMgmtMsgBuilder() {
204: return this .mMgmtMsgBuilder;
205: }
206:
207: /**
208: * fix it
209: * @throws JBIException fix it
210: */
211: public void createDeployer() throws JBIException {
212: try {
213: if (this .mDeployer == null) {
214: this .mDeployer = new Binding2Deployer(this );
215: }
216: } catch (Exception e) {
217: throw new JBIException(
218: "Ant Test Binding2 Deployer Creation Failed", e);
219: }
220: }
221:
222: /** This method is called by JBI to check if this component, in the role of
223: * provider of the service indicated by the given exchange, can actually
224: * perform the operation desired.
225: */
226: public boolean isExchangeWithConsumerOkay(
227: javax.jbi.servicedesc.ServiceEndpoint endpoint,
228: javax.jbi.messaging.MessageExchange exchange) {
229: return true;
230: }
231:
232: /** This method is called by JBI to check if this component, in the role of
233: * consumer of the service indicated by the given exchange, can actually
234: * interact with the the provider completely.
235: */
236: public boolean isExchangeWithProviderOkay(
237: javax.jbi.servicedesc.ServiceEndpoint endpoint,
238: javax.jbi.messaging.MessageExchange exchange) {
239: return true;
240: }
241:
242: /**
243: * Resolve the given endpoint reference, given the capabilities of the
244: * given consumer. This is called by JBI when it is attempting to resolve
245: * the given endpoint reference on behalf of a component.
246: * @param epr the endpoint reference, in some XML dialect understood by the
247: * appropriate component (usually a Binding Component).
248: * @return the service endpoint for the endpoint reference;
249: * <code>null</code> if the endpoint reference cannot be resolved.
250: */
251: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
252: org.w3c.dom.DocumentFragment epr) {
253: return null;
254: }
255: }
|