config-api: final parameters
[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(final NotificationType type,
31                                     final NotificationBroadcasterSupport source, final 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     public static CommitJMXNotification afterCommit(final NotificationBroadcasterSupport source, final String messages) {
54         return new CommitJMXNotification(source, messages);
55     }
56
57     enum NotificationType {
58         COMMIT
59     }
60
61 }