001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management;
023:
024: import org.jboss.mx.server.ServerConstants;
025: import org.jboss.mx.util.AgentID;
026:
027: /**
028: * Mandatory MBean server delegate MBean implementation.
029: *
030: * @see javax.management.MBeanServerDelegateMBean
031: *
032: * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>.
033: * @version $Revision: 57200 $
034: *
035: */
036: public class MBeanServerDelegate implements MBeanServerDelegateMBean,
037: NotificationEmitter {
038:
039: // Attributes ----------------------------------------------------
040: private MBeanNotificationInfo notificationInfo = null;
041: private NotificationBroadcasterSupport notifier = null;
042: private String agentID = AgentID.create();
043:
044: // Constructors --------------------------------------------------
045: public MBeanServerDelegate() {
046: this .notificationInfo = new MBeanNotificationInfo(new String[] {
047: MBeanServerNotification.REGISTRATION_NOTIFICATION,
048: MBeanServerNotification.UNREGISTRATION_NOTIFICATION },
049: MBeanServerNotification.class.getName(),
050: "Describes the MBean registration and unregistration events in a MBean Server.");
051: this .notifier = new NotificationBroadcasterSupport();
052: }
053:
054: // MBeanServerDelegateMBean implementation -----------------------
055: public String getMBeanServerId() {
056: return agentID;
057: }
058:
059: public String getSpecificationName() {
060: return ServerConstants.SPECIFICATION_NAME;
061: }
062:
063: public String getSpecificationVersion() {
064: return ServerConstants.SPECIFICATION_VERSION;
065: }
066:
067: public String getSpecificationVendor() {
068: return ServerConstants.SPECIFICATION_VENDOR;
069: }
070:
071: public String getImplementationName() {
072: return ServerConstants.IMPLEMENTATION_NAME;
073: }
074:
075: public String getImplementationVersion() {
076: return ServerConstants.IMPLEMENTATION_VERSION;
077: }
078:
079: public String getImplementationVendor() {
080: return ServerConstants.IMPLEMENTATION_VENDOR;
081: }
082:
083: public MBeanNotificationInfo[] getNotificationInfo() {
084: return new MBeanNotificationInfo[] { notificationInfo };
085: }
086:
087: public synchronized void addNotificationListener(
088: NotificationListener listener, NotificationFilter filter,
089: Object handback) throws IllegalArgumentException {
090: notifier.addNotificationListener(listener, filter, handback);
091: }
092:
093: public synchronized void removeNotificationListener(
094: NotificationListener listener, NotificationFilter filter,
095: Object handback) throws ListenerNotFoundException {
096: notifier.removeNotificationListener(listener, filter, handback);
097: }
098:
099: public synchronized void removeNotificationListener(
100: NotificationListener listener)
101: throws ListenerNotFoundException {
102: notifier.removeNotificationListener(listener);
103: }
104:
105: public void sendNotification(Notification notification) {
106: notifier.sendNotification(notification);
107: }
108:
109: }
|