equal
deleted
inserted
replaced
27 package javax.management.openmbean; |
27 package javax.management.openmbean; |
28 |
28 |
29 |
29 |
30 // java import |
30 // java import |
31 // |
31 // |
|
32 import com.sun.jmx.mbeanserver.GetPropertyAction; |
32 import java.io.IOException; |
33 import java.io.IOException; |
33 import java.io.ObjectInputStream; |
34 import java.io.ObjectInputStream; |
34 import java.io.Serializable; |
35 import java.io.Serializable; |
|
36 import java.security.AccessController; |
35 import java.util.ArrayList; |
37 import java.util.ArrayList; |
36 import java.util.Arrays; |
38 import java.util.Arrays; |
37 import java.util.Collection; |
39 import java.util.Collection; |
38 import java.util.Collections; |
40 import java.util.Collections; |
39 import java.util.HashMap; |
41 import java.util.HashMap; |
40 import java.util.Iterator; |
42 import java.util.Iterator; |
|
43 import java.util.LinkedHashMap; |
41 import java.util.List; |
44 import java.util.List; |
42 import java.util.Map; |
45 import java.util.Map; |
43 import java.util.Set; |
46 import java.util.Set; |
44 |
47 |
45 // jmx import |
48 // jmx import |
77 |
80 |
78 |
81 |
79 /** |
82 /** |
80 * @serial This tabular data instance's contents: a {@link HashMap} |
83 * @serial This tabular data instance's contents: a {@link HashMap} |
81 */ |
84 */ |
|
85 // field cannot be final because of clone method |
82 private Map<Object,CompositeData> dataMap; |
86 private Map<Object,CompositeData> dataMap; |
83 |
87 |
84 /** |
88 /** |
85 * @serial This tabular data instance's tabular type |
89 * @serial This tabular data instance's tabular type |
86 */ |
90 */ |
87 private TabularType tabularType; |
91 private final TabularType tabularType; |
88 |
92 |
89 /** |
93 /** |
90 * The array of item names that define the index used for rows (convenience field) |
94 * The array of item names that define the index used for rows (convenience field) |
91 */ |
95 */ |
92 private transient String[] indexNamesArray; |
96 private transient String[] indexNamesArray; |
107 * |
111 * |
108 * @throws IllegalArgumentException if the tabular type is null. |
112 * @throws IllegalArgumentException if the tabular type is null. |
109 */ |
113 */ |
110 public TabularDataSupport(TabularType tabularType) { |
114 public TabularDataSupport(TabularType tabularType) { |
111 |
115 |
112 this(tabularType, 101, 0.75f); |
116 this(tabularType, 16, 0.75f); |
113 } |
117 } |
114 |
118 |
115 /** |
119 /** |
116 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>, |
120 * Creates an empty <tt>TabularDataSupport</tt> instance whose open-type is <var>tabularType</var>, |
117 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor. |
121 * and whose underlying <tt>HashMap</tt> has the specified initial capacity and load factor. |
139 // |
143 // |
140 this.tabularType = tabularType; |
144 this.tabularType = tabularType; |
141 List<String> tmpNames = tabularType.getIndexNames(); |
145 List<String> tmpNames = tabularType.getIndexNames(); |
142 this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]); |
146 this.indexNamesArray = tmpNames.toArray(new String[tmpNames.size()]); |
143 |
147 |
|
148 // Since LinkedHashMap was introduced in SE 1.4, it's conceivable even |
|
149 // if very unlikely that we might be the server of a 1.3 client. In |
|
150 // that case you'll need to set this property. See CR 6334663. |
|
151 String useHashMapProp = AccessController.doPrivileged( |
|
152 new GetPropertyAction("jmx.tabular.data.hash.map")); |
|
153 boolean useHashMap = "true".equalsIgnoreCase(useHashMapProp); |
|
154 |
144 // Construct the empty contents HashMap |
155 // Construct the empty contents HashMap |
145 // |
156 // |
146 this.dataMap = |
157 this.dataMap = useHashMap ? |
147 new HashMap<Object,CompositeData>(initialCapacity, loadFactor); |
158 new HashMap<Object,CompositeData>(initialCapacity, loadFactor) : |
|
159 new LinkedHashMap<Object, CompositeData>(initialCapacity, loadFactor); |
148 } |
160 } |
149 |
161 |
150 |
162 |
151 |
163 |
152 |
164 |