KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > examples > scandir > config > ResultLogConfig


1 /*
2  * ResultLogConfig.java
3  *
4  * Created on July 17, 2006, 5:13 PM
5  *
6  * @(#)ResultLogConfig.java 1.3 06/08/02
7  *
8  * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * -Redistribution of source code must retain the above copyright notice, this
14  * list of conditions and the following disclaimer.
15  *
16  * -Redistribution in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * Neither the name of Sun Microsystems, Inc. or the names of contributors may
21  * be used to endorse or promote products derived from this software without
22  * specific prior written permission.
23  *
24  * This software is provided "AS IS," without a warranty of any kind. ALL
25  * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
26  * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
27  * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
28  * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
29  * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
30  * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
31  * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
32  * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
33  * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
34  * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
35  *
36  * You acknowledge that this software is not designed, licensed or intended
37  * for use in the design, construction, operation or maintenance of any
38  * nuclear facility.
39  */

40
41 package com.sun.jmx.examples.scandir.config;
42
43 import java.util.Arrays JavaDoc;
44 import javax.xml.bind.annotation.XmlElement;
45 import javax.xml.bind.annotation.XmlRootElement;
46
47 /**
48  * The <code>ResultLogConfig</code> Java Bean is used to model
49  * the initial configuration of the {@link
50  * com.sun.jmx.examples.scandir.ResultLogManagerMXBean}.
51  *
52  * <p>
53  * This class is annotated for XML binding.
54  * </p>
55  *
56  * @author Sun Microsystems, 2006 - All rights reserved.
57  */

58 @XmlRootElement(name="ResultLogConfig",
59         namespace=XmlConfigUtils.NAMESPACE)
60 public class ResultLogConfig {
61     
62     //
63
// A logger for this class.
64
//
65
// private static final Logger LOG =
66
// Logger.getLogger(ResultLogConfig.class.getName());
67

68     /**
69      * The path to the result log file. {@code null} means that logging to
70      * file is disabled.
71      */

72     private String JavaDoc logFileName;
73
74     /**
75      * Maximum number of record that will be logged in the log file before
76      * switching to a new log file.
77      */

78     private long logFileMaxRecords;
79
80     /**
81      * The maximum number of records that can be contained in the memory log.
82      * When this number is reached, the memory log drops its eldest record
83      * to make way for the new one.
84      */

85     private int memoryMaxRecords;
86
87     /**
88      * Creates a new instance of ResultLogConfig
89      */

90     public ResultLogConfig() {
91     }
92
93     /**
94      * Gets the path to the result log file. {@code null} means that logging to
95      * file is disabled.
96      * @return the path to the result log file.
97      */

98     @XmlElement(name="LogFileName",namespace=XmlConfigUtils.NAMESPACE)
99     public String JavaDoc getLogFileName() {
100         return this.logFileName;
101     }
102
103     /**
104      * Sets the path to the result log file. {@code null} means that
105      * logging to file is disabled.
106      * @param logFileName the path to the result log file.
107      */

108     public void setLogFileName(String JavaDoc logFileName) {
109         this.logFileName = logFileName;
110     }
111
112     /**
113      * Gets the maximum number of record that will be logged in the log file
114      * before switching to a new log file.
115      * A 0 or negative value means no limit.
116      * @return the maximum number of record that will be logged in the log file.
117      */

118     @XmlElement(name="LogFileMaxRecords",namespace=XmlConfigUtils.NAMESPACE)
119     public long getLogFileMaxRecords() {
120         return this.logFileMaxRecords;
121     }
122
123     /**
124      * Sets the maximum number of record that will be logged in the log file
125      * before switching to a new log file.
126      * A 0 or negative value means no limit.
127      * @param logFileMaxRecords the maximum number of record that will be
128      * logged in the log file.
129      */

130     public void setLogFileMaxRecords(long logFileMaxRecords) {
131         this.logFileMaxRecords = logFileMaxRecords;
132     }
133
134     /**
135      * Gets the maximum number of records that can be contained in the memory
136      * log.
137      * When this number is reached, the memory log drops its eldest record
138      * to make way for the new one.
139      * @return the maximum number of records that can be contained in the
140      * memory log.
141      */

142     @XmlElement(name="MemoryMaxRecords",namespace=XmlConfigUtils.NAMESPACE)
143     public int getMemoryMaxRecords() {
144         return this.memoryMaxRecords;
145     }
146
147     /**
148      * Sets the maximum number of records that can be contained in the memory
149      * log.
150      * When this number is reached, the memory log drops its eldest record
151      * to make way for the new one.
152      * @param memoryMaxRecords the maximum number of records that can be
153      * contained in the memory log.
154      */

155     public void setMemoryMaxRecords(int memoryMaxRecords) {
156         this.memoryMaxRecords = memoryMaxRecords;
157     }
158     
159     private Object JavaDoc[] toArray() {
160         final Object JavaDoc[] thisconfig = {
161             memoryMaxRecords,logFileMaxRecords,logFileName
162         };
163         return thisconfig;
164     }
165     
166     @Override JavaDoc
167     public boolean equals(Object JavaDoc o) {
168         if (o == this) return true;
169         if (!(o instanceof ResultLogConfig)) return false;
170         final ResultLogConfig other = (ResultLogConfig)o;
171         return Arrays.deepEquals(toArray(),other.toArray());
172     }
173     
174     @Override JavaDoc
175     public int hashCode() {
176         return Arrays.deepHashCode(toArray());
177     }
178 }
179
Popular Tags