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: * @(#)SharedNamespaceTestEngine.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package classloaderregresstests.sharedlibtest.engine.rt;
030:
031: import javax.jbi.component.ServiceUnitManager;
032: import javax.jbi.component.ComponentLifeCycle;
033: import java.util.logging.*;
034: import javax.management.ObjectName;
035: import javax.jbi.JBIException;
036: import java.io.IOException;
037: import classloaderregresstests.util.*;
038: import library1.QuoteEngine;
039:
040: /**
041: * This is an implementation of a Business Process Engine used to
042: * test the various use cases of the classloader design
043: * In particular it tests if a private library specified in the "componentClassPath"
044: * element of jbi.xml
045: *
046: * @author Sun Microsystems, Inc.
047: */
048: public class SharedNamespaceTestEngine implements
049: javax.jbi.component.ComponentLifeCycle,
050: javax.jbi.component.Component {
051: /**
052: * Local copy of the component ID
053: */
054: private String mComponentName;
055:
056: /**
057: * Local handle to the EnvironmentContext
058: */
059: private javax.jbi.component.ComponentContext mContext;
060:
061: /**
062: * Logger instance
063: */
064: private String logStr = "classloaderregresstests.sharedlibtest.engine.rt";
065: private Logger mLog = Logger.getLogger(logStr);
066: private int msgCount = 0;
067:
068: /**
069: * Initialize the Business Process Engine.
070: * @param context the JBI environment context created
071: * by the JBI framework
072: * @throws JBIException if an error occurs
073: */
074: public void init(javax.jbi.component.ComponentContext context)
075: throws javax.jbi.JBIException {
076: if (null != context) {
077: mComponentName = context.getComponentName();
078:
079: // setup the logger
080: try {
081: Utils.setUpLogger(mLog, new FileHandler(Utils
082: .getLogLocation(logStr)),
083: new SimpleFormatter(), Level.INFO);
084: mLog.info("SNS User Engine " + mComponentName
085: + " initialized");
086: } catch (IOException ioe) {
087: System.out.println("Could not setup logger");
088: }
089: } else {
090: throw new javax.jbi.JBIException(
091: "Null argument received for "
092: + "EnvironmentContext");
093: }
094: }
095:
096: /**
097: * Get the JMX ObjectName for the DeploymentMBean for this BPE. If there
098: * is none, return null.
099: * @return ObjectName the JMX object name of the DeploymentMBean or null
100: * if there is no DeploymentMBean.
101: */
102: public ObjectName getDeploymentMBeanName() {
103: return null;
104: }
105:
106: /**
107: * Get the JMX ObjectName for any additional MBean for this BPE. If there
108: * is none, return null.
109: * @return ObjectName the JMX object name of the additional MBean or null
110: * if there is no additional MBean.
111: */
112: public ObjectName getExtensionMBeanName() {
113: return null;
114: }
115:
116: /**
117: * Start the Business Process Engine.
118: * @throws JBIException if an error occurs
119: */
120: public void start() throws javax.jbi.JBIException {
121: mLog.info("SNS User Engine " + mComponentName + " started");
122: try {
123: mLog.info("MSFT'S STOCK VALUE = "
124: + QuoteEngine.getQuote("MSFT"));
125: } catch (Exception cnfe) {
126: mLog.info("Unable to find QuoteEngine reference :"
127: + cnfe.toString());
128: throw new JBIException("could not load QuoteEngine:", cnfe);
129: }
130: }
131:
132: /**
133: * Stop the Business Process Engine.
134: * @throws JBIException if an error occurs
135: */
136: public void stop() throws javax.jbi.JBIException {
137: mLog.info("SNS User Engine " + mComponentName + " stopped");
138: }
139:
140: /**
141: * Shut down the Business Process Engine.
142: * @throws JBIException if an error occurs
143: */
144: public void shutDown() throws javax.jbi.JBIException {
145: mLog.info("SNS User Engine " + mComponentName + " shut down");
146: }
147:
148: // javax.jbi.component.Component interface
149:
150: /**
151: * Get the ComponentLifeCycle implementation instance for this Binding
152: * Component
153: * @return the lifecycle impl instance
154: */
155: public ComponentLifeCycle getLifeCycle() {
156: return this ;
157: }
158:
159: /**
160: * Get the ServiceUnitManager implementation instance for this Binding
161: * Component.
162: * @return the Service Unit manager implementation instance.
163: */
164: public ServiceUnitManager getServiceUnitManager() {
165: mLog.info("Engine " + mComponentName
166: + " getServiceUnitManager called");
167: return null;
168: }
169:
170: /**
171: * Resolve descriptor details for the specified reference, which is for a
172: * service provided by this component.
173: * @param ref the endpoint reference to be resolved.
174: * @return the description for the specified reference.
175: */
176: public org.w3c.dom.Document getServiceDescription(
177: javax.jbi.servicedesc.ServiceEndpoint ref) {
178: mLog.info("Engine " + mComponentName
179: + " getServiceDescription called");
180: return null;
181: }
182:
183: /** This method is called by JBI to check if this component, in the role of
184: * provider of the service indicated by the given exchange, can actually
185: * perform the operation desired.
186: */
187: public boolean isExchangeWithConsumerOkay(
188: javax.jbi.servicedesc.ServiceEndpoint endpoint,
189: javax.jbi.messaging.MessageExchange exchange) {
190: return true;
191: }
192:
193: /** This method is called by JBI to check if this component, in the role of
194: * consumer of the service indicated by the given exchange, can actually
195: * interact with the the provider completely.
196: */
197: public boolean isExchangeWithProviderOkay(
198: javax.jbi.servicedesc.ServiceEndpoint endpoint,
199: javax.jbi.messaging.MessageExchange exchange) {
200: return true;
201: }
202:
203: /**
204: * Resolve the given endpoint reference, given the capabilities of the
205: * given consumer. This is called by JBI when it is attempting to resolve
206: * the given endpoint reference on behalf of a component.
207: * @param epr the endpoint reference, in some XML dialect understood by the
208: * appropriate component (usually a Binding Component).
209: * @return the service endpoint for the endpoint reference;
210: * <code>null</code> if the endpoint reference cannot be resolved.
211: */
212: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
213: org.w3c.dom.DocumentFragment epr) {
214: return null;
215: }
216: }
|