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