001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.logging.log4j.core.appender.rolling; 018 019 import org.apache.logging.log4j.core.appender.rolling.helper.Action; 020 021 /** 022 * Description of actions needed to complete rollover. 023 */ 024 public final class RolloverDescriptionImpl implements RolloverDescription { 025 /** 026 * Active log file name after rollover. 027 */ 028 private final String activeFileName; 029 030 /** 031 * Should active file be opened for appending. 032 */ 033 private final boolean append; 034 035 /** 036 * Action to be completed after close of current active log file 037 * before returning control to caller. 038 */ 039 private final Action synchronous; 040 041 /** 042 * Action to be completed after close of current active log file 043 * and before next rollover attempt, may be executed asynchronously. 044 */ 045 private final Action asynchronous; 046 047 /** 048 * Create new instance. 049 * 050 * @param activeFileName active log file name after rollover, may not be null. 051 * @param append true if active log file after rollover should be opened for appending. 052 * @param synchronous action to be completed after close of current active log file, may be null. 053 * @param asynchronous action to be completed after close of current active log file and 054 * before next rollover attempt. 055 */ 056 public RolloverDescriptionImpl(final String activeFileName, final boolean append, final Action synchronous, 057 final Action asynchronous) { 058 if (activeFileName == null) { 059 throw new NullPointerException("activeFileName"); 060 } 061 062 this.append = append; 063 this.activeFileName = activeFileName; 064 this.synchronous = synchronous; 065 this.asynchronous = asynchronous; 066 } 067 068 /** 069 * Active log file name after rollover. 070 * 071 * @return active log file name after rollover. 072 */ 073 public String getActiveFileName() { 074 return activeFileName; 075 } 076 077 /** 078 * {@inheritDoc} 079 */ 080 public boolean getAppend() { 081 return append; 082 } 083 084 /** 085 * Action to be completed after close of current active log file 086 * before returning control to caller. 087 * 088 * @return action, may be null. 089 */ 090 public Action getSynchronous() { 091 return synchronous; 092 } 093 094 /** 095 * Action to be completed after close of current active log file 096 * and before next rollover attempt, may be executed asynchronously. 097 * 098 * @return action, may be null. 099 */ 100 public Action getAsynchronous() { 101 return asynchronous; 102 } 103 }