1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| package org.jboss.cache.pojo.jmx; |
9 |
| |
10 |
| import javax.management.MBeanServer; |
11 |
| import javax.management.MalformedObjectNameException; |
12 |
| import javax.management.ObjectName; |
13 |
| import java.util.Hashtable; |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| public class JmxUtil extends org.jboss.cache.jmx.JmxUtil |
22 |
| { |
23 |
| public static final String POJO_CACHE_DOMAIN = "jboss.pojocache"; |
24 |
| public static final String POJO_CACHE_TYPE = "PojoCache"; |
25 |
| |
26 |
24
| public static void registerPojoCache(MBeanServer server, PojoCacheJmxWrapperMBean cache, String objectName)
|
27 |
| throws Exception |
28 |
| { |
29 |
24
| if (server == null || cache == null || objectName == null)
|
30 |
0
| return;
|
31 |
24
| ObjectName tmpObj = new ObjectName(objectName);
|
32 |
24
| if (!server.isRegistered(tmpObj))
|
33 |
24
| server.registerMBean(cache, tmpObj);
|
34 |
| |
35 |
| } |
36 |
| |
37 |
51
| public static ObjectName getPlainCacheObjectName(ObjectName pojoCacheName)
|
38 |
| throws MalformedObjectNameException |
39 |
| { |
40 |
51
| String domain = pojoCacheName.getDomain();
|
41 |
51
| Hashtable attributes = new Hashtable(pojoCacheName.getKeyPropertyList());
|
42 |
51
| Object type = attributes.get(CACHE_TYPE_KEY);
|
43 |
51
| if (type == null || POJO_CACHE_TYPE.equals(type))
|
44 |
| { |
45 |
51
| attributes.put(CACHE_TYPE_KEY, PLAIN_CACHE_TYPE);
|
46 |
| } |
47 |
| else |
48 |
| { |
49 |
0
| attributes.put(UNIQUE_ID_KEY, String.valueOf(System.currentTimeMillis()));
|
50 |
| } |
51 |
51
| return new ObjectName(domain, attributes);
|
52 |
| } |
53 |
| |
54 |
0
| public static void unregisterPojoCache(MBeanServer server, String objectName)
|
55 |
| throws Exception |
56 |
| { |
57 |
0
| if (server == null || objectName == null)
|
58 |
0
| return;
|
59 |
| |
60 |
0
| ObjectName on = new ObjectName(objectName);
|
61 |
0
| if (server.isRegistered(on))
|
62 |
0
| server.unregisterMBean(on);
|
63 |
| |
64 |
| } |
65 |
| } |