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: * @(#)EngineLifeCycle.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package classloaderregresstests.selffirstloading.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 EngineLifeCycle 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.selffirstloading.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: //String testJavaxClass = "javax.test.Test" ;
122: String testJavaxClass = "javax.ejb.EJBObject";
123: Class selfFirstClass = Class.forName(testJavaxClass);
124: mLog.info(testJavaxClass + " was loaded using:"
125: + selfFirstClass.getClassLoader());
126: } catch (Exception cnfe) {
127: mLog.info("Unable to find javax.test.Test reference :"
128: + cnfe.toString());
129: throw new JBIException("could not load javax.test.Test:",
130: cnfe);
131: }
132: }
133:
134: /**
135: * Stop the Business Process Engine.
136: * @throws JBIException if an error occurs
137: */
138: public void stop() throws javax.jbi.JBIException {
139: mLog.info("Engine " + mComponentName + " stopped");
140: }
141:
142: /**
143: * Shut down the Business Process Engine.
144: * @throws JBIException if an error occurs
145: */
146: public void shutDown() throws javax.jbi.JBIException {
147: mLog.info("Engine " + mComponentName + " shut down");
148: }
149:
150: private String getLogFileName() {
151: return Utils.getLogLocation(logStr);
152: }
153:
154: // javax.jbi.component.Component interface
155:
156: /**
157: * Get the ComponentLifeCycle implementation instance for this Binding
158: * Component
159: * @return the lifecycle impl instance
160: */
161: public ComponentLifeCycle getLifeCycle() {
162: return this ;
163: }
164:
165: /**
166: * Get the ServiceUnitManager implementation instance for this Binding
167: * Component.
168: * @return the Service Unit manager implementation instance.
169: */
170: public ServiceUnitManager getServiceUnitManager() {
171: mLog.info("Engine " + mComponentName
172: + " getServiceUnitManager called");
173: return null;
174: }
175:
176: /**
177: * Resolve the given endpoint reference, given the capabilities of the
178: * given consumer. This is called by JBI when it is attempting to resolve
179: * the given endpoint reference on behalf of a component.
180: * @param epr the endpoint reference, in some XML dialect understood by the
181: * appropriate component (usually a Binding Component).
182: * @return the service endpoint for the endpoint reference;
183: * <code>null</code> if the endpoint reference cannot be resolved.
184: */
185: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
186: org.w3c.dom.DocumentFragment epr) {
187: return null;
188: }
189:
190: /**
191: * Resolve descriptor details for the specified reference, which is for a
192: * service provided by this component.
193: * @param ref the endpoint reference to be resolved.
194: * @return the description for the specified reference.
195: */
196: public org.w3c.dom.Document getServiceDescription(
197: javax.jbi.servicedesc.ServiceEndpoint ref) {
198: mLog.info("Engine " + mComponentName
199: + " getServiceDescription called");
200: return null;
201: }
202:
203: /** This method is called by JBI to check if this component, in the role of
204: * provider of the service indicated by the given exchange, can actually
205: * perform the operation desired.
206: */
207: public boolean isExchangeWithConsumerOkay(
208: javax.jbi.servicedesc.ServiceEndpoint endpoint,
209: javax.jbi.messaging.MessageExchange exchange) {
210: return true;
211: }
212:
213: /** This method is called by JBI to check if this component, in the role of
214: * consumer of the service indicated by the given exchange, can actually
215: * interact with the the provider completely.
216: */
217: public boolean isExchangeWithProviderOkay(
218: javax.jbi.servicedesc.ServiceEndpoint endpoint,
219: javax.jbi.messaging.MessageExchange exchange) {
220: return true;
221: }
222:
223: }
|