Mechanical code cleanup (config)
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / jmx / notifications / ConfigJMXNotification.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.config.api.jmx.notifications;
10
11 import javax.management.Notification;
12 import javax.management.NotificationBroadcasterSupport;
13 import javax.management.ObjectName;
14 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
15
16 public abstract class ConfigJMXNotification extends Notification {
17
18     /**
19      *
20      */
21     private static final long serialVersionUID = 6754474563863772845L;
22
23     private static long sequenceNumber = 1;
24
25     public static String TYPE_NAME = "configfNotificationProvider";
26     public static ObjectName OBJECT_NAME = ObjectNameUtil.createONWithDomainAndType(TYPE_NAME);
27
28     private final NotificationType type;
29
30     protected ConfigJMXNotification(NotificationType type,
31                                     NotificationBroadcasterSupport source, String message) {
32         super(type.toString(), source, sequenceNumber++, System.nanoTime(), message);
33         this.type = type;
34     }
35
36     @Override
37     public String toString() {
38         return "TransactionProviderJMXNotification [type=" + type + "]";
39     }
40
41     /**
42      * Sends this notification using source that created it
43      */
44     public void send() {
45         ((NotificationBroadcasterSupport) getSource()).sendNotification(this);
46     }
47
48     /**
49      * Creates notification about successful commit execution.
50      *
51      * Intended for config-persister.
52      *
53      * @param transactionName
54      * @param cfgSnapshot
55      */
56     public static CommitJMXNotification afterCommit(NotificationBroadcasterSupport source, String messages) {
57         return new CommitJMXNotification(source, messages);
58     }
59
60     enum NotificationType {
61         COMMIT
62     }
63
64 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.