OPENDJ-879 (CR-1600) Add HTTP access log
Consolidated common code for the *LogPublisher classes prior to implementing the HTTP access log.
LogPublisher.java: ADDED
Unify all the *LogPublisher classes.
Implements Closeable.
AccessLogPublisher.java, DebugLogPublisher.java, ErrorLogPublisher.java:
Now implementing LogPublisher.
Pulled up isConfigurationAcceptable(), initialize*LogPublisher() renamed to initializeLogPublisher(), close(), getDN().
Removed syntactic/spaces differences between all these classes to better expose their commonalities.
Used Set and MAp interfaces rather than comcrete classes.
AccessLogger.java, ErrorLogger.java, DebugLogger.java:
In isJavaClassAcceptable() and getAccessPublisher(), replaced method invocations via reflection by direct method calls.
TextAccessLogPublisher.java, TextAuditLogPublisher.java, TextErrorLogPublisher.java, ThreadFilterTextErrorLogPublisher.java, TextDebugLogPublisher.java, ConsoleDebugLogPublisher.java:
Consequence of renaming the initialize*LogPublisher() methods, or generecizing the isConfigurationAcceptable() methods in their parent classes.
1 files added
12 files modified
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.std.server.AccessLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | |
| | | mayInstantiate = false, |
| | | mayExtend = true, |
| | | mayInvoke = false) |
| | | public abstract class AccessLogPublisher |
| | | <T extends AccessLogPublisherCfg> |
| | | public abstract class AccessLogPublisher<T extends AccessLogPublisherCfg> |
| | | implements LogPublisher<T> |
| | | { |
| | | |
| | | /** |
| | | * Initializes this access publisher provider based on the |
| | | * information in the provided debug publisher configuration. |
| | | * |
| | | * @param config |
| | | * The access publisher configuration that contains the |
| | | * information to use to initialize this access publisher. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of |
| | | * performing the initialization as a result of the server |
| | | * configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not |
| | | * related to the server configuration. |
| | | */ |
| | | public abstract void initializeAccessLogPublisher(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided configuration is acceptable for |
| | | * this access log publisher. It should be possible to call this |
| | | * method on an uninitialized access log publisher instance in order |
| | | * to determine whether the access log publisher would be able to |
| | | * use the provided configuration. <BR> |
| | | * <BR> |
| | | * Note that implementations which use a subclass of the provided |
| | | * configuration class will likely need to cast the configuration to |
| | | * the appropriate subclass type. |
| | | * |
| | | * @param configuration |
| | | * The access log publisher configuration for which to make |
| | | * the determination. |
| | | * @param unacceptableReasons |
| | | * A list that may be used to hold the reasons that the |
| | | * provided configuration is not acceptable. |
| | | * @return {@code true} if the provided configuration is acceptable |
| | | * for this access log publisher, or {@code false} if not. |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(T configuration, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | public abstract void close(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the access logger with information about a |
| | | * new client connection that has been established, regardless of |
| | | * whether it will be immediately terminated. |
| | |
| | | // Do nothing |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the DN of the configuration entry for this access log |
| | | * publisher. |
| | | * |
| | | * @return The configuration entry DN. |
| | | */ |
| | | public abstract DN getDN(); |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | |
| | | import com.sleepycat.je.Transaction; |
| | | import com.sleepycat.je.Database; |
| | | import com.sleepycat.je.DatabaseEntry; |
| | | import com.sleepycat.je.OperationStatus; |
| | | import com.sleepycat.je.Transaction; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.DN; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | |
| | | mayInstantiate=false, |
| | | mayExtend=true, |
| | | mayInvoke=false) |
| | | public abstract class DebugLogPublisher |
| | | <T extends DebugLogPublisherCfg> |
| | | public abstract class DebugLogPublisher<T extends DebugLogPublisherCfg> |
| | | implements LogPublisher<T> |
| | | { |
| | | //The default global settings key. |
| | | private static final String GLOBAL= "_global"; |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Initializes this debug publisher provider based on the |
| | | * information in the provided debug publisher configuration. |
| | | * |
| | | * @param config The debug publisher configuration that contains |
| | | * the information to use to initialize this debug |
| | | * publisher. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in |
| | | * the process of performing the |
| | | * initialization as a result of the |
| | | * server configuration. |
| | | * |
| | | * @throws InitializationException If a problem occurs during |
| | | * initialization that is not |
| | | * related to the server |
| | | * configuration. |
| | | */ |
| | | public abstract void initializeDebugLogPublisher(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided configuration is acceptable for |
| | | * this debug log publisher. It should be possible to call this |
| | | * method on an uninitialized debug log publisher instance in |
| | | * order to determine whether the debug log publisher would be able |
| | | * to use the provided configuration. |
| | | * <BR><BR> |
| | | * Note that implementations which use a subclass of the provided |
| | | * configuration class will likely need to cast the configuration |
| | | * to the appropriate subclass type. |
| | | * |
| | | * @param configuration The debug log publisher |
| | | * configuration for which to make the |
| | | * determination. |
| | | * @param unacceptableReasons A list that may be used to hold the |
| | | * reasons that the provided |
| | | * configuration is not acceptable. |
| | | * |
| | | * @return {@code true} if the provided configuration is acceptable |
| | | * for this debug log publisher, or {@code false} if not. |
| | | */ |
| | | public boolean isConfigurationAcceptable( |
| | | DebugLogPublisherCfg configuration, |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(T configuration, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | // This default implementation does not perform any special |
| | | // validation. It should be overridden by debug log publisher |
| | | // validation. It should be overridden by debug log publisher |
| | | // implementations that wish to perform more detailed validation. |
| | | return true; |
| | | } |
| | |
| | | * |
| | | * @param level The log level for the message. |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The constuctor signature. |
| | | * @param signature The constructor signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param args The parameters provided to the |
| | | * constructor. |
| | |
| | | * @param settings The current trace settings in effect. |
| | | * @param signature The method signature. |
| | | * @param sourceLocation The location of the method in the source. |
| | | * @param decodedForm The string reprentation of the protocol |
| | | * @param decodedForm The string representation of the protocol |
| | | * element. |
| | | * @param stackTrace The stack trace at the time the protocol |
| | | * element is logged or null if its not |
| | |
| | | String decodedForm, |
| | | StackTraceElement[] stackTrace); |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | public abstract void close(); |
| | | |
| | | /** |
| | | * Gets the DN of the configuration entry for this debug log |
| | | * publisher. |
| | | * |
| | | * @return The configuration entry DN. |
| | | */ |
| | | public abstract DN getDN(); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.api; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | |
| | | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.messages.Category; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be |
| | |
| | | mayInstantiate=false, |
| | | mayExtend=true, |
| | | mayInvoke=false) |
| | | public abstract class ErrorLogPublisher |
| | | <T extends ErrorLogPublisherCfg> |
| | | public abstract class ErrorLogPublisher<T extends ErrorLogPublisherCfg> |
| | | implements LogPublisher<T> |
| | | { |
| | | /** |
| | | * The hash map that will be used to define specific log severities |
| | | * for the various categories. |
| | | */ |
| | | protected HashMap<Category,HashSet<Severity>> |
| | | definedSeverities = |
| | | new HashMap<Category, HashSet<Severity>>(); |
| | | protected Map<Category, Set<Severity>> definedSeverities = |
| | | new HashMap<Category, Set<Severity>>(); |
| | | |
| | | |
| | | |
| | |
| | | * The set of default log severities that will be used if no custom |
| | | * severities have been defined for the associated category. |
| | | */ |
| | | protected HashSet<Severity> |
| | | defaultSeverities = new HashSet<Severity>(); |
| | | protected Set<Severity> defaultSeverities = new HashSet<Severity>(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Initializes this access publisher provider based on the |
| | | * information in the provided debug publisher configuration. |
| | | * |
| | | * @param config The error publisher configuration that contains |
| | | * the information to use to initialize this error |
| | | * publisher. |
| | | * |
| | | * @throws ConfigException If an unrecoverable problem arises in |
| | | * the process of performing the |
| | | * initialization as a result of the |
| | | * server configuration. |
| | | * |
| | | * @throws InitializationException If a problem occurs during |
| | | * initialization that is not |
| | | * related to the server |
| | | * configuration. |
| | | */ |
| | | public abstract void initializeErrorLogPublisher(T config) |
| | | throws ConfigException, InitializationException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided configuration is acceptable for |
| | | * this error log publisher. It should be possible to call this |
| | | * method on an uninitialized error log publisher instance in |
| | | * order to determine whether the error log publisher would be able |
| | | * to use the provided configuration. |
| | | * <BR><BR> |
| | | * Note that implementations which use a subclass of the provided |
| | | * configuration class will likely need to cast the configuration |
| | | * to the appropriate subclass type. |
| | | * |
| | | * @param configuration The error log publisher |
| | | * configuration for which to make the |
| | | * determination. |
| | | * @param unacceptableReasons A list that may be used to hold the |
| | | * reasons that the provided |
| | | * configuration is not acceptable. |
| | | * |
| | | * @return {@code true} if the provided configuration is acceptable |
| | | * for this error log publisher, or {@code false} if not. |
| | | */ |
| | | public boolean isConfigurationAcceptable( |
| | | ErrorLogPublisherCfg configuration, |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAcceptable(T configuration, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | // This default implementation does not perform any special |
| | | // validation. It should be overridden by error log publisher |
| | | // validation. It should be overridden by error log publisher |
| | | // implementations that wish to perform more detailed validation. |
| | | return true; |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | public abstract void close(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Writes a message to the error log using the provided information. |
| | | * The message's category and severity information will be used to |
| | | * determine whether to actually log this message. |
| | |
| | | */ |
| | | public abstract void logError(Message message); |
| | | |
| | | /** |
| | | * Gets the DN of the configuration entry for this error log |
| | | * publisher. |
| | | * |
| | | * @return The configuration entry DN. |
| | | */ |
| | | public abstract DN getDN(); |
| | | |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | import java.io.Closeable; |
| | | import java.util.List; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.std.server.LogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | |
| | | /** |
| | | * This class defines the set of methods and structures that must be implemented |
| | | * for a Directory Server log publisher. |
| | | * |
| | | * @param <T> |
| | | * The type of log publisher configuration handled by this log |
| | | * publisher implementation. |
| | | */ |
| | | @org.opends.server.types.PublicAPI( |
| | | stability = org.opends.server.types.StabilityLevel.VOLATILE, |
| | | mayInstantiate = false, |
| | | mayExtend = true, |
| | | mayInvoke = false) |
| | | public interface LogPublisher<T extends LogPublisherCfg> extends Closeable |
| | | { |
| | | |
| | | /** |
| | | * Initializes this publisher provider based on the information in the |
| | | * provided debug publisher configuration. |
| | | * |
| | | * @param config |
| | | * The publisher configuration that contains the information to use |
| | | * to initialize this publisher. |
| | | * @throws ConfigException |
| | | * If an unrecoverable problem arises in the process of performing |
| | | * the initialization as a result of the server configuration. |
| | | * @throws InitializationException |
| | | * If a problem occurs during initialization that is not related to |
| | | * the server configuration. |
| | | */ |
| | | void initializeLogPublisher(T config) throws ConfigException, |
| | | InitializationException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether the provided configuration is acceptable for this log |
| | | * publisher. It should be possible to call this method on an uninitialized |
| | | * log publisher instance in order to determine whether the log publisher |
| | | * would be able to use the provided configuration. |
| | | * <BR><BR> |
| | | * Note that implementations which use a subclass of the provided |
| | | * configuration class will likely need to cast the configuration to the |
| | | * appropriate subclass type. |
| | | * |
| | | * @param configuration |
| | | * The log publisher configuration for which to make the |
| | | * determination. |
| | | * @param unacceptableReasons |
| | | * A list that may be used to hold the reasons that the provided |
| | | * configuration is not acceptable. |
| | | * @return {@code true} if the provided configuration is acceptable for this |
| | | * log publisher, or {@code false} if not. |
| | | */ |
| | | boolean isConfigurationAcceptable(T configuration, |
| | | List<Message> unacceptableReasons); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Close this publisher. |
| | | */ |
| | | @Override |
| | | void close(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the DN of the configuration entry for this log publisher. |
| | | * |
| | | * @return The configuration entry DN. |
| | | */ |
| | | DN getDN(); |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | import org.opends.messages.Message; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.util.List; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.AccessLogPublisher; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.admin.std.server.AccessLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.AccessLogPublisherCfgDefn; |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.std.meta.AccessLogPublisherCfgDefn; |
| | | import org.opends.server.admin.std.server.AccessLogPublisherCfg; |
| | | import org.opends.server.api.AccessLogPublisher; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.config.ConfigException; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import static org.opends.messages.ConfigMessages. |
| | | ERR_CONFIG_LOGGER_CANNOT_CREATE_LOGGER; |
| | | import static org.opends.messages.ConfigMessages. |
| | | ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS; |
| | | |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import org.opends.server.types.*; |
| | | |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable( |
| | | AccessLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | AccessLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(AccessLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | AccessLogPublisherCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | AccessLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | AccessLogPublisherCfg config) |
| | | { |
| | |
| | | AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | AccessLogPublisher<?> publisher = null; |
| | | Class<? extends AccessLogPublisher<?>> theClass; |
| | | try { |
| | | theClass = (Class<? extends AccessLogPublisher<?>>) |
| | | pd.loadClass(className, AccessLogPublisher.class); |
| | | publisher = theClass.newInstance(); |
| | | // Load the class and cast it to a AccessLogPublisher. |
| | | AccessLogPublisher<AccessLogPublisherCfg> publisher = |
| | | pd.loadClass(className, AccessLogPublisher.class).newInstance(); |
| | | // The class is valid as far as we can tell. |
| | | return publisher.isConfigurationAcceptable(config, unacceptableReasons); |
| | | } catch (Exception e) { |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get( |
| | | className, |
| | |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | AccessLogPublisherCfg.class, |
| | | List.class); |
| | | Boolean acceptable = (Boolean) method.invoke(publisher, config, |
| | | unacceptableReasons); |
| | | |
| | | if (! acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | } catch (Exception e) { |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get( |
| | | className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private AccessLogPublisher<?> getAccessPublisher(AccessLogPublisherCfg config) |
| | |
| | | AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a AccessLogPublisher. |
| | | AccessLogPublisher<?> accessLogPublisher; |
| | | try { |
| | | @SuppressWarnings("unchecked") |
| | | Class<? extends AccessLogPublisher<?>> theClass = |
| | | (Class<? extends AccessLogPublisher<?>>) pd |
| | | .loadClass(className, AccessLogPublisher.class); |
| | | accessLogPublisher = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeAccessLogPublisher", config |
| | | .configurationClass()); |
| | | method.invoke(accessLogPublisher, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get( |
| | | className, config.dn().toString(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | // Load the class and cast it to a AccessLogPublisher. |
| | | AccessLogPublisher<AccessLogPublisherCfg> accessLogPublisher = |
| | | pd.loadClass(className, AccessLogPublisher.class).newInstance(); |
| | | accessLogPublisher.initializeLogPublisher(config); |
| | | // The access publisher has been successfully initialized. |
| | | return accessLogPublisher; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | className, config.dn().toString(), String.valueOf(e)); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // The access publisher has been successfully initialized. |
| | | return accessLogPublisher; |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | import org.opends.messages.Message; |
| | | |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.List; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.util.List; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | /** |
| | | * This class defines the wrapper that will invoke all registered error loggers |
| | | * for each type of request received or response sent. If no error log |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(ErrorLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | ErrorLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(ErrorLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | ErrorLogPublisherCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable( |
| | | ErrorLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete( |
| | | ErrorLogPublisherCfg config) |
| | | { |
| | |
| | | ErrorLogPublisherCfgDefn d = ErrorLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | ErrorLogPublisher publisher = null; |
| | | Class<? extends ErrorLogPublisher> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, ErrorLogPublisher.class); |
| | | publisher = theClass.newInstance(); |
| | | // Load the class and cast it to a ErrorLogPublisher. |
| | | ErrorLogPublisher<ErrorLogPublisherCfg> publisher = |
| | | pd.loadClass(className, ErrorLogPublisher.class).newInstance(); |
| | | // The class is valid as far as we can tell. |
| | | return publisher.isConfigurationAcceptable(config, unacceptableReasons); |
| | | } catch (Exception e) { |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS.get( |
| | | className, |
| | |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | ErrorLogPublisherCfg.class, |
| | | List.class); |
| | | Boolean acceptable = (Boolean) method.invoke(publisher, config, |
| | | unacceptableReasons); |
| | | |
| | | if (! acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | } catch (Exception e) { |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS.get( |
| | | className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private ErrorLogPublisher getErrorPublisher(ErrorLogPublisherCfg config) |
| | |
| | | ErrorLogPublisherCfgDefn d = ErrorLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a ErrorLogPublisher. |
| | | Class<? extends ErrorLogPublisher> theClass; |
| | | ErrorLogPublisher errorLogPublisher; |
| | | try { |
| | | theClass = pd.loadClass(className, ErrorLogPublisher.class); |
| | | errorLogPublisher = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeErrorLogPublisher", config |
| | | .configurationClass()); |
| | | method.invoke(errorLogPublisher, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS.get( |
| | | className, config.dn().toString(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | // Load the class and cast it to a ErrorLogPublisher. |
| | | ErrorLogPublisher<ErrorLogPublisherCfg> errorLogPublisher = |
| | | pd.loadClass(className, ErrorLogPublisher.class).newInstance(); |
| | | errorLogPublisher.initializeLogPublisher(config); |
| | | // The error publisher has been successfully initialized. |
| | | return errorLogPublisher; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | className, config.dn().toString(), String.valueOf(e)); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // The error publisher has been successfully initialized. |
| | | return errorLogPublisher; |
| | | } |
| | | |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void initializeAccessLogPublisher( |
| | | final FileBasedAccessLogPublisherCfg cfg) throws ConfigException, |
| | | InitializationException |
| | | public void initializeLogPublisher(final FileBasedAccessLogPublisherCfg cfg) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | final File logFile = getFileForPath(cfg.getLogFile()); |
| | | final FileNamingPolicy fnPolicy = new TimeStampNaming(logFile); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011 ForgeRock AS. |
| | | * Portions copyright 2011-2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.types.ResultCode.SUCCESS; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import static org.opends.server.util.StaticUtils.getBytes; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import static org.opends.server.types.ResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedAuditLogPublisherCfg config) |
| | | { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public void initializeAccessLogPublisher(FileBasedAuditLogPublisherCfg cfg) |
| | | public void initializeLogPublisher(FileBasedAuditLogPublisherCfg cfg) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(cfg.getLogFile()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedAuditLogPublisherCfg config, List<Message> unacceptableReasons) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2012 ForgeRock AS. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | import org.opends.messages.Message; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.LoggerMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | import org.opends.server.api.*; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.LoggerMessages.*; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.messages.Category; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.admin.std.server.FileBasedErrorLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn; |
| | | import org.opends.server.admin.std.server.FileBasedErrorLogPublisherCfg; |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.TimeThread; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | /** |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeErrorLogPublisher(FileBasedErrorLogPublisherCfg config) |
| | | @Override |
| | | public void initializeLogPublisher(FileBasedErrorLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public boolean isConfigurationAcceptable(ErrorLogPublisherCfg configuration, |
| | | List<Message> unacceptableReasons) |
| | | public boolean isConfigurationAcceptable( |
| | | FileBasedErrorLogPublisherCfg config, List<Message> unacceptableReasons) |
| | | { |
| | | FileBasedErrorLogPublisherCfg config = |
| | | (FileBasedErrorLogPublisherCfg) configuration; |
| | | |
| | | return isConfigurationChangeAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedErrorLogPublisherCfg config, List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedErrorLogPublisherCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void logError(Message message) |
| | | { |
| | | Severity severity = message.getDescriptor().getSeverity(); |
| | | Category category = message.getDescriptor().getCategory(); |
| | | int msgId = message.getDescriptor().getId(); |
| | | HashSet<Severity> severities = definedSeverities.get(category); |
| | | Set<Severity> severities = definedSeverities.get(category); |
| | | if(severities == null) |
| | | { |
| | | severities = defaultSeverities; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN getDN() |
| | | { |
| | | if(currentConfig != null) |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.messages.Category; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.Severity; |
| | | import org.opends.messages.Category; |
| | | import org.opends.server.admin.std.server.ErrorLogPublisherCfg; |
| | | import org.opends.server.api.ErrorLogPublisher; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.TimeThread; |
| | | |
| | | /** |
| | | * This class provides an implementation of an error logger where only messages |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeErrorLogPublisher(ErrorLogPublisherCfg config) |
| | | @Override |
| | | public void initializeLogPublisher(ErrorLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // This class should only be used internally in the server and not be |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void logError(Message message) |
| | | { |
| | | if (message != null) { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN getDN() |
| | | { |
| | | // This class should only be used internally in the server and not be |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.loggers.debug; |
| | | import org.opends.messages.Message; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.lang.reflect.Method; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.ClassPropertyDefinition; |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | /** |
| | | * A logger for debug and trace logging. DebugLogger provides a debugging |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(DebugLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(DebugLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(DebugLogPublisherCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | DebugLogPublisherCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(DebugLogPublisherCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | } |
| | | |
| | | return debugLogPublisher != null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult |
| | | applyConfigurationDelete(DebugLogPublisherCfg config) |
| | | { |
| | |
| | | DebugLogPublisherCfgDefn d = DebugLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | DebugLogPublisher publisher = null; |
| | | Class<? extends DebugLogPublisher> theClass; |
| | | try { |
| | | theClass = pd.loadClass(className, DebugLogPublisher.class); |
| | | publisher = theClass.newInstance(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | DebugLogPublisher<DebugLogPublisherCfg> publisher = |
| | | pd.loadClass(className, DebugLogPublisher.class).newInstance(); |
| | | // The class is valid as far as we can tell. |
| | | return publisher.isConfigurationAcceptable(config, unacceptableReasons); |
| | | } catch (Exception e) { |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS.get( |
| | | className, |
| | |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // Check that the implementation class implements the correct interface. |
| | | try { |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("isConfigurationAcceptable", |
| | | DebugLogPublisherCfg.class, |
| | | List.class); |
| | | Boolean acceptable = (Boolean) method.invoke(publisher, config, |
| | | unacceptableReasons); |
| | | |
| | | if (! acceptable) |
| | | { |
| | | return false; |
| | | } |
| | | } catch (Exception e) { |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS.get( |
| | | className, |
| | | config.dn().toString(), |
| | | String.valueOf(e)); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | | } |
| | | // The class is valid as far as we can tell. |
| | | return true; |
| | | } |
| | | |
| | | private DebugLogPublisher getDebugPublisher(DebugLogPublisherCfg config) |
| | |
| | | DebugLogPublisherCfgDefn d = DebugLogPublisherCfgDefn.getInstance(); |
| | | ClassPropertyDefinition pd = |
| | | d.getJavaClassPropertyDefinition(); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | Class<? extends DebugLogPublisher> theClass; |
| | | DebugLogPublisher debugLogPublisher; |
| | | try { |
| | | theClass = pd.loadClass(className, DebugLogPublisher.class); |
| | | debugLogPublisher = theClass.newInstance(); |
| | | |
| | | // Determine the initialization method to use: it must take a |
| | | // single parameter which is the exact type of the configuration |
| | | // object. |
| | | Method method = theClass.getMethod("initializeDebugLogPublisher", config |
| | | .configurationClass()); |
| | | method.invoke(debugLogPublisher, config); |
| | | } |
| | | catch (InvocationTargetException ite) |
| | | { |
| | | // Rethrow the exceptions thrown be the invoked method. |
| | | Throwable e = ite.getTargetException(); |
| | | Message message = ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS.get( |
| | | className, config.dn().toString(), stackTraceToSingleLineString(e)); |
| | | throw new ConfigException(message, e); |
| | | // Load the class and cast it to a DebugLogPublisher. |
| | | DebugLogPublisher<DebugLogPublisherCfg> debugLogPublisher = |
| | | pd.loadClass(className, DebugLogPublisher.class).newInstance(); |
| | | debugLogPublisher.initializeLogPublisher(config); |
| | | // The debug publisher has been successfully initialized. |
| | | return debugLogPublisher; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | className, config.dn().toString(), String.valueOf(e)); |
| | | throw new ConfigException(message, e); |
| | | } |
| | | |
| | | // The debug publisher has been successfully initialized. |
| | | return debugLogPublisher; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | import org.opends.messages.Message; |
| | | |
| | | import org.opends.server.api.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.server.admin.std.server.DebugTargetCfg; |
| | | import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString; |
| | | import static org.opends.server.util.StaticUtils.getFileForPath; |
| | | import static org.opends.server.util.ServerConstants.PROPERTY_DEBUG_TARGET; |
| | | import org.opends.server.admin.std.server.DebugTargetCfg; |
| | | import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.server.ConfigurationDeleteListener; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import static org.opends.messages.ConfigMessages. |
| | | ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER; |
| | | import static org.opends.messages.ConfigMessages. |
| | | ERR_CONFIG_LOGGING_CANNOT_OPEN_FILE; |
| | | import static org.opends.messages.ConfigMessages. |
| | | ERR_CONFIG_LOGGING_INSANE_MODE; |
| | | import static org.opends.messages.ConfigMessages. |
| | | ERR_CONFIG_LOGGING_MODE_INVALID; |
| | | |
| | | |
| | | import java.util.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationAcceptable(DebugLogPublisherCfg configuration, |
| | | List<Message> unacceptableReasons) |
| | | @Override |
| | | public boolean isConfigurationAcceptable( |
| | | FileBasedDebugLogPublisherCfg config, List<Message> unacceptableReasons) |
| | | { |
| | | FileBasedDebugLogPublisherCfg config = |
| | | (FileBasedDebugLogPublisherCfg) configuration; |
| | | return isConfigurationChangeAcceptable(config, unacceptableReasons); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeDebugLogPublisher(FileBasedDebugLogPublisherCfg config) |
| | | @Override |
| | | public void initializeLogPublisher(FileBasedDebugLogPublisherCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | File logFile = getFileForPath(config.getLogFile()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedDebugLogPublisherCfg config, List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedDebugLogPublisherCfg config) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(DebugTargetCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(DebugTargetCfg config, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(DebugTargetCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(DebugTargetCfg config) |
| | | { |
| | | // Default result code. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceConstructor(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceStaticMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceReturn(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceThrown(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceMessage(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceCaught(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceJEAccess(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceData(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceProtocolElement(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void close() |
| | | { |
| | | writer.shutdown(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN getDN() |
| | | { |
| | | if(currentConfig != null) |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.LogCategory; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.loggers.debug.DebugStackTraceFormatter; |
| | | import org.opends.server.loggers.debug.DebugMessageFormatter; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import com.sleepycat.je.*; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.loggers.LogCategory; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.loggers.debug.DebugMessageFormatter; |
| | | import org.opends.server.loggers.debug.DebugStackTraceFormatter; |
| | | import org.opends.server.loggers.debug.TraceSettings; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.sleepycat.je.*; |
| | | |
| | | /** |
| | | * The debug log publisher implementation that writes debug messages in a |
| | | * friendly for console output. |
| | | */ |
| | | public class ConsoleDebugLogPublisher extends DebugLogPublisher |
| | | public class ConsoleDebugLogPublisher extends |
| | | DebugLogPublisher<DebugLogPublisherCfg> |
| | | { |
| | | /** |
| | | * The print stream where tracing will be sent. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void initializeDebugLogPublisher(DebugLogPublisherCfg config) |
| | | @Override |
| | | public void initializeLogPublisher(DebugLogPublisherCfg config) |
| | | throws ConfigException, InitializationException { |
| | | // This pubisher is not configurable. |
| | | // This publisher is not configurable. |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceConstructor(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceStaticMethodEntry(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceReturn(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceThrown(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceMessage(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceCaught(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceJEAccess(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceData(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void traceProtocolElement(LogLevel level, |
| | | TraceSettings settings, |
| | | String signature, |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void close() |
| | | { |
| | | // Nothing to do. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN getDN() |
| | | { |
| | | // There is no configuration DN associated with this publisher. |