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