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.loggers;
028    
029    import org.opends.server.admin.std.server.LogRetentionPolicyCfg;
030    import org.opends.server.config.ConfigException;
031    import org.opends.server.types.InitializationException;
032    import org.opends.server.types.DirectoryException;
033    
034    import java.io.File;
035    
036    /**
037     * This interface describes the retention policy that should be used
038     * for the logger. Supported policies include number of files and
039     * disk utilization (for Java 6).
040     *
041     * @param <T> The type of retention policy configuration handled by
042     *            this retention policy implementation.
043     */
044    public interface RetentionPolicy<T extends LogRetentionPolicyCfg>
045    {
046      /**
047       * Initializes this log retention policy based on the
048       * information in the provided retention policy configuration.
049       *
050       * @param config
051       *          The retention policy configuration that contains the
052       *          information to use to initialize this policy.
053       * @throws ConfigException
054       *           If an unrecoverable problem arises in the process of
055       *           performing the initialization as a result of the server
056       *           configuration.
057       * @throws InitializationException
058       *           If a problem occurs during initialization that is not
059       *           related to the server configuration.
060       */
061      public abstract void initializeLogRetentionPolicy(T config)
062          throws ConfigException, InitializationException;
063    
064      /**
065       * Returns all files that should be deleted according to the policy.
066       *
067       * @param fileNamingPolicy The naming policy used generate the log file
068       *                         names.
069       *
070       * @return An array of files that should be deleted according to the
071       *         policy or <code>null</code> if an error occured while
072       *         obtaining the file list.
073       * @throws DirectoryException If an error occurs while obtaining a list
074       *                            of files to delete.
075       */
076      public File[] deleteFiles(FileNamingPolicy fileNamingPolicy)
077          throws DirectoryException;
078    }
079