Lines 17-22
Link Here
|
17 |
package org.apache.log4j.jmx; |
17 |
package org.apache.log4j.jmx; |
18 |
|
18 |
|
19 |
//import java.lang.reflect.Constructor; |
19 |
//import java.lang.reflect.Constructor; |
|
|
20 |
import java.util.Collection; |
20 |
import java.util.Iterator; |
21 |
import java.util.Iterator; |
21 |
import javax.management.DynamicMBean; |
22 |
import javax.management.DynamicMBean; |
22 |
import javax.management.AttributeList; |
23 |
import javax.management.AttributeList; |
Lines 25-30
Link Here
|
25 |
import javax.management.MBeanRegistration; |
26 |
import javax.management.MBeanRegistration; |
26 |
import javax.management.MBeanServer; |
27 |
import javax.management.MBeanServer; |
27 |
import javax.management.ObjectName; |
28 |
import javax.management.ObjectName; |
|
|
29 |
import javax.management.InstanceAlreadyExistsException; |
30 |
import javax.management.InstanceNotFoundException; |
31 |
import javax.management.MBeanRegistrationException; |
32 |
import javax.management.NotCompliantMBeanException; |
28 |
|
33 |
|
29 |
import org.apache.log4j.Logger; |
34 |
import org.apache.log4j.Logger; |
30 |
|
35 |
|
Lines 33-38
Link Here
|
33 |
|
38 |
|
34 |
String dClassName; |
39 |
String dClassName; |
35 |
MBeanServer server; |
40 |
MBeanServer server; |
|
|
41 |
|
42 |
/** List of MBean names which are registered internally. */ |
43 |
private Collection mbeanList = new java.util.LinkedList(); |
36 |
|
44 |
|
37 |
/** |
45 |
/** |
38 |
* Enables the to get the values of several attributes of the Dynamic MBean. |
46 |
* Enables the to get the values of several attributes of the Dynamic MBean. |
Lines 112-121
Link Here
|
112 |
} |
120 |
} |
113 |
|
121 |
|
114 |
|
122 |
|
|
|
123 |
/** |
124 |
* Registers MBean instance in the attached server. Must <em>NOT</em> |
125 |
* be called before registration if this instance. |
126 |
*/ |
127 |
protected |
128 |
void registerMBean(Object mbean, ObjectName objectName) |
129 |
throws InstanceAlreadyExistsException, MBeanRegistrationException, |
130 |
NotCompliantMBeanException { |
131 |
server.registerMBean(mbean, objectName); |
132 |
mbeanList.add(objectName); |
133 |
} |
115 |
|
134 |
|
|
|
135 |
/** |
136 |
* Performs cleanup for deregistering this MBean. Default implementation |
137 |
* unregisters MBean instances which are registered using |
138 |
* {@link #registerMBean(Object mbean, ObjectName objectName)}. |
139 |
*/ |
116 |
public |
140 |
public |
117 |
void preDeregister() { |
141 |
void preDeregister() { |
118 |
getLogger().debug("preDeregister called."); |
142 |
getLogger().debug("preDeregister called."); |
|
|
143 |
Iterator iterator = mbeanList.iterator(); |
144 |
while (iterator.hasNext()) { |
145 |
ObjectName name = (ObjectName) iterator.next(); |
146 |
try { |
147 |
server.unregisterMBean(name); |
148 |
} catch (InstanceNotFoundException e) { |
149 |
getLogger().warn("Missing MBean " + name.getCanonicalName()); |
150 |
} catch (MBeanRegistrationException e) { |
151 |
getLogger().warn("Failed unregistering " + name.getCanonicalName()); |
152 |
} |
153 |
} |
119 |
} |
154 |
} |
120 |
|
155 |
|
121 |
public |
156 |
public |