KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > management > beans > logging > TCLoggingBroadcaster


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc;
11 import javax.management.NotCompliantMBeanException JavaDoc;
12 import javax.management.Notification JavaDoc;
13
14 public final class TCLoggingBroadcaster extends AbstractTerracottaMBean implements TCLoggingBroadcasterMBean {
15
16   private static final String JavaDoc LOGGING_EVENT_TYPE = "tc.logging.event";
17   private static final MBeanNotificationInfo JavaDoc[] NOTIFICATION_INFO;
18   static {
19     final String JavaDoc[] notifTypes = new String JavaDoc[] { LOGGING_EVENT_TYPE };
20     final String JavaDoc name = Notification JavaDoc.class.getName();
21     final String JavaDoc description = "Each notification sent contains a Terracotta logging event";
22     NOTIFICATION_INFO = new MBeanNotificationInfo JavaDoc[] { new MBeanNotificationInfo JavaDoc(notifTypes, name, description) };
23   }
24
25   private final SynchronizedLong sequenceNumber = new SynchronizedLong(0L);
26
27   public void reset() {
28     // nothing to reset
29
}
30
31   public TCLoggingBroadcaster() throws NotCompliantMBeanException JavaDoc {
32     super(TCLoggingBroadcasterMBean.class, true);
33   }
34
35   public MBeanNotificationInfo JavaDoc[] getNotificationInfo() {
36     return NOTIFICATION_INFO;
37   }
38
39   public void broadcastLogEvent(final String JavaDoc event) {
40     final Notification JavaDoc notif = new Notification JavaDoc(LOGGING_EVENT_TYPE, this, sequenceNumber.increment(), System
41         .currentTimeMillis(), event);
42     sendNotification(notif);
43   }
44
45 }
46
Popular Tags