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