001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2016 ForgeRock AS.
016 */
017package org.opends.server.loggers;
018
019import org.forgerock.opendj.server.config.server.LogRotationPolicyCfg;
020import org.opends.server.types.InitializationException;
021import org.forgerock.opendj.config.server.ConfigException;
022
023
024/**
025 * This interface describes the rotation policy that should be used
026 * for the logger. Supported policies include size based and time
027 * based.
028 *
029 * @param <T> The type of rotation policy configuration handled by
030 *            this retention policy implementation.
031 */
032public interface RotationPolicy<T extends LogRotationPolicyCfg>
033{
034  /**
035   * Initializes this log rotation policy based on the
036   * information in the provided rotation policy configuration.
037   *
038   * @param config
039   *          The rotation policy configuration that contains the
040   *          information to use to initialize this policy.
041   * @throws ConfigException
042   *           If an unrecoverable problem arises in the process of
043   *           performing the initialization as a result of the server
044   *           configuration.
045   * @throws InitializationException
046   *           If a problem occurs during initialization that is not
047   *           related to the server configuration.
048   */
049  void initializeLogRotationPolicy(T config)
050      throws ConfigException, InitializationException;
051
052
053  /**
054   * This method indicates if the log file should be rotated or not.
055   *
056   * @param writer
057   *          the file writer to be checked.
058   * @return true if the log file should be rotated, false otherwise.
059   */
060  boolean rotateFile(RotatableLogFile writer);
061
062
063}
064