author | chegar |
Fri, 09 Mar 2018 17:59:11 +0000 | |
branch | http-client-branch |
changeset 56272 | 7394452786ba |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9698
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.management; |
|
27 |
||
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
28 |
import java.lang.management.ManagementFactory; |
2 | 29 |
import java.lang.management.MemoryManagerMXBean; |
30 |
import java.lang.management.MemoryPoolMXBean; |
|
31 |
||
9698
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
32 |
import javax.management.MBeanNotificationInfo; |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
33 |
import javax.management.ObjectName; |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
34 |
|
2 | 35 |
/** |
36 |
* Implementation class for a memory manager. |
|
37 |
* Standard and committed hotspot-specific metrics if any. |
|
38 |
* |
|
39 |
* ManagementFactory.getMemoryManagerMXBeans() returns a list |
|
40 |
* of instances of this class. |
|
41 |
*/ |
|
9698
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
42 |
class MemoryManagerImpl extends NotificationEmitterSupport |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
43 |
implements MemoryManagerMXBean { |
2 | 44 |
|
45 |
private final String name; |
|
46 |
private final boolean isValid; |
|
47 |
private MemoryPoolMXBean[] pools; |
|
48 |
||
49 |
MemoryManagerImpl(String name) { |
|
50 |
this.name = name; |
|
51 |
this.isValid = true; |
|
52 |
this.pools = null; |
|
53 |
} |
|
54 |
||
55 |
public String getName() { |
|
56 |
return name; |
|
57 |
} |
|
58 |
||
59 |
public boolean isValid() { |
|
60 |
return isValid; |
|
61 |
} |
|
62 |
||
63 |
public String[] getMemoryPoolNames() { |
|
64 |
MemoryPoolMXBean[] ps = getMemoryPools(); |
|
65 |
||
66 |
String[] names = new String[ps.length]; |
|
67 |
for (int i = 0; i < ps.length; i++) { |
|
68 |
names[i] = ps[i].getName(); |
|
69 |
} |
|
70 |
return names; |
|
71 |
} |
|
72 |
||
73 |
synchronized MemoryPoolMXBean[] getMemoryPools() { |
|
74 |
if (pools == null) { |
|
75 |
pools = getMemoryPools0(); |
|
76 |
} |
|
77 |
return pools; |
|
78 |
} |
|
79 |
private native MemoryPoolMXBean[] getMemoryPools0(); |
|
80 |
||
9698
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
81 |
private MBeanNotificationInfo[] notifInfo = null; |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
82 |
public MBeanNotificationInfo[] getNotificationInfo() { |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
83 |
synchronized (this) { |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
84 |
if(notifInfo == null) { |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
85 |
notifInfo = new MBeanNotificationInfo[0]; |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
86 |
} |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
87 |
} |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
88 |
return notifInfo; |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
89 |
} |
8b66cd6c5ebc
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
5506
diff
changeset
|
90 |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
91 |
public ObjectName getObjectName() { |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
92 |
return Util.newObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE, getName()); |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
93 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
94 |
|
2 | 95 |
} |