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 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.api; 028 import org.opends.messages.Message; 029 030 031 032 import java.util.HashSet; 033 import java.util.HashMap; 034 import java.util.List; 035 036 import org.opends.server.admin.std.server.ErrorLogPublisherCfg; 037 import org.opends.server.config.ConfigException; 038 039 040 import org.opends.server.types.InitializationException; 041 import org.opends.server.types.DN; 042 import org.opends.messages.Severity; 043 import org.opends.messages.Category; 044 045 046 /** 047 * This class defines the set of methods and structures that must be 048 * implemented for a Directory Server error log publisher. 049 * 050 * @param <T> The type of error log publisher configuration handled 051 * by this log publisher implementation. 052 */ 053 @org.opends.server.types.PublicAPI( 054 stability=org.opends.server.types.StabilityLevel.VOLATILE, 055 mayInstantiate=false, 056 mayExtend=true, 057 mayInvoke=false) 058 public abstract class ErrorLogPublisher 059 <T extends ErrorLogPublisherCfg> 060 { 061 /** 062 * The hash map that will be used to define specific log severities 063 * for the various categories. 064 */ 065 protected HashMap<Category,HashSet<Severity>> 066 definedSeverities = 067 new HashMap<Category, HashSet<Severity>>(); 068 069 070 071 /** 072 * The set of default log severities that will be used if no custom 073 * severities have been defined for the associated category. 074 */ 075 protected HashSet<Severity> 076 defaultSeverities = new HashSet<Severity>(); 077 078 079 080 /** 081 * Initializes this access publisher provider based on the 082 * information in the provided debug publisher configuration. 083 * 084 * @param config The error publisher configuration that contains 085 * the information to use to initialize this error 086 * publisher. 087 * 088 * @throws ConfigException If an unrecoverable problem arises in 089 * the process of performing the 090 * initialization as a result of the 091 * server configuration. 092 * 093 * @throws InitializationException If a problem occurs during 094 * initialization that is not 095 * related to the server 096 * configuration. 097 */ 098 public abstract void initializeErrorLogPublisher(T config) 099 throws ConfigException, InitializationException; 100 101 102 103 /** 104 * Indicates whether the provided configuration is acceptable for 105 * this error log publisher. It should be possible to call this 106 * method on an uninitialized error log publisher instance in 107 * order to determine whether the error log publisher would be able 108 * to use the provided configuration. 109 * <BR><BR> 110 * Note that implementations which use a subclass of the provided 111 * configuration class will likely need to cast the configuration 112 * to the appropriate subclass type. 113 * 114 * @param configuration The error log publisher 115 * configuration for which to make the 116 * determination. 117 * @param unacceptableReasons A list that may be used to hold the 118 * reasons that the provided 119 * configuration is not acceptable. 120 * 121 * @return {@code true} if the provided configuration is acceptable 122 * for this error log publisher, or {@code false} if not. 123 */ 124 public boolean isConfigurationAcceptable( 125 ErrorLogPublisherCfg configuration, 126 List<Message> unacceptableReasons) 127 { 128 // This default implementation does not perform any special 129 // validation. It should be overridden by error log publisher 130 // implementations that wish to perform more detailed validation. 131 return true; 132 } 133 134 135 136 /** 137 * Close this publisher. 138 */ 139 public abstract void close(); 140 141 142 143 /** 144 * Writes a message to the error log using the provided information. 145 * The message's category and severity information will be used to 146 * determine whether to actually log this message. 147 * 148 * @param message The message to be logged. 149 */ 150 public abstract void logError(Message message); 151 152 /** 153 * Gets the DN of the configuration entry for this error log 154 * publisher. 155 * 156 * @return The configuration entry DN. 157 */ 158 public abstract DN getDN(); 159 160 } 161