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: * @(#)ClassloaderChainTestEngine.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package classloaderregresstests.classloaderchaintest.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:
039: /**
040: * This is an implementation of a Business Process Engine used to
041: * test the various use cases of the classloader design
042: * In particular it tests if a private library specified in the "componentClassPath"
043: * element of jbi.xml
044: *
045: * @author Sun Microsystems, Inc.
046: */
047: public class ClassloaderChainTestEngine implements
048: javax.jbi.component.ComponentLifeCycle,
049: javax.jbi.component.Component {
050: /**
051: * Local copy of the component name
052: */
053: private String mComponentName;
054:
055: /**
056: * Local handle to the ComponentContext
057: */
058: private javax.jbi.component.ComponentContext mContext;
059:
060: /**
061: * Logger instance
062: */
063: private String logStr = "classloaderregresstests.classloaderchaintest.engine.rt";
064: private Logger mLog = Logger.getLogger(logStr);
065: private int msgCount = 0;
066:
067: /**
068: * Initialize the Business Process Engine.
069: * @param context the JBI environment context created
070: * by the JBI framework
071: * @throws JBIException if an error occurs
072: */
073: public void init(javax.jbi.component.ComponentContext context)
074: throws javax.jbi.JBIException {
075: if (null != context) {
076: mComponentName = context.getComponentName();
077:
078: // setup the logger
079: try {
080: Utils.setUpLogger(mLog, new FileHandler(Utils
081: .getLogLocation(logStr)),
082: new SimpleFormatter(), Level.INFO);
083: mLog.info("Classloader Chain Test Engine "
084: + 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 " + "ComponentContext");
091: }
092: }
093:
094: /**
095: * Get the JMX ObjectName for any additional MBean for this BPE. If there
096: * is none, return null.
097: * @return ObjectName the JMX object name of the additional MBean or null
098: * if there is no additional MBean.
099: */
100: public ObjectName getExtensionMBeanName() {
101: return null;
102: }
103:
104: /**
105: * Start the Business Process Engine.
106: * @throws JBIException if an error occurs
107: */
108: public void start() throws javax.jbi.JBIException {
109: mLog.info("Classloader Chain Test Engine " + mComponentName
110: + " started");
111: try {
112: mLog.info("Component Classloader = "
113: + this .getClass().getClassLoader());
114: mLog
115: .info("Parent of Component Classloader(Delegating Classloader) = "
116: + this .getClass().getClassLoader()
117: .getParent());
118: mLog.info("Parent of Delegating Classloader = "
119: + this .getClass().getClassLoader().getParent()
120: .getParent());
121: } catch (Exception cnfe) {
122: mLog.info("Unable to list Component Classloader chain :"
123: + cnfe.toString());
124: throw new JBIException(
125: "could not load component classloader chain :",
126: 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("Classloader Chain Test Engine " + mComponentName
136: + " stopped");
137: }
138:
139: /**
140: * Shut down the Business Process Engine.
141: * @throws JBIException if an error occurs
142: */
143: public void shutDown() throws javax.jbi.JBIException {
144: mLog.info("Classloader Chain Test Engine " + mComponentName
145: + " 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: }
|