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 org.apache.harmony.lang.management;
19:
20: import java.lang.management.GarbageCollectorMXBean;
21:
22: /**
23: * Runtime type for {@link java.lang.management.GarbageCollectorMXBean}.
24: *
25: * @since 1.5
26: */
27: public final class GarbageCollectorMXBeanImpl extends
28: MemoryManagerMXBeanImpl implements GarbageCollectorMXBean {
29:
30: /**
31: * @param name The name of this collector
32: * @param id An internal id number representing this collector
33: * @param memBean The memory bean that receives notification events from pools managed by this collector
34: */
35: GarbageCollectorMXBeanImpl(String name, int id,
36: MemoryMXBeanImpl memBean) {
37: super (name, id, memBean);
38: }
39:
40: /**
41: * Sets the metadata for this bean.
42: */
43: protected void initializeInfo() {
44: setMBeanInfo(ManagementUtils
45: .getMBeanInfo(java.lang.management.GarbageCollectorMXBean.class
46: .getName()));
47: }
48:
49: /**
50: * @return the total number of garbage collections that have been carried
51: * out by the associated garbage collector.
52: * @see #getCollectionCount()
53: */
54: private native long getCollectionCountImpl();
55:
56: /*
57: * (non-Javadoc)
58: *
59: * @see java.lang.management.GarbageCollectorMXBean#getCollectionCount()
60: */
61: public long getCollectionCount() {
62: return this .getCollectionCountImpl();
63: }
64:
65: /**
66: * @return the number of milliseconds that have been spent in performing
67: * garbage collection. This is a cumulative figure.
68: * @see #getCollectionTime()
69: */
70: private native long getCollectionTimeImpl();
71:
72: /*
73: * (non-Javadoc)
74: *
75: * @see java.lang.management.GarbageCollectorMXBean#getCollectionTime()
76: */
77: public long getCollectionTime() {
78: return this.getCollectionTimeImpl();
79: }
80: }
|