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