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