1 4 package com.tc.management.beans.logging; 5 6 import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong; 7 8 import com.tc.management.AbstractTerracottaMBean; 9 10 import javax.management.MBeanNotificationInfo ; 11 import javax.management.NotCompliantMBeanException ; 12 import javax.management.Notification ; 13 14 public final class TCLoggingBroadcaster extends AbstractTerracottaMBean implements TCLoggingBroadcasterMBean { 15 16 private static final String LOGGING_EVENT_TYPE = "tc.logging.event"; 17 private static final MBeanNotificationInfo [] NOTIFICATION_INFO; 18 static { 19 final String [] notifTypes = new String [] { LOGGING_EVENT_TYPE }; 20 final String name = Notification .class.getName(); 21 final String description = "Each notification sent contains a Terracotta logging event"; 22 NOTIFICATION_INFO = new MBeanNotificationInfo [] { new MBeanNotificationInfo (notifTypes, name, description) }; 23 } 24 25 private final SynchronizedLong sequenceNumber = new SynchronizedLong(0L); 26 27 public void reset() { 28 } 30 31 public TCLoggingBroadcaster() throws NotCompliantMBeanException { 32 super(TCLoggingBroadcasterMBean.class, true); 33 } 34 35 public MBeanNotificationInfo [] getNotificationInfo() { 36 return NOTIFICATION_INFO; 37 } 38 39 public void broadcastLogEvent(final String event) { 40 final Notification notif = new Notification (LOGGING_EVENT_TYPE, this, sequenceNumber.increment(), System 41 .currentTimeMillis(), event); 42 sendNotification(notif); 43 } 44 45 } 46 | Popular Tags |