Merge "Fix raw references to Iterator"
[controller.git] / opendaylight / netconf / netconf-api / src / main / java / org / opendaylight / controller / netconf / api / jmx / NetconfJMXNotification.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.netconf.api.jmx;
10
11 import java.util.Set;
12 import javax.management.Notification;
13 import javax.management.NotificationBroadcasterSupport;
14 import org.w3c.dom.Element;
15
16 public abstract class NetconfJMXNotification extends Notification {
17
18     /**
19      *
20      */
21     private static final long serialVersionUID = 6754474563863772845L;
22
23     private static long sequenceNumber = 1;
24
25     private final TransactionProviderJMXNotificationType type;
26
27     protected NetconfJMXNotification(TransactionProviderJMXNotificationType type,
28             NotificationBroadcasterSupport source, String message) {
29         super(type.toString(), source, sequenceNumber++, System.nanoTime(), message);
30         this.type = type;
31     }
32
33     @Override
34     public String toString() {
35         return "TransactionProviderJMXNotification [type=" + type + "]";
36     }
37
38     /**
39      * Sends this notification using source that created it
40      */
41     public void send() {
42         ((NotificationBroadcasterSupport) getSource()).sendNotification(this);
43     }
44
45     /**
46      * Creates notification about successful commit execution.
47      *
48      * Intended for config-persister.
49      *
50      * @param transactionName
51      * @param cfgSnapshot
52      */
53     public static CommitJMXNotification afterCommit(NotificationBroadcasterSupport source, String message,
54             Element cfgSnapshot, Set<String> capabilities) {
55         return new CommitJMXNotification(source, message, cfgSnapshot, capabilities);
56     }
57
58     static enum TransactionProviderJMXNotificationType {
59         commit;
60     }
61
62 }