mx4j.log
Class LoggerBroadcaster

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by mx4j.log.LoggerBroadcaster
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, LoggerBroadcasterMBean

public class LoggerBroadcaster
extends javax.management.NotificationBroadcasterSupport
implements javax.management.MBeanRegistration, LoggerBroadcasterMBean

This broadcaster MBean allows to redirect MX4J internal logging to registered JMX listeners.

Simply register this MBean in the MBeanServer, register one or more listener (eventually with filters on the notification type), then call (directly or through MBeanServer) one of the start operations. From this moment, MX4J internal logging is redirected to this MBean, and from here to all registered listeners, basing on their filters.

Version:
$Revision: 1.7 $

Nested Class Summary
static class LoggerBroadcaster.LoggerNotifier
           
 
Constructor Summary
LoggerBroadcaster()
           
 
Method Summary
protected  Logger createLoggerPrototype()
           
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
          Returns the metadata information associated with this emitter.
 void postDeregister()
          Callback called just after the MBean has been successfully unregistered.
 void postRegister(java.lang.Boolean registrationDone)
          Callback called just after the MBean has been registered (successfully or not).
 void preDeregister()
          Callback called just before MBean unregistration from the MBeanServer.
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
          Callback called just before MBean registration in the MBeanServer.
 void removeNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback)
          Removes a notification listener from this MBean.
 void sendNotification(javax.management.Notification n)
          Sends the given notification to all registered listeners
 void start()
           
 void start(java.lang.String category)
           
 void stop()
           
 void stop(java.lang.String category)
           
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, handleNotification, removeNotificationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface mx4j.log.LoggerBroadcasterMBean
addNotificationListener
 

Constructor Detail

LoggerBroadcaster

public LoggerBroadcaster()
Method Detail

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Description copied from interface: javax.management.MBeanRegistration
Callback called just before MBean registration in the MBeanServer. Any exception thrown by this method will cause the MBean registration to abort.

Specified by:
preRegister in interface javax.management.MBeanRegistration
Parameters:
server - The MBeanServer on which the MBean will be registered.
name - The ObjectName of the MBean.
Returns:
The ObjectName of the registered MBean, must not be null
Throws:
java.lang.Exception - Any possible exception generated by this method will be caught by the MBeanServer and re-thrown as an MBeanRegistrationException to the client.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Description copied from interface: javax.management.MBeanRegistration
Callback called just after the MBean has been registered (successfully or not).

Specified by:
postRegister in interface javax.management.MBeanRegistration
Parameters:
registrationDone - True if the registration was successful, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: javax.management.MBeanRegistration
Callback called just before MBean unregistration from the MBeanServer. Any exception thrown by this method will cause the MBean unregistration to abort.

Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception - Any possible exception generated by this method will be caught by the MBeanServer and re-thrown as an MBeanRegistrationException to the client.

postDeregister

public void postDeregister()
Description copied from interface: javax.management.MBeanRegistration
Callback called just after the MBean has been successfully unregistered.

Specified by:
postDeregister in interface javax.management.MBeanRegistration

removeNotificationListener

public void removeNotificationListener(javax.management.NotificationListener listener,
                                       javax.management.NotificationFilter filter,
                                       java.lang.Object handback)
                                throws javax.management.ListenerNotFoundException
Description copied from interface: javax.management.NotificationEmitter
Removes a notification listener from this MBean. The MBean must have a registered listener that exactly matches the given listener, filter, and handback parameters.

Specified by:
removeNotificationListener in interface javax.management.NotificationEmitter
Specified by:
removeNotificationListener in interface LoggerBroadcasterMBean
Overrides:
removeNotificationListener in class javax.management.NotificationBroadcasterSupport
Parameters:
listener - The listener that was previously added to this MBean.
filter - The filter that was specified when the listener was added.
handback - The handback that was specified when the listener was added.
Throws:
javax.management.ListenerNotFoundException - If the triple listener, filter, handback is not registered with the emitter

sendNotification

public void sendNotification(javax.management.Notification n)
Description copied from class: javax.management.NotificationBroadcasterSupport
Sends the given notification to all registered listeners

Overrides:
sendNotification in class javax.management.NotificationBroadcasterSupport
Parameters:
n - The notification to send

start

public void start()
Specified by:
start in interface LoggerBroadcasterMBean

start

public void start(java.lang.String category)
Specified by:
start in interface LoggerBroadcasterMBean

stop

public void stop()
Specified by:
stop in interface LoggerBroadcasterMBean

stop

public void stop(java.lang.String category)
Specified by:
stop in interface LoggerBroadcasterMBean

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Description copied from interface: javax.management.NotificationBroadcaster
Returns the metadata information associated with this emitter.

Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster
Overrides:
getNotificationInfo in class javax.management.NotificationBroadcasterSupport

createLoggerPrototype

protected Logger createLoggerPrototype()


Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.