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: * @(#)Engine4Runtime.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.engine4.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 Engine4Runtime 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 Engine4Deployer mDeployer;
070:
071: /**
072: * Logger instance
073: */
074: private Logger mLog = Logger
075: .getLogger("com.sun.jbi.ui.cli.test.engine4");
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.engine4");
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: try {
155: DummyTest obj = (DummyTest) Class.forName(
156: "com.sun.jbi.ui.cli.test.engine4.rt.DummyTest")
157: .newInstance();
158: obj.printMsg();
159: } catch (Exception exp) {
160: throw new JBIException("Can not load DummyTest class");
161: }
162: }
163:
164: /**
165: * Stop the Business Process Engine.
166: * @throws JBIException if an error occurs
167: */
168: public void stop() throws JBIException {
169: mLog.info("Engine " + mComponentId + " stopped");
170: }
171:
172: /**
173: * Shut down the Business Process Engine.
174: * @throws JBIException if an error occurs
175: */
176: public void shutDown() throws JBIException {
177: mLog.info("Engine " + mComponentId + " shut down");
178: }
179:
180: /**
181: * fix it
182: * @return fix it
183: */
184: public Logger getLogger() {
185: return this .mLog;
186: }
187:
188: /**
189: * fix it
190: * @return fix it
191: */
192: public String getId() {
193: return this .mComponentId;
194: }
195:
196: /**
197: * fix it
198: * @return fix it
199: */
200: public ComponentContext getContext() {
201: return this .mContext;
202: }
203:
204: /**
205: * fix it
206: * @return fix it
207: */
208: public ManagementMessageBuilder getMgmtMsgBuilder() {
209: return this .mMgmtMsgBuilder;
210: }
211:
212: /**
213: * fix it
214: * @throws JBIException fix it
215: */
216: public void createDeployer() throws JBIException {
217: try {
218: if (this .mDeployer == null) {
219: this .mDeployer = new Engine4Deployer(this );
220: }
221: } catch (Exception e) {
222: throw new JBIException(
223: "cli Test Engine4 Deployer Creation Failed", e);
224: }
225: }
226:
227: /** This method is called by JBI to check if this component, in the role of
228: * provider of the service indicated by the given exchange, can actually
229: * perform the operation desired.
230: */
231: public boolean isExchangeWithConsumerOkay(
232: javax.jbi.servicedesc.ServiceEndpoint endpoint,
233: javax.jbi.messaging.MessageExchange exchange) {
234: return true;
235: }
236:
237: /** This method is called by JBI to check if this component, in the role of
238: * consumer of the service indicated by the given exchange, can actually
239: * interact with the the provider completely.
240: */
241: public boolean isExchangeWithProviderOkay(
242: javax.jbi.servicedesc.ServiceEndpoint endpoint,
243: javax.jbi.messaging.MessageExchange exchange) {
244: return true;
245: }
246:
247: /**
248: * Resolve the given endpoint reference, given the capabilities of the
249: * given consumer. This is called by JBI when it is attempting to resolve
250: * the given endpoint reference on behalf of a component.
251: * @param epr the endpoint reference, in some XML dialect understood by the
252: * appropriate component (usually a Binding Component).
253: * @return the service endpoint for the endpoint reference;
254: * <code>null</code> if the endpoint reference cannot be resolved.
255: */
256: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
257: org.w3c.dom.DocumentFragment epr) {
258: return null;
259: }
260: }
|