01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.management.beans.logging;
05:
06: import EDU.oswego.cs.dl.util.concurrent.SynchronizedLong;
07:
08: import com.tc.management.AbstractTerracottaMBean;
09:
10: import javax.management.MBeanNotificationInfo;
11: import javax.management.NotCompliantMBeanException;
12: import javax.management.Notification;
13:
14: public final class TCLoggingBroadcaster extends AbstractTerracottaMBean
15: implements TCLoggingBroadcasterMBean {
16:
17: private static final String LOGGING_EVENT_TYPE = "tc.logging.event";
18: private static final MBeanNotificationInfo[] NOTIFICATION_INFO;
19: static {
20: final String[] notifTypes = new String[] { LOGGING_EVENT_TYPE };
21: final String name = Notification.class.getName();
22: final String description = "Each notification sent contains a Terracotta logging event";
23: NOTIFICATION_INFO = new MBeanNotificationInfo[] { new MBeanNotificationInfo(
24: notifTypes, name, description) };
25: }
26:
27: private final SynchronizedLong sequenceNumber = new SynchronizedLong(
28: 0L);
29:
30: public void reset() {
31: // nothing to reset
32: }
33:
34: public TCLoggingBroadcaster() throws NotCompliantMBeanException {
35: super (TCLoggingBroadcasterMBean.class, true);
36: }
37:
38: public MBeanNotificationInfo[] getNotificationInfo() {
39: return NOTIFICATION_INFO;
40: }
41:
42: public void broadcastLogEvent(final String event) {
43: final Notification notif = new Notification(LOGGING_EVENT_TYPE,
44: this, sequenceNumber.increment(), System
45: .currentTimeMillis(), event);
46: sendNotification(notif);
47: }
48:
49: }
|