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: * @(#)ModelBindingComponent.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.management.binding;
030:
031: import com.sun.jbi.management.JbiNameInfo;
032: import com.sun.jbi.management.MBeanNames;
033: import com.sun.jbi.management.support.MBeanSet;
034: import com.sun.jbi.management.common.LoggerMBean;
035: import com.sun.jbi.StringTranslator;
036: import com.sun.jbi.management.LocalStringKeys;
037: import java.util.logging.Logger;
038: import java.util.logging.Level;
039: import java.util.Properties;
040: import javax.management.NotificationEmitter;
041: import javax.management.NotificationListener;
042: import javax.management.NotificationFilter;
043: import javax.management.MBeanNotificationInfo;
044: import javax.management.NotificationBroadcasterSupport;
045: import javax.management.ListenerNotFoundException;
046: import javax.management.MBeanServer;
047: import javax.management.ObjectName;
048: import javax.jbi.component.Component;
049: import com.sun.jbi.management.common.ControllerMBean;
050: import javax.jbi.component.ComponentLifeCycle;
051: import javax.jbi.component.ServiceUnitManager;
052: import javax.jbi.component.ComponentContext;
053: import javax.jbi.JBIException;
054:
055: import javax.jbi.messaging.MessageExchange;
056: import javax.jbi.servicedesc.ServiceEndpoint;
057:
058: import javax.xml.namespace.QName;
059:
060: import org.w3c.dom.Document;
061: import org.w3c.dom.DocumentFragment;
062: import javax.jbi.management.DeploymentException;
063:
064: /**
065: * The ModelBindingComponent implements the management controls for a standard
066: * JBI Framework binding component, and can be extended to provide a full
067: * binding implementation.
068: *
069: * @author Sun Microsystems, Inc.
070: */
071: public abstract class ModelBindingComponent implements Component,
072: ControllerMBean, ComponentLifeCycle, ServiceUnitManager,
073: NotificationEmitter {
074: protected com.sun.jbi.component.ComponentContext mEnv;
075:
076: //allocate mbean sets for INITIAL and START/STOP mbeans:
077: protected MBeanSet mInitialMBeans, mStartMBeans;
078:
079: /** Logger to be used by ModelBindingComponent methods: */
080: protected Logger mLogger;
081:
082: /** handle to our MBean Server: */
083: protected MBeanServer mMBeanServer;
084:
085: /** handle to our MBean Namer: */
086: protected com.sun.jbi.management.MBeanNames mMBeanNames;
087:
088: /** handle to jbi system or installed component identification: */
089: protected JbiNameInfo mJbiNameInfo;
090:
091: /** User-friendly display name to be used by ModelBindingComponent methods: */
092: protected String mDisplayName;
093:
094: /** JMX object names for standard mbeans: */
095: protected ObjectName mConfigMBeanName;
096: protected ObjectName mLifeCycleMBeanName;
097: protected ObjectName mLoggerMBeanName;
098:
099: protected final String mModelName = "ModelBindingComponent";
100:
101: /** Handle to StringTranslator for message translation: */
102: protected StringTranslator mTranslator;
103:
104: /** allocate a logger, and then initialize the ModelBindingComponent. */
105: protected void initModelBindingComponent(
106: javax.jbi.component.ComponentContext anEnv,
107: JbiNameInfo aJbiName) {
108: //allocate a logger, since none was provided::
109: mLogger = Logger.getLogger(anEnv.getComponentName());
110:
111: //call the secondary form of init:
112: initModelBindingComponent(anEnv, mLogger, aJbiName);
113: }
114:
115: /** Initialize the ModelBindingComponent. This does not register any mbeans. */
116: protected void initModelBindingComponent(
117: javax.jbi.component.ComponentContext anEnv, Logger aLogger,
118: JbiNameInfo aJbiName) {
119: //get access to environment implementation, if different:
120: mEnv = (com.sun.jbi.component.ComponentContext) anEnv;
121:
122: //save handle to jbi system or installed component identification:
123: mJbiNameInfo = aJbiName;
124:
125: //save logger handle
126: mLogger = aLogger;
127:
128: mMBeanServer = mEnv.getMBeanServer();
129: try {
130: //why doesn't this work for model components????
131: //(throws a class-cast exception).
132: //mMBeanNames = (com.sun.jbi.management.MBeanNames) mEnv.getMBeanNames();
133:
134: //work-around for above:
135: com.sun.jbi.management.support.MBeanNamesImpl mbnamesImpl = new com.sun.jbi.management.support.MBeanNamesImpl(
136: mEnv.getMBeanNames().getJmxDomainName(), System
137: .getProperty("com.sun.jbi.instanceName"));
138: mMBeanNames = (com.sun.jbi.management.MBeanNames) mbnamesImpl;
139:
140: //create MBEAN sets for INITIAL and START states:
141: mInitialMBeans = new MBeanSet(mMBeanServer, mLogger);
142: mStartMBeans = new MBeanSet(mMBeanServer, mLogger);
143:
144: //create Object names for standard mbeans, and populate mbean sets:
145: initModelBindingMBeanNames();
146: } catch (Exception e) {
147: e.printStackTrace();
148: }
149:
150: try {
151: //this is for translating messages in management support packages:
152: mTranslator = (StringTranslator) mEnv
153: .getStringTranslator("com.sun.jbi.management");
154: } catch (Exception e) {
155: e.printStackTrace();
156: }
157:
158: mLogger
159: .fine("initModelBindingComponent: Initialization complete for "
160: + mJbiNameInfo.name());
161: }
162:
163: /** perform one-time startup tasks for this model */
164: protected void bootstrap() {
165: mLogger.fine("ModelBindingComponent: START bootstrap for '"
166: + mJbiNameInfo.name() + "'");
167:
168: //register INITIAL mbean set:
169: mInitialMBeans.register();
170:
171: //restore & apply current configuration:
172: try {
173: mMBeanServer.invoke(mConfigMBeanName, "restore",
174: new Object[0], new String[0]);
175: mMBeanServer.invoke(mConfigMBeanName, "apply",
176: new Object[0], new String[0]);
177: } catch (Exception e) {
178: mLogger.warning(e.toString());
179: }
180:
181: mLogger.fine("ModelBindingComponent: FINISH bootstrap for '"
182: + mJbiNameInfo.name() + "'");
183: }
184:
185: ////////////////
186: //implementation of JBI Framework Component:
187: ////////////////
188:
189: /**
190: * Get the life cycle control interface for this component. This interface
191: * allows the JBI implementation to control the running state of this
192: * component.
193: * <p>
194: * This method must be called before any other methods of this interface
195: * are called. In addition, the JBI implementation must call the init()
196: * method of the component life cycle returned by this method before
197: * calling any other methods on this interface, or the component life cycle
198: * interface.
199: *
200: * @return the life cycle control interface for this component; must be
201: * non-null.
202: */
203: public ComponentLifeCycle getLifeCycle() {
204: return this ;
205: }
206:
207: /**
208: * Get the Service Unit manager for this component. If this component does
209: * not support deployments, it must return <code>null</code>.
210: *
211: * @return the <code>ServiceUnitManager</code> for this component, or
212: * <code>null</code> if there is none.
213: */
214: public ServiceUnitManager getServiceUnitManager() {
215: return this ;
216: }
217:
218: /**
219: * Retrieves a DOM representation containing metadata which describes the
220: * service provided by this component, through the given endpoint. The
221: * result can use WSDL 1.1 or WSDL 2.0.
222: *
223: * @param endpoint the service endpoint.
224: * @return the description for the specified service endpoint.
225: */
226: public Document getServiceDescription(ServiceEndpoint endpoint) {
227: return (Document) null;
228: }
229:
230: /**
231: * This method is called by JBI to check if this component, in the role of
232: * provider of the service indicated by the given exchange, can actually
233: * perform the operation desired.
234: *
235: * @param endpoint the endpoint to be used by the consumer; must be
236: * non-null.
237: * @param exchange the proposed message exchange to be performed; must be
238: * non-null.
239: * @return <code>true</code> if this provider component can perform the
240: * given exchange with the described consumer.
241: */
242: public boolean isExchangeWithConsumerOkay(ServiceEndpoint endpoint,
243: MessageExchange exchange) {
244: return true;
245: }
246:
247: /**
248: * This method is called by JBI to check if this component, in the role of
249: * consumer of the service indicated by the given exchange, can actually
250: * interact with the provider properly. The provider is described by the
251: * given endpoint and the service description supplied by that endpoint.
252: *
253: * @param endpoint the endpoint to be used by the provider; must be
254: * non-null.
255: * @param exchange the proposed message exchange to be performed; must be
256: * non-null.
257: * @return <code>true</code> if this consumer component can interact with
258: * the described provider to perform the given exchange.
259: */
260: public boolean isExchangeWithProviderOkay(ServiceEndpoint endpoint,
261: MessageExchange exchange) {
262: return true;
263: }
264:
265: /**
266: * Resolve the given endpoint reference. This is called by JBI when it is
267: * attempting to resolve the given EPR on behalf of a component.
268: * <p>
269: * If this component returns a non-null result, it must conform to the
270: * following:
271: * <ul>
272: * <li>This component implements the {@link ServiceEndpoint} returned.
273: * </li>
274: * <li>The result must not be registered or activated with the JBI
275: * implementation.</li>
276: * </ul>
277: *
278: * Dynamically resolved endpoints are distinct from static ones; they must
279: * not be activated (see {@link ComponentContext#activateEndpoint(QName,
280: * String)}), nor registered (see {@link ComponentContext}) by components.
281: * They can only be used to address message exchanges; the JBI
282: * implementation must deliver such exchanges to the component that resolved
283: * the endpoint reference (see {@link
284: * ComponentContext#resolveEndpointReference(DocumentFragment)}).
285: *
286: * @param epr the endpoint reference, in some XML dialect understood by
287: * the appropriate component (usually a binding); must be non-null.
288: * @return the service endpoint for the EPR; <code>null</code> if the
289: * EPR cannot be resolved by this component.
290: */
291: public ServiceEndpoint resolveEndpointReference(DocumentFragment epr) {
292: return null;
293: }
294:
295: ////////////////
296: //implementation of JBI Framework ComponentLifeCycle:
297: ////////////////
298:
299: /**
300: * Get the JMX object name for the extension MBean for this component; if
301: * there is none, return <code>null</code>.
302: *
303: * @return the JMX object name of the additional MBean or <code>null</code>
304: * if there is no additional MBean.
305: */
306: public ObjectName getExtensionMBeanName() {
307: return mControllerMBeanName;
308: }
309:
310: /**
311: * Initialize the component. This performs initialization required by the
312: * component but does not make it ready to process messages. This method is
313: * called once for each life cycle of the component.
314: * <p>
315: * If the component needs to register an additional MBean to extend its
316: * life cycle, or provide other component management tasks, it should
317: * be registered during this call.
318: *
319: * @param context the component's context, providing access to component
320: * data provided by the JBI environment; must be non-null.
321: * @exception JBIException if the component is unable to initialize.
322: */
323: public void init(ComponentContext context) throws JBIException {
324: }
325:
326: /**
327: * Shut down the component. This performs clean-up, releasing all run-time
328: * resources used by the component. Once this method has been called,
329: * {@link #init(ComponentContext)} must be called before the component can
330: * be started again with a call to {@link #start()}.
331: *
332: * @exception JBIException if the component is unable to shut down.
333: */
334: public void shutDown() throws JBIException {
335: try {
336: //unregister INITIAL mbean set:
337: mInitialMBeans.unregister();
338: } catch (Exception e) {
339: e.printStackTrace();
340: }
341: }
342:
343: /**
344: * Start the component. This makes the component ready to process messages.
345: * This method is called after {@link #init(ComponentContext)}, both when
346: * the component is being started for the first time and when the component
347: * is being restarted after a previous call to {@link #shutDown()}.
348: * If {@link #stop()} was called previously but {@link #shutDown()} was not,
349: * <code>start()</code> can be called again without another call to
350: * {@link #init(ComponentContext)}.
351: *
352: * @exception JBIException if the component is unable to start.
353: */
354: public void start() throws JBIException {
355: //register START/STOP mbean set:
356: mStartMBeans.register();
357: }
358:
359: /**
360: * Stop the component. This makes the component stop accepting messages for
361: * processing. After a call to this method, {@link #start()} may be called
362: * again without first calling {@link #init(ComponentContext)}.
363: *
364: * @exception JBIException if the component is unable to stop.
365: */
366: public void stop() throws JBIException {
367: //unregister START/STOP mbean set:
368: mStartMBeans.unregister();
369: }
370:
371: ////////////////
372: //implementation of ServiceUnitManager:
373: ////////////////
374:
375: /**
376: * Deploy a Service Unit to the component. This is called by the JBI
377: * implementation in order to deploy the given artifact to the implementing
378: * component.
379: * <p>
380: * Upon successful deployment, a non-empty result string must be returned,
381: * that starts with the JBI-defined component-task-result element.
382: * For example:
383: * <pre>
384: * <component-task-result>
385: * <component-name>BC1</component-name>
386: * <component-task-result-details
387: * xmlns="http://java.sun.com/xml/ns/jbi/management-message">
388: * <task-result-details>
389: * <task-id>deploy</task-id>
390: * <task-result>SUCCESS</task-result>
391: * </task-result-details>
392: * </component-task-result-details>
393: * </component-task-result>
394: * </pre>
395: * A failed deployment of the service unit must be reported using the
396: * <code>component-task-result</code> element as well; the
397: * <code>task-result</code> must be set to FAILED.
398: *
399: * @param serviceUnitName name of the service unit being deployed; must be
400: * non-null and non-empty and unique among service units already
401: * deployed to the component.
402: * @param serviceUnitRootPath path of the service unit artifact root, in
403: * platform specific format; must be non-null and non-empty.
404: * @return a deployment status message, which is an XML string that conforms
405: * to the schema given in the <i>MBean Status and Result Strings</i>
406: * section of the <i><b>Management</b></i> chapter of the JBI
407: * specification; must be non-null and non-empty.
408: * @exception DeploymentException if the deployment operation is
409: * unsuccessful.
410: */
411: public String deploy(String serviceUnitName,
412: String serviceUnitRootPath) throws DeploymentException {
413: return messageDeployOkay();
414: }
415:
416: /**
417: * Initialize the given deployed service unit. This is the first phase of
418: * a two-phase start, where the component must prepare to receive service
419: * requests related to the deployment (if any).
420: * <p>
421: * The serviceUnitRootPath parameter is provided to facilitate restart of
422: * the component. This allows simple components to rely entirely on JBI's
423: * ability to persist deployment information, avoiding the need for the
424: * component to provide its own persistence mechanism.
425: *
426: * @param serviceUnitName name of the service unit being initialized; must
427: * be non-null, non-empty, and match the name of a previously
428: * deployed (but not yet undeployed) service unit.
429: * @param serviceUnitRootPath path of the service unit artifact root, in
430: * platform specific format; must be non-null and non-empty.
431: * @exception DeploymentException if the service unit is not deployed, or
432: * if it is in an incorrect state.
433: */
434: public void init(String serviceUnitName, String serviceUnitRootPath)
435: throws DeploymentException {
436: }
437:
438: /**
439: * Start the deployed service unit. This is the second phase of a two-phase
440: * start, where the component can now initiate service requests related to
441: * the deployment.
442: *
443: * @param serviceUnitName the name of the service unit being started; must
444: * be non-null, non-empty, and match the name of a previously
445: * deployed (but not yet undeployed) service unit.
446: * @exception DeploymentException if the service unit is not deployed, or
447: * if it is in an incorrect state.
448: */
449: public void start(String serviceUnitName)
450: throws DeploymentException {
451: }
452:
453: /**
454: * Stop the deployed service unit. This causes the component to cease
455: * generating service requests related to the given service unit. This
456: * returns the service unit to a state equivalent to after
457: * {@link #init(String, String)} was called.
458: *
459: * @param serviceUnitName name of the service unit being stopped; must
460: * be non-null, non-empty, and match the name of a previously
461: * deployed (but not yet undeployed) service unit.
462: * @exception DeploymentException if the service unit is not deployed, or
463: * if it is in an incorrect state.
464: */
465: public void stop(String serviceUnitName) throws DeploymentException {
466: }
467:
468: /**
469: * Shut down the deployment. This causes the deployment to return to the
470: * to the state it was in after {@link #deploy(String, String)}, and before
471: * {@link #init(String, String)}.
472: *
473: * @param serviceUnitName name of the service unit being shut down; must
474: * be non-null, non-empty, and match the name of a previously
475: * deployed (but not yet undeployed) service unit.
476: * @exception DeploymentException if the service unit is not deployed, or
477: * if it is in an incorrect state.
478: */
479: public void shutDown(String serviceUnitName)
480: throws DeploymentException {
481: }
482:
483: /**
484: * Undeploy a service unit from the component. The service unit must be
485: * shut down to undeploy it.
486: *
487: * @param serviceUnitName name of the service unit being undeployed; must
488: * be non-null, non-empty, and match the name of a previously
489: * deployed (but not yet undeployed) service unit.
490: * @param serviceUnitRootPath path of the service unit artifact root, in
491: * platform specific format; must be non-null and non-empty.
492: * @return deployment status message, which is an XML string that conforms
493: * to the <code>component-task-result</code> type from
494: * the schema given in the <i>MBean Status and Result Strings</i>
495: * section of the <i><b>Management</b></i> chapter of the JBI
496: * specification; must be non-null and non-empty.
497: * @exception DeploymentException if undeployment operation is unsuccessful,
498: * or if the service unit is in an incorrect state.
499: */
500: public String undeploy(String serviceUnitName,
501: String serviceUnitRootPath) throws DeploymentException {
502: return messageUnDeployOkay();
503: }
504:
505: ////////////////
506: //implementation of JBI Framework ControllerMBean:
507: ////////////////
508:
509: /**
510: * Return current version and other info about this component.
511: * @return info String
512: */
513: public String getComponentInfo() {
514: //TODO: add version info.
515: return mModelName + ": " + mJbiNameInfo.name();
516: }
517:
518: /**
519: * Return help text about this component.
520: * @return help text about this component.
521: */
522: public String getHelp() {
523: return "no soup for you";
524: }
525:
526: /**
527: * Return the JMX ObjectName for this component's ConfigurationMBean
528: * or null.
529: * @return the JMX ObjectName for this component's ConfigurationMBean
530: * or null.
531: */
532: public ObjectName getConfigurationMBean() {
533: return mConfigMBeanName;
534: }
535:
536: /**
537: * Return the JMX ObjectName for this component's DeployerMBean or null.
538: * @return the JMX ObjectName for this component's DeployerMBean or null.
539: */
540: public ObjectName getDeployerMBean() {
541: return mDeployerMBeanName;
542: }
543:
544: /**
545: * Return the JMX ObjectName for this component's LifeCycleMBean
546: * or null.
547: * @return the JMX ObjectName for this component's LifeCycleMBean
548: * or null.
549: */
550: public ObjectName getLifeCycleMBean() {
551: return mLifeCycleMBeanName;
552: }
553:
554: /**
555: * Return the ObjectName for LoggerMBean named <CODE>aLoggerName</CODE>,
556: * or null, if the named logger does not exist in this component.
557: * @return ObjectName of LoggerMBean.
558: */
559: public ObjectName getLoggerMBeanByName(String aLoggerName) {
560: return mLoggerMBeanName;
561: }
562:
563: /**
564: * Return the ObjectName of the default LoggerMBean for this component.
565: * @return ObjectName of default LoggerMBean or null.
566: */
567: public ObjectName getDefaultLoggerMBean() {
568: return mLoggerMBeanName;
569: }
570:
571: /**
572: * Return the ObjectNames for all of the LoggerMBean's for this component.
573: * @return array of ObjectName, possibly of zero length.
574: */
575: public ObjectName[] getLoggerMBeans() {
576: ObjectName[] names = new ObjectName[1];
577: names[0] = mLoggerMBeanName;
578:
579: return names;
580: }
581:
582: /**
583: * Return the componentName
584: * @return the componentName
585: */
586: public String getcomponentName() {
587: return mJbiNameInfo.name();
588: }
589:
590: /** JMX object names for component-only mbeans: */
591: protected ObjectName mDeployerMBeanName;
592: protected ObjectName mControllerMBeanName;
593:
594: /**
595: * create Object names for required ModelBindingComponent mbeans,
596: * and populate the INITIAL & START state mbean sets.
597: */
598: private void initModelBindingMBeanNames() {
599: /////////////
600: //controller:
601: /////////////
602: mControllerMBeanName = mMBeanNames.getBindingMBeanName(
603: mJbiNameInfo.name(),
604: mMBeanNames.CONTROL_TYPE_CONTROLLER);
605: mStartMBeans.add(mControllerMBeanName,
606: com.sun.jbi.management.common.ControllerMBean.class,
607: this );
608:
609: ///////////
610: //deployer:
611: ///////////
612: mDeployerMBeanName = mMBeanNames.getBindingMBeanName(
613: mJbiNameInfo.name(), mMBeanNames.CONTROL_TYPE_DEPLOYER);
614: //note - we do not add our deployer mbean to the initial set,
615: //as the implementation of $deployerMBean is managed by the framework.
616:
617: ////////////
618: //lifecycle:
619: ////////////
620: mLifeCycleMBeanName = mMBeanNames
621: .getBindingMBeanName(mJbiNameInfo.name(),
622: mMBeanNames.CONTROL_TYPE_LIFECYCLE);
623: //note - we do not add our lifecycle mbean to the initial set,
624: //as the implementation of $lifecycleMBean is managed by the framework.
625:
626: /////////
627: //logger:
628: /////////
629: mLoggerMBeanName = mMBeanNames.getBindingMBeanName(mJbiNameInfo
630: .name(), mMBeanNames.CONTROL_TYPE_LOGGER);
631: //note - we do not add our logger mbean to the initial set,
632: //as the implementation of $loggerMBean is managed by the framework.
633: }
634:
635: //allocate our broadcast support class:
636: private NotificationBroadcasterSupport mEmitter = new NotificationBroadcasterSupport();
637:
638: //Implementation for NotificationBroadcaster, extended by NotificationEmitter
639: /**
640: * Adds a listener to this MBean.
641: *
642: * @param listener The listener object which will handle the
643: * notifications emitted by the broadcaster.
644: * @param filter The filter object. If filter is null, no
645: * filtering will be performed before handling notifications.
646: * @param handback An opaque object to be sent back to the
647: * listener when a notification is emitted. This object cannot be
648: * used by the Notification broadcaster object. It should be
649: * resent unchanged with the notification to the listener.
650: *
651: * @exception IllegalArgumentException Listener parameter is null.
652: *
653: * @see #removeNotificationListener
654: */
655: public void addNotificationListener(NotificationListener listener,
656: NotificationFilter filter, Object handback)
657: throws java.lang.IllegalArgumentException {
658: mEmitter.addNotificationListener(listener, filter, handback);
659: }
660:
661: /**
662: * Removes a listener from this MBean. If the listener
663: * has been registered with different handback objects or
664: * notification filters, all entries corresponding to the listener
665: * will be removed.
666: *
667: * @param listener A listener that was previously added to this
668: * MBean.
669: *
670: * @exception ListenerNotFoundException The listener is not
671: * registered with the MBean.
672: *
673: * @see #addNotificationListener
674: * @see NotificationEmitter#removeNotificationListener
675: */
676: public void removeNotificationListener(NotificationListener listener)
677: throws ListenerNotFoundException {
678: mEmitter.removeNotificationListener(listener);
679: }
680:
681: /**
682: * <p>Returns an array indicating, for each notification this
683: * MBean may send, the name of the Java class of the notification
684: * and the notification type.</p>
685: *
686: * <p>It is not illegal for the MBean to send notifications not
687: * described in this array. However, some clients of the MBean
688: * server may depend on the array being complete for their correct
689: * functioning.</p>
690: *
691: * @return the array of possible notifications.
692: */
693: public MBeanNotificationInfo[] getNotificationInfo() {
694: return (new MBeanNotificationInfo[0]);
695: }
696:
697: //Implementaion for NotificationEmitter, which extends NotificationBroadcaster
698:
699: /**
700: * <p>Removes a listener from this MBean. The MBean must have a
701: * listener that exactly matches the given <code>listener</code>,
702: * <code>filter</code>, and <code>handback</code> parameters. If
703: * there is more than one such listener, only one is removed.</p>
704: *
705: * <p>The <code>filter</code> and <code>handback</code> parameters
706: * may be null if and only if they are null in a listener to be
707: * removed.</p>
708: *
709: * @param listener A listener that was previously added to this
710: * MBean.
711: * @param filter The filter that was specified when the listener
712: * was added.
713: * @param handback The handback that was specified when the listener was
714: * added.
715: *
716: * @exception ListenerNotFoundException The listener is not
717: * registered with the MBean, or it is not registered with the
718: * given filter and handback.
719: */
720: public void removeNotificationListener(
721: NotificationListener listener, NotificationFilter filter,
722: Object handback) throws ListenerNotFoundException {
723: mEmitter.removeNotificationListener(listener, filter, handback);
724: }
725:
726: /**
727: * Getter for local NotificationBroadcaster.
728: *
729: * @return NotificationBroadcaster
730: */
731: public NotificationBroadcasterSupport getNotificationBroadcaster() {
732: return mEmitter;
733: }
734:
735: private String mm_prolog = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><jbi-task version=\"1.0\" xmlns=\"http://java.sun.com/xml/ns/managementMessage\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/managementMessage ./managementMessage.xsd\"><jbi-task-result><frmwk-task-result><frmwk-task-result-details><task-result-details>";
736: private String mm_deploy_task = "<task-id>deploy</task-id>";
737: private String mm_undeploy_task = "<task-id>undeploy</task-id>";
738: private String mm_task_success = "<task-result>SUCCESS</task-result>";
739: private String mm_task_details_1 = "</task-result-details><locale>en_US</locale></frmwk-task-result-details></frmwk-task-result><component-task-result><component-name>";
740: private String mm_task_details_2 = "</component-name><component-task-result-details><task-result-details>";
741: private String mm_epilog = "</task-result-details></component-task-result-details></component-task-result></jbi-task-result></jbi-task>";
742:
743: public String messageDeployOkay() {
744: return mm_prolog + mm_deploy_task + mm_task_success
745: + mm_task_details_1 + mJbiNameInfo.name()
746: + mm_task_details_2 + mm_deploy_task + mm_task_success
747: + mm_epilog;
748: }
749:
750: public String messageUnDeployOkay() {
751: return mm_prolog + mm_undeploy_task + mm_task_success
752: + mm_task_details_1 + mJbiNameInfo.name()
753: + mm_task_details_2 + mm_undeploy_task
754: + mm_task_success + mm_epilog;
755: }
756: }
|