| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | * Portions Copyright 2026 3A Systems, LLC. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.ConcurrentMap; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | /** The number of times this alert handler has been invoked. */ |
| | | private static AtomicInteger alertCount = new AtomicInteger(0); |
| | | |
| | | /** The number of times this alert handler has been invoked, per alert type. */ |
| | | private static final ConcurrentMap<String, AtomicInteger> alertCountByType = new ConcurrentHashMap<>(); |
| | | |
| | | /** Creates a new instance of this SMTP alert handler. */ |
| | | public DummyAlertHandler() |
| | | { |
| | |
| | | LocalizableMessage alertMessage) |
| | | { |
| | | alertCount.incrementAndGet(); |
| | | alertCountByType.computeIfAbsent(alertType, type -> new AtomicInteger()).incrementAndGet(); |
| | | } |
| | | |
| | | /** |
| | |
| | | return alertCount.get(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the number of times that this alert handler has been invoked with the |
| | | * provided alert type. |
| | | * |
| | | * @param alertType The type of the alert notifications to count. |
| | | * |
| | | * @return The number of times that this alert handler has been given an alert |
| | | * notification of that type. |
| | | */ |
| | | public static int getAlertCount(String alertType) |
| | | { |
| | | final AtomicInteger count = alertCountByType.get(alertType); |
| | | return count != null ? count.get() : 0; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(AlertHandlerCfg configuration, |