01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.lang.management;
19:
20: import javax.management.openmbean.CompositeData;
21:
22: /**
23: * <p>
24: * Memory notification information.
25: * </p>
26: *
27: * @since 1.5
28: */
29: public class MemoryNotificationInfo {
30: public static final String MEMORY_COLLECTION_THRESHOLD_EXCEEDED = "java.management.memory.collection.threshold.exceeded";
31:
32: public static final String MEMORY_THRESHOLD_EXCEEDED = "java.management.memory.threshold.exceeded";
33:
34: /**
35: * <p>
36: * Constructs a MemoryNotificationInfo object from the CompositeData passed.
37: * </p>
38: *
39: * @param cd The CompositeDate object to retrieve data from.
40: * @return A MemoryNotificationInfo instance.
41: * @throws IllegalArgumentException if <code>cd</code> does not contain
42: * MemoryUsage data.
43: */
44: public static MemoryNotificationInfo from(CompositeData cd) {
45: String poolName = (String) cd.get("poolName");
46: MemoryUsage usage = MemoryUsage.from((CompositeData) cd
47: .get("usage"));
48: long count = ((Long) cd.get("count")).longValue();
49: return new MemoryNotificationInfo(poolName, usage, count);
50: }
51:
52: private final String poolName;
53:
54: private final MemoryUsage usage;
55:
56: private final long count;
57:
58: /**
59: * <p>
60: * Constructs a MemoryNotificationInfo instance.
61: * </p>
62: *
63: * @param poolName The memory pool name.
64: * @param usage The memory usage snapshot.
65: * @param count The threshold crossing count.
66: */
67: public MemoryNotificationInfo(String poolName, MemoryUsage usage,
68: long count) {
69: super ();
70: this .poolName = poolName;
71: this .usage = usage;
72: this .count = count;
73: }
74:
75: public String getPoolName() {
76: return poolName;
77: }
78:
79: public MemoryUsage getUsage() {
80: return usage;
81: }
82:
83: public long getCount() {
84: return count;
85: }
86: }
|