Skip to content

Commit 7a8852d

Browse files
committed
[bugfix] All JMX Beans should export a name
1 parent e028452 commit 7a8852d

File tree

5 files changed

+52
-7
lines changed

5 files changed

+52
-7
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* eXist-db Open Source Native XML Database
3+
* Copyright (C) 2001 The eXist-db Authors
4+
*
5+
6+
* http://www.exist-db.org
7+
*
8+
* This library is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU Lesser General Public
10+
* License as published by the Free Software Foundation; either
11+
* version 2.1 of the License, or (at your option) any later version.
12+
*
13+
* This library is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public
19+
* License along with this library; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
*/
22+
package org.exist.management.impl;
23+
24+
import javax.management.MalformedObjectNameException;
25+
import javax.management.ObjectName;
26+
27+
/**
28+
* Interface for all eXist-db provided MBeans.
29+
*/
30+
public interface ExistMBean {
31+
32+
/**
33+
* Get the name of the MBean.
34+
*
35+
* @return the name of the mbean.
36+
*
37+
* @throws MalformedObjectNameException if the name cannot be constructed.
38+
*/
39+
ObjectName getName() throws MalformedObjectNameException;
40+
}

exist-core/src/main/java/org/exist/management/impl/JMXAgent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public JMXAgent() {
7070

7171
private void registerSystemMBeans() {
7272
try {
73-
addMBean(new ObjectName(SystemInfo.OBJECT_NAME), new org.exist.management.impl.SystemInfo());
73+
final SystemInfoMXBean systemInfoMXBean = new org.exist.management.impl.SystemInfo();
74+
addMBean(systemInfoMXBean.getName(), systemInfoMXBean);
7475
} catch (final MalformedObjectNameException | DatabaseConfigurationException e) {
7576
LOG.warn("Exception while registering cache mbean.", e);
7677
}

exist-core/src/main/java/org/exist/management/impl/PerInstanceMBean.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222

2323
package org.exist.management.impl;
2424

25-
import javax.management.MalformedObjectNameException;
26-
import javax.management.ObjectName;
27-
28-
public interface PerInstanceMBean {
25+
public interface PerInstanceMBean extends ExistMBean {
2926
String getInstanceId();
30-
ObjectName getName() throws MalformedObjectNameException;
3127
}

exist-core/src/main/java/org/exist/management/impl/SystemInfo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
import org.exist.SystemProperties;
2828

29+
import javax.management.MalformedObjectNameException;
30+
import javax.management.ObjectName;
31+
2932
/**
3033
* Class SystemInfo
3134
*
@@ -36,6 +39,11 @@ public class SystemInfo implements SystemInfoMXBean {
3639

3740
public static final String OBJECT_NAME = "org.exist.management:type=SystemInfo";
3841

42+
@Override
43+
public ObjectName getName() throws MalformedObjectNameException {
44+
return new ObjectName(OBJECT_NAME);
45+
}
46+
3947
@Override
4048
public String getProductName() {
4149
return SystemProperties.getInstance().getSystemProperty("product-name","eXist");

exist-core/src/main/java/org/exist/management/impl/SystemInfoMXBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @author wessels
2828
* @author ljo
2929
*/
30-
public interface SystemInfoMXBean {
30+
public interface SystemInfoMXBean extends ExistMBean {
3131
String getProductName();
3232

3333
String getProductVersion();

0 commit comments

Comments
 (0)