X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2Fjmx%2Fnotifications%2FConfigJMXNotification.java;fp=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2Fjmx%2Fnotifications%2FConfigJMXNotification.java;h=0d9e5497207ba45f7a3ecd1221f5ea8994b346bc;hp=0000000000000000000000000000000000000000;hb=23fe9ca678ada6263fec5dd996f4025e4a32fcf5;hpb=071a641d7c12c0e6112d5ce0afe806b54f116ed2 diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java new file mode 100644 index 0000000000..0d9e549720 --- /dev/null +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/notifications/ConfigJMXNotification.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.config.api.jmx.notifications; + +import javax.management.Notification; +import javax.management.NotificationBroadcasterSupport; +import javax.management.ObjectName; +import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; + +public abstract class ConfigJMXNotification extends Notification { + + /** + * + */ + private static final long serialVersionUID = 6754474563863772845L; + + private static long sequenceNumber = 1; + + public static String TYPE_NAME = "configfNotificationProvider"; + public static ObjectName OBJECT_NAME = ObjectNameUtil.createONWithDomainAndType(TYPE_NAME); + + private final NotificationType type; + + protected ConfigJMXNotification(NotificationType type, + NotificationBroadcasterSupport source, String message) { + super(type.toString(), source, sequenceNumber++, System.nanoTime(), message); + this.type = type; + } + + @Override + public String toString() { + return "TransactionProviderJMXNotification [type=" + type + "]"; + } + + /** + * Sends this notification using source that created it + */ + public void send() { + ((NotificationBroadcasterSupport) getSource()).sendNotification(this); + } + + /** + * Creates notification about successful commit execution. + * + * Intended for config-persister. + * + * @param transactionName + * @param cfgSnapshot + */ + public static CommitJMXNotification afterCommit(NotificationBroadcasterSupport source, String messages) { + return new CommitJMXNotification(source, messages); + } + + enum NotificationType { + COMMIT; + } + +}