01: /*
02: File: DefaultChannelCapacity.java
03:
04: Originally written by Doug Lea and released into the public domain.
05: This may be used for any purposes whatsoever without acknowledgment.
06: Thanks for the assistance and support of Sun Microsystems Labs,
07: and everyone contributing, testing, and using this code.
08:
09: History:
10: Date Who What
11: 11Jun1998 dl Create public version
12: */
13:
14: package org.dbunit.util.concurrent;
15:
16: import org.slf4j.Logger;
17: import org.slf4j.LoggerFactory;
18:
19: /**
20: * A utility class to set the default capacity of
21: * BoundedChannel
22: * implementations that otherwise require a capacity argument
23: * @see BoundedChannel
24: * [<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>] <p>
25: **/
26:
27: public class DefaultChannelCapacity {
28:
29: /**
30: * Logger for this class
31: */
32: private static final Logger logger = LoggerFactory
33: .getLogger(DefaultChannelCapacity.class);
34:
35: /** The initial value of the default capacity is 1024 **/
36: public static final int INITIAL_DEFAULT_CAPACITY = 1024;
37:
38: /** the current default capacity **/
39: private static final SynchronizedInt defaultCapacity_ = new SynchronizedInt(
40: INITIAL_DEFAULT_CAPACITY);
41:
42: /**
43: * Set the default capacity used in
44: * default (no-argument) constructor for BoundedChannels
45: * that otherwise require a capacity argument.
46: * @exception IllegalArgumentException if capacity less or equal to zero
47: */
48: public static void set(int capacity) {
49: logger.debug("set(capacity=" + capacity + ") - start");
50:
51: if (capacity <= 0)
52: throw new IllegalArgumentException();
53: defaultCapacity_.set(capacity);
54: }
55:
56: /**
57: * Get the default capacity used in
58: * default (no-argument) constructor for BoundedChannels
59: * that otherwise require a capacity argument.
60: * Initial value is <code>INITIAL_DEFAULT_CAPACITY</code>
61: * @see #INITIAL_DEFAULT_CAPACITY
62: */
63: public static int get() {
64: logger.debug("get() - start");
65:
66: return defaultCapacity_.get();
67: }
68: }
|