Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JmxLegacySupport |
|
| 1.3333333333333333;1.333 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.module.management.support; | |
8 | ||
9 | import java.util.Collection; | |
10 | import java.util.HashSet; | |
11 | import java.util.Iterator; | |
12 | import java.util.Set; | |
13 | ||
14 | import javax.management.MBeanServer; | |
15 | import javax.management.MalformedObjectNameException; | |
16 | import javax.management.ObjectName; | |
17 | ||
18 | /** | |
19 | * Support class for JMX 1.1 based systems. | |
20 | */ | |
21 | 0 | public class JmxLegacySupport extends AbstractJmxSupport |
22 | { | |
23 | ||
24 | /** | |
25 | * Uses simpler rules for escaping non-JMX compliant chars. | |
26 | * Much of the work has already been performed in {@link org.mule.util.ObjectNameHelper}. | |
27 | * | |
28 | * @param name value to escape for JMX compliance | |
29 | * @return value valid for JMX | |
30 | */ | |
31 | public String escape(String name) | |
32 | { | |
33 | // do nothing at the moment, as ObjectNameHelper handles most of the conversion scenarios | |
34 | // kept as a placeholder and no-op to keep newer JMX classes from kicking in. | |
35 | 0 | return name; |
36 | } | |
37 | ||
38 | ||
39 | /** | |
40 | * For modern JMX implementation just delegate to a standard factory method. | |
41 | * | |
42 | * @param name object name | |
43 | * @return ObjectName for MBeanServer | |
44 | * @throws javax.management.MalformedObjectNameException | |
45 | * for invalid names | |
46 | */ | |
47 | public ObjectName getObjectName(String name) throws MalformedObjectNameException | |
48 | { | |
49 | 0 | return new ObjectName(name); |
50 | } | |
51 | ||
52 | ||
53 | /** {@inheritDoc} */ | |
54 | protected Collection getDomains(final MBeanServer server) | |
55 | { | |
56 | // list all MBean names and collect unique domains | |
57 | 0 | Set set = server.queryNames(null, null); |
58 | 0 | Set domains = new HashSet(); |
59 | 0 | for (Iterator it = set.iterator(); it.hasNext();) |
60 | { | |
61 | 0 | ObjectName objectName = (ObjectName) it.next(); |
62 | 0 | domains.add(objectName.getDomain()); |
63 | 0 | } |
64 | 0 | return domains; |
65 | } | |
66 | } |