Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / jmx / notifications / ConfigJMXNotification.java
1 /*
2  * Copyright (c) 2013, 2017 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     private static final long serialVersionUID = 6754474563863772845L;
19
20     private static long sequenceNumber = 1;
21
22     public static final String TYPE_NAME = "configfNotificationProvider";
23     public static final ObjectName OBJECT_NAME = ObjectNameUtil.createONWithDomainAndType(TYPE_NAME);
24
25     private final NotificationType type;
26
27     protected ConfigJMXNotification(final NotificationType type, final NotificationBroadcasterSupport source,
28             final 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. Intended for
47      * config-persister.
48      */
49     public static CommitJMXNotification afterCommit(final NotificationBroadcasterSupport source,
50             final String messages) {
51         return new CommitJMXNotification(source, messages);
52     }
53
54     enum NotificationType {
55         COMMIT
56     }
57 }

©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.