001/*
002 *   Licensed to the Apache Software Foundation (ASF) under one
003 *   or more contributor license agreements.  See the NOTICE file
004 *   distributed with this work for additional information
005 *   regarding copyright ownership.  The ASF licenses this file
006 *   to you under the Apache License, Version 2.0 (the
007 *   "License"); you may not use this file except in compliance
008 *   with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *   Unless required by applicable law or agreed to in writing,
013 *   software distributed under the License is distributed on an
014 *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *   KIND, either express or implied.  See the License for the
016 *   specific language governing permissions and limitations
017 *   under the License.
018 *
019 */
020package org.apache.directory.server.config.beans;
021
022
023import org.apache.directory.server.config.ConfigurationElement;
024
025
026/**
027 * A class used to store the Journal configuration.
028 *
029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
030 */
031public class JournalBean extends AdsBaseBean
032{
033    /** The journal unique Id */
034    @ConfigurationElement(attributeType = "ads-journalId", isRdn = true)
035    private String journalId;
036
037    /** The journal file name */
038    @ConfigurationElement(attributeType = "ads-journalFileName")
039    private String journalFileName;
040
041    /** The journal working directory */
042    @ConfigurationElement(attributeType = "ads-journalWorkingDir")
043    private String journalWorkingDir;
044
045    /** The journal rotation */
046    @ConfigurationElement(attributeType = "ads-journalRotation")
047    private int journalRotation;
048
049
050    /**
051     * Create a new JournalBean instance
052     */
053    public JournalBean()
054    {
055        // Default to infinite
056        journalRotation = 0;
057
058        // Not enabled by default
059        setEnabled( false );
060    }
061
062
063    /**
064     * @return the journalId
065     */
066    public String getJournalId()
067    {
068        return journalId;
069    }
070
071
072    /**
073     * @param journalId the journalId to set
074     */
075    public void setJournalId( String journalId )
076    {
077        this.journalId = journalId;
078    }
079
080
081    /**
082     * @return the fileName
083     */
084    public String getJournalFileName()
085    {
086        return journalFileName;
087    }
088
089
090    /**
091     * @param journalFileName the journalFileName to set
092     */
093    public void setJournalFileName( String journalFileName )
094    {
095        this.journalFileName = journalFileName;
096    }
097
098
099    /**
100     * @return the journal WorkingDir
101     */
102    public String getJournalWorkingDir()
103    {
104        return journalWorkingDir;
105    }
106
107
108    /**
109     * @param journalWorkingDir the journal WorkingDir to set
110     */
111    public void setJournalWorkingDir( String journalWorkingDir )
112    {
113        this.journalWorkingDir = journalWorkingDir;
114    }
115
116
117    /**
118     * @return the journal Rotation
119     */
120    public int getJournalRotation()
121    {
122        return journalRotation;
123    }
124
125
126    /**
127     * @param journalRotation the journal Rotation to set
128     */
129    public void setJournalRotation( int journalRotation )
130    {
131        this.journalRotation = journalRotation;
132    }
133
134
135    /**
136     * {@inheritDoc}
137     */
138    public String toString( String tabs )
139    {
140        StringBuilder sb = new StringBuilder();
141
142        sb.append( tabs ).append( "Journal :\n" );
143        sb.append( tabs ).append( "  journal id : " ).append( journalId ).append( '\n' );
144        sb.append( tabs ).append( "  journal file name : " ).append( journalFileName ).append( '\n' );
145        sb.append( toString( tabs, "  journal working dir", journalWorkingDir ) );
146        sb.append( toString( tabs, "  journal rotation", journalRotation ) );
147
148        return sb.toString();
149    }
150
151
152    /**
153     * {@inheritDoc}
154     */
155    public String toString()
156    {
157        return toString( "" );
158    }
159}