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: * @(#)AbstractComponent.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.framework;
030:
031: import java.util.logging.Logger;
032:
033: import javax.jbi.component.Component;
034: import javax.jbi.component.ComponentContext;
035: import javax.jbi.component.ComponentLifeCycle;
036: import javax.jbi.component.ServiceUnitManager;
037:
038: /**
039: * This is an abstract class that all test components can inherit from. The
040: * purpose for this class is to minimize the impact of SPI changes to the
041: * test components. Dummy methods can be implemented here and only components
042: * that need real working versions of those methods need to implement them.
043: *
044: * @author Sun Microsystems, Inc.
045: */
046: public abstract class AbstractComponent implements Component,
047: ComponentLifeCycle, ServiceUnitManager {
048: /**
049: * Local copy of the component name.
050: */
051: protected String mComponentName;
052:
053: /**
054: * Type of component, defaults to "Component", but can be set by extending
055: * class to "Binding" or "Engine".
056: */
057: protected String mComponentType = "Component";
058:
059: /**
060: * Local handle to the ComponentContext.
061: */
062: protected ComponentContext mContext;
063:
064: /**
065: * Logger instance.
066: */
067: protected Logger mLog = Logger
068: .getLogger("com.sun.jbi.framework.test");
069:
070: //
071: // Component methods
072: //
073:
074: /**
075: * Get the ComponentLifeCycle implementation instance for this Binding
076: * Component.
077: * @return the life cycle implementation instance.
078: */
079: public ComponentLifeCycle getLifeCycle() {
080: mLog.info(mComponentType + " getLifeCycle called");
081: return this ;
082: }
083:
084: /**
085: * Get the ServiceUnitManager implementation instance for this Binding
086: * Component.
087: * @return the Service Unit manager implementation instance.
088: */
089: public ServiceUnitManager getServiceUnitManager() {
090: mLog.info(mComponentType + " " + mComponentName
091: + " getServiceUnitManager called");
092: return this ;
093: }
094:
095: /**
096: * Resolve descriptor details for the specified reference, which is for a
097: * service provided by this component.
098: * @param ref the endpoint reference to be resolved.
099: * @return the description for the specified reference.
100: */
101: public org.w3c.dom.Document getServiceDescription(
102: javax.jbi.servicedesc.ServiceEndpoint ref) {
103: mLog.info(mComponentType + " " + mComponentName
104: + " getServiceDescription called");
105: return null;
106: }
107:
108: /**
109: * This method is called by JBI to check if this component, in the role of
110: * provider of the service indicated by the given exchange, can actually
111: * perform the operation desired.
112: */
113: public boolean isExchangeWithConsumerOkay(
114: javax.jbi.servicedesc.ServiceEndpoint endpoint,
115: javax.jbi.messaging.MessageExchange exchange) {
116: mLog.info(mComponentType + " " + mComponentName
117: + " isExchangeWithConsumerOkay called");
118: return true;
119: }
120:
121: /**
122: * This method is called by JBI to check if this component, in the role of
123: * consumer of the service indicated by the given exchange, can actually
124: * interact with the the provider completely.
125: */
126: public boolean isExchangeWithProviderOkay(
127: javax.jbi.servicedesc.ServiceEndpoint endpoint,
128: javax.jbi.messaging.MessageExchange exchange) {
129: mLog.info(mComponentType + " " + mComponentName
130: + " isExchangeWithProviderOkay called");
131: return true;
132: }
133:
134: /**
135: * Resolve the given endpoint reference, given the capabilities of the
136: * given consumer. This is called by JBI when it is attempting to resolve
137: * the given endpoint reference on behalf of a component.
138: * @param epr the endpoint reference, in some XML dialect understood by the
139: * appropriate component (usually a Binding Component).
140: * @return the service endpoint for the endpoint reference;
141: * <code>null</code> if the endpoint reference cannot be resolved.
142: */
143: public javax.jbi.servicedesc.ServiceEndpoint resolveEndpointReference(
144: org.w3c.dom.DocumentFragment epr) {
145: mLog.info(mComponentType + " " + mComponentName
146: + " resolveEndpointReference called");
147: return null;
148: }
149:
150: //
151: // ComponentLifeCycle methods
152: //
153:
154: /**
155: * Initialize the Binding Component.
156: * @param context the JBI component context created by the JBI framework.
157: * @throws javax.jbi.JBIException if an error occurs.
158: */
159: public void init(ComponentContext context)
160: throws javax.jbi.JBIException {
161: }
162:
163: /**
164: * Get the JMX ObjectName for any additional MBean for this BC. This
165: * implementation always returns null.
166: * @return javax.management.ObjectName is always null.
167: */
168: public javax.management.ObjectName getExtensionMBeanName() {
169: mLog.info(mComponentType + " " + mComponentName
170: + " getExtensionMBeanName called");
171: return null;
172: }
173:
174: /**
175: * Start the Binding Component.
176: * @throws javax.jbi.JBIException if an error occurs.
177: */
178: public void start() throws javax.jbi.JBIException {
179: mLog.info(mComponentType + " " + mComponentName
180: + " start called");
181: }
182:
183: /**
184: * Stop the Binding Component.
185: * @throws javax.jbi.JBIException if an error occurs.
186: */
187: public void stop() throws javax.jbi.JBIException {
188: mLog.info(mComponentType + " " + mComponentName
189: + " stop called");
190: }
191:
192: /**
193: * Shut down the Binding Component.
194: * @throws javax.jbi.JBIException if an error occurs.
195: */
196: public void shutDown() throws javax.jbi.JBIException {
197: mLog.info(mComponentType + " " + mComponentName
198: + " shutDown called");
199: }
200:
201: //
202: // ServiceUnitManager methods
203: //
204:
205: /**
206: * Deploy a Service Unit.
207: * @param serviceUnitName the name of the Service Unit being deployed.
208: * @param serviceUnitRootPath the full path to the Service Unit artifact
209: * root directory.
210: * @return a deployment status message.
211: * @throws javax.jbi.management.DeploymentException if the deployment
212: * operation is unsuccessful.
213: */
214: public String deploy(String serviceUnitName,
215: String serviceUnitRootPath)
216: throws javax.jbi.management.DeploymentException {
217: mLog.info(mComponentType + " " + mComponentName
218: + " deployed Service Unit " + serviceUnitName);
219: return "Successfully deployed " + serviceUnitName;
220: }
221:
222: /**
223: * Initialize the deployment.
224: * @param serviceUnitName the name of the Service Unit being initialized.
225: * @param serviceUnitRootPath the full path to the Service Unit artifact
226: * root directory.
227: * @throws javax.jbi.management.DeploymentException if the Service Unit is
228: * not deployed, or is in an incorrect state.
229: */
230: public void init(String serviceUnitName, String serviceUnitRootPath)
231: throws javax.jbi.management.DeploymentException {
232: mLog.info(mComponentType + " " + mComponentName
233: + " initialized Service Unit " + serviceUnitName);
234: }
235:
236: /**
237: * Shut down the deployment.
238: * @param serviceUnitName the name of the Service Unit being shut down.
239: * @throws javax.jbi.management.DeploymentException if the Service Unit
240: * is not deployed, or is in an incorrect state.
241: */
242: public void shutDown(String serviceUnitName)
243: throws javax.jbi.management.DeploymentException {
244: mLog.info(mComponentType + " " + mComponentName
245: + " shut down Service Unit " + serviceUnitName);
246: }
247:
248: /**
249: * Start the deployment.
250: * @param serviceUnitName the name of the Service Unit being started.
251: * @throws javax.jbi.management.DeploymentException if the Service Unit
252: * is not deployed, or is in an incorrect state.
253: */
254: public void start(String serviceUnitName)
255: throws javax.jbi.management.DeploymentException {
256: mLog.info(mComponentType + " " + mComponentName
257: + " started Service Unit " + serviceUnitName);
258: }
259:
260: /**
261: * Stop the deployment.
262: * @param serviceUnitName the name of the Service Unit being stopped.
263: * @throws javax.jbi.management.DeploymentException if the Service Unit
264: * is not deployed, or is in an incorrect state.
265: */
266: public void stop(String serviceUnitName)
267: throws javax.jbi.management.DeploymentException {
268: mLog.info(mComponentType + " " + mComponentName
269: + " stopped Service Unit " + serviceUnitName);
270: }
271:
272: /**
273: * Undeploy a Service Unit from the component.
274: * @param serviceUnitName the name of the Service Unit being undeployed.
275: * @param serviceUnitRootPath the full path to the Service Unit artifact
276: * root directory.
277: * @return an undeployment status message.
278: * @throws javax.jbi.management.DeploymentException if the undeployment
279: * operation is unsuccessful.
280: */
281: public String undeploy(String serviceUnitName,
282: String serviceUnitRootPath)
283: throws javax.jbi.management.DeploymentException {
284: mLog.info(mComponentType + " " + mComponentName
285: + " undeployed Service Unit " + serviceUnitName);
286: return "Successfully undeployed " + serviceUnitName;
287: }
288: }
|