001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014-2015 ForgeRock AS 026 */ 027package org.opends.server.api; 028import org.forgerock.i18n.LocalizableMessage; 029 030 031 032import java.util.List; 033 034import org.opends.server.admin.std.server.AlertHandlerCfg; 035import org.forgerock.opendj.config.server.ConfigException; 036import org.opends.server.types.InitializationException; 037 038 039/** 040 * This interface defines the set of methods that must be implemented 041 * for a Directory Server alert handler. Alert handlers are used to 042 * present alert notifications in various forms like JMX, e-mail, or 043 * paging. 044 * 045 * @param <T> The type of configuration handled by this alert 046 * handler. 047 */ 048@org.opends.server.types.PublicAPI( 049 stability=org.opends.server.types.StabilityLevel.VOLATILE, 050 mayInstantiate=false, 051 mayExtend=true, 052 mayInvoke=false) 053public interface AlertHandler<T extends AlertHandlerCfg> 054{ 055 /** 056 * Initializes this alert handler based on the information in the 057 * provided configuration entry. 058 * 059 * @param configuration The configuration to use to initialize 060 * this alert handler. 061 * 062 * @throws ConfigException If the provided entry does not contain 063 * a valid configuration for this alert 064 * handler. 065 * 066 * @throws InitializationException If a problem occurs during 067 * initialization that is not 068 * related to the server 069 * configuration. 070 */ 071 void initializeAlertHandler(T configuration) 072 throws ConfigException, InitializationException; 073 074 075 076 /** 077 * Retrieves the current configuration for this alert handler. 078 * 079 * @return The current configuration for this alert handler. 080 */ 081 AlertHandlerCfg getAlertHandlerConfiguration(); 082 083 084 085 /** 086 * Indicates whether the provided configuration is acceptable for 087 * this alert handler. 088 * 089 * @param configuration The configuration for which to make 090 * tje determination. 091 * @param unacceptableReasons A list to which human-readable 092 * reasons may be added to explain why 093 * the configuration is not acceptable. 094 * 095 * @return {@code true} if the provided configuration is 096 * acceptable, or {@code false} if it is not. 097 */ 098 boolean isConfigurationAcceptable( 099 AlertHandlerCfg configuration, 100 List<LocalizableMessage> unacceptableReasons); 101 102 103 104 /** 105 * Performs any necessary cleanup that may be necessary when this 106 * alert handler is finalized. 107 */ 108 void finalizeAlertHandler(); 109 110 111 112 /** 113 * Sends an alert notification based on the provided information. 114 * 115 * @param generator The alert generator that created the alert. 116 * @param alertType The alert type name for this alert. 117 * @param alertMessage A message (possibly {@code null}) that can 118 * provide more information about this alert. 119 */ 120 void sendAlertNotification(AlertGenerator generator, 121 String alertType, 122 LocalizableMessage alertMessage); 123} 124