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: * @(#)SharedNamespaceTestBinding.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package classloaderregresstests.sharedlibtest.binding.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 Binding 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 SharedNamespaceTestBinding 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 EnvironmentContext
058: */
059: private javax.jbi.component.ComponentContext mContext;
060:
061: /**
062: * Logger instance
063: */
064: private String logStr = "classloaderregresstests.sharedlibtest.binding.rt";
065: private Logger mLog = Logger.getLogger(logStr);
066: private int msgCount = 0;
067:
068: /**
069: * Initialize the Binding.
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: try {
079: Utils.setUpLogger(mLog, new FileHandler(Utils
080: .getLogLocation(logStr)),
081: new SimpleFormatter(), Level.INFO);
082: mLog.info("SNS User Binding" + mComponentName
083: + " initialized");
084: } catch (IOException ioe) {
085: System.out.println("Could not setup logger");
086: }
087: } else {
088: throw new javax.jbi.JBIException(
089: "Null argument received for "
090: + "EnvironmentContext");
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 Binding.
116: * @throws JBIException if an error occurs
117: */
118: public void start() throws javax.jbi.JBIException {
119: mLog.info("SNS User Binding" + mComponentName + " started");
120: try {
121: mLog.info("MSFT'S STOCK VALUE = "
122: + QuoteEngine.getQuote("MSFT"));
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 Binding.
132: * @throws JBIException if an error occurs
133: */
134: public void stop() throws javax.jbi.JBIException {
135: mLog.info("SNS User Binding " + mComponentName + " stopped");
136: }
137:
138: /**
139: * Shut down the Binding.
140: * @throws JBIException if an error occurs
141: */
142: public void shutDown() throws javax.jbi.JBIException {
143: mLog.info("Binding" + mComponentName + " shut down");
144: }
145:
146: /**
147: * Get the ComponentLifeCycle implementation instance for this Binding
148: * Component
149: * @return the lifecycle impl instance
150: */
151: public ComponentLifeCycle getLifeCycle() {
152: return this ;
153: }
154:
155: /**
156: * Get the ServiceUnitManager implementation instance for this Binding
157: * Component.
158: * @return the Service Unit manager implementation instance.
159: */
160: public ServiceUnitManager getServiceUnitManager() {
161: mLog.info("Binding " + mComponentName
162: + " getServiceUnitManager called");
163: return null;
164: }
165:
166: /**
167: * Resolve descriptor details for the specified reference, which is for a
168: * service provided by this component.
169: * @param ref the endpoint reference to be resolved.
170: * @return the description for the specified reference.
171: */
172: public org.w3c.dom.Document getServiceDescription(
173: javax.jbi.servicedesc.ServiceEndpoint ref) {
174: mLog.info("Binding " + mComponentName
175: + " getServiceDescription called");
176: return null;
177: }
178:
179: /** This method is called by JBI to check if this component, in the role of
180: * provider of the service indicated by the given exchange, can actually
181: * perform the operation desired.
182: */
183: public boolean isExchangeWithConsumerOkay(
184: javax.jbi.servicedesc.ServiceEndpoint endpoint,
185: javax.jbi.messaging.MessageExchange exchange) {
186: return true;
187: }
188:
189: /** This method is called by JBI to check if this component, in the role of
190: * consumer of the service indicated by the given exchange, can actually
191: * interact with the the provider completely.
192: */
193: public boolean isExchangeWithProviderOkay(
194: javax.jbi.servicedesc.ServiceEndpoint endpoint,
195: javax.jbi.messaging.MessageExchange exchange) {
196: return true;
197: }
198:
199: /**
200: * Resolve the given endpoint reference, given the capabilities of the
201: * given consumer. This is called by JBI when it is attempting to resolve
202: * the given endpoint reference on behalf of a component.
203: * @param epr the endpoint reference, in some XML dialect understood by the
204: * appropriate component (usually a Binding Component).
205: * @return the service endpoint for the endpoint reference;
206: * <code>null</code> if the endpoint reference cannot be resolved.
207: */
208: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
209: org.w3c.dom.DocumentFragment epr) {
210: return null;
211: }
212: }
|