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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.api; 028 import org.opends.messages.Message; 029 030 031 032 import java.util.List; 033 034 import org.opends.server.admin.std.server.AlertHandlerCfg; 035 import org.opends.server.config.ConfigException; 036 import 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) 053 public 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 public 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 public 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 public boolean isConfigurationAcceptable( 099 AlertHandlerCfg configuration, 100 List<Message> unacceptableReasons); 101 102 103 104 /** 105 * Performs any necessary cleanup that may be necessary when this 106 * alert handler is finalized. 107 */ 108 public 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 public void sendAlertNotification(AlertGenerator generator, 121 String alertType, 122 Message alertMessage); 123 } 124