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: * @(#)Binding1Runtime.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.cli.test.binding1.rt;
030:
031: import com.sun.jbi.management.ManagementMessageBuilder;
032: import com.sun.jbi.ui.cli.test.binding1.sns1impl.SNS1DocImpl;
033: import com.sun.jbi.ui.cli.test.sns1.SNS1Doc;
034: import java.util.logging.Logger;
035: import javax.jbi.JBIException;
036: import javax.jbi.component.Component;
037: import javax.jbi.component.ComponentContext;
038: import javax.jbi.component.ComponentLifeCycle;
039: import javax.jbi.component.ServiceUnitManager;
040: import javax.jbi.management.MBeanNames;
041: import javax.jbi.servicedesc.ServiceEndpoint;
042: import javax.management.MBeanServer;
043: import javax.management.ObjectName;
044: import javax.management.StandardMBean;
045:
046: /**
047: * This is an implementation of a Binding life cycle which starts a
048: * thread. The thread is the main implementation of the binding.
049: *
050: * @author Sun Microsystems, Inc.
051: */
052: public class Binding1Runtime implements Component, ComponentLifeCycle {
053:
054: /**
055: * Logger instance
056: */
057: private Logger mLog = Logger
058: .getLogger("com.sun.jbi.ui.cli.test.binding1");
059: /**
060: * Actual binding implementation
061: */
062: /**
063: * Local copy of the component ID
064: */
065: private String mComponentId;
066: /**
067: * fix it
068: */
069: private ComponentContext mContext;
070: /**
071: * fix it
072: */
073: private ManagementMessageBuilder mMgmtMsgBuilder;
074:
075: /**
076: * fix it
077: */
078: private Binding1Deployer mDeployer;
079:
080: /**
081: * Get the required life cycle control implementation for this component.
082: * @return the life cycle control implementation for this component.
083: */
084: public ComponentLifeCycle getLifeCycle() {
085: return this ;
086: }
087:
088: /**
089: * Get the Service Unit manager for this component. If this component
090: * does not support deployments, return <code>null</code>.
091: * @return the Service Unit manager for this component, or <code>null</code>
092: * if there is none.
093: */
094: public ServiceUnitManager getServiceUnitManager() {
095: return mDeployer;
096: }
097:
098: /**
099: * Resolve descriptor details for the specified reference, which is for a
100: * service provided by this component.
101: * @param ref the endpoint reference to be resolved.
102: * @return the description for the specified reference.
103: */
104: public org.w3c.dom.Document getServiceDescription(
105: ServiceEndpoint ref) {
106: return null;
107: }
108:
109: /**
110: * Initialize the Binding Component.
111: * @param context the JBI binding environment context created
112: * by the JBI framework
113: * @throws JBIException if an error occurs
114: */
115: public void init(ComponentContext context) throws JBIException {
116:
117: if (context == null) {
118: throw new JBIException("Null argument received for "
119: + "ComponentContext");
120: }
121:
122: this .mLog = Logger
123: .getLogger("com.sun.jbi.ui.cli.test.binding1");
124:
125: this .mContext = context;
126: this .mComponentId = context.getComponentName();
127:
128: try {
129: this .mMgmtMsgBuilder = ((com.sun.jbi.component.ComponentContext) mContext)
130: .getManagementMessageFactory()
131: .newBuildManagementMessage();
132: } catch (Exception e) {
133: throw new JBIException("Unable to create Mmgt Msg Builder",
134: e);
135: }
136:
137: createDeployer();
138:
139: mLog.info("Binding " + mComponentId + " initialized");
140:
141: }
142:
143: /**
144: * Get the JMX ObjectName for any additional MBean for this BC. If there
145: * is none, return null.
146: * @return ObjectName the JMX object name of the additional MBean or null
147: * if there is no additional MBean.
148: */
149: public ObjectName getExtensionMBeanName() {
150: return null;
151: }
152:
153: /**
154: * Start the Binding Component.
155: * @throws JBIException if an error occurs
156: */
157: public void start() throws JBIException {
158:
159: // load the sns interface implementation here.
160: try {
161: SNS1Doc sns1Doc = new SNS1DocImpl();
162: mLog.info(sns1Doc.getContentAsString());
163: } catch (Exception ex) {
164: mLog.info("SNS Access Error : " + ex.getMessage());
165: }
166:
167: mLog.info("Binding " + mComponentId + " started");
168: }
169:
170: /**
171: * Stop the Binding Component.
172: * @throws JBIException if an error occurs
173: */
174: public void stop() throws JBIException {
175: mLog.info("Binding " + mComponentId + " stopped");
176: }
177:
178: /**
179: * Shut down the Binding Component.
180: * @throws JBIException if an error occurs
181: */
182: public void shutDown() throws JBIException {
183: mLog.info("Binding " + mComponentId + " shut down");
184: }
185:
186: /**
187: * fix it
188: * @return fix it
189: */
190: public Logger getLogger() {
191: return this .mLog;
192: }
193:
194: /**
195: * fix it
196: * @return fix it
197: */
198: public String getId() {
199: return this .mComponentId;
200: }
201:
202: /**
203: * fix it
204: * @return fix it
205: */
206: public ComponentContext getContext() {
207: return this .mContext;
208: }
209:
210: /**
211: * fix it
212: * @return fix it
213: */
214: public ManagementMessageBuilder getMgmtMsgBuilder() {
215: return this .mMgmtMsgBuilder;
216: }
217:
218: /**
219: * fix it
220: * @throws JBIException fix it
221: */
222: public void createDeployer() throws JBIException {
223: try {
224: if (this .mDeployer == null) {
225: this .mDeployer = new Binding1Deployer(this );
226: }
227: } catch (Exception e) {
228: throw new JBIException(
229: "cli Test Binding1 Deployer Creation Failed", e);
230: }
231: }
232:
233: /** This method is called by JBI to check if this component, in the role of
234: * provider of the service indicated by the given exchange, can actually
235: * perform the operation desired.
236: */
237: public boolean isExchangeWithConsumerOkay(
238: javax.jbi.servicedesc.ServiceEndpoint endpoint,
239: javax.jbi.messaging.MessageExchange exchange) {
240: return true;
241: }
242:
243: /** This method is called by JBI to check if this component, in the role of
244: * consumer of the service indicated by the given exchange, can actually
245: * interact with the the provider completely.
246: */
247: public boolean isExchangeWithProviderOkay(
248: javax.jbi.servicedesc.ServiceEndpoint endpoint,
249: javax.jbi.messaging.MessageExchange exchange) {
250: return true;
251: }
252:
253: /**
254: * Resolve the given endpoint reference, given the capabilities of the
255: * given consumer. This is called by JBI when it is attempting to resolve
256: * the given endpoint reference on behalf of a component.
257: * @param epr the endpoint reference, in some XML dialect understood by the
258: * appropriate component (usually a Binding Component).
259: * @return the service endpoint for the endpoint reference;
260: * <code>null</code> if the endpoint reference cannot be resolved.
261: */
262: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
263: org.w3c.dom.DocumentFragment epr) {
264: return null;
265: }
266: }
|