aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-02-16 18:11:21 -0500
committerJim Hahn <jrh3@att.com>2018-02-16 18:29:40 -0500
commit45f97b0b7735c9ac75c3f0d010b9524b47807cb8 (patch)
tree2fc61fb13e587c9f5af1a9e3b02ca512504d3631 /integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
parent2b0b96e27b11904bb36d8f4887aa28a913727fad (diff)
Fix more generic exceptions in common
Fixed a few more generic exceptions in integrity-audit and integrity-monitor. Fixed license dates. Change-Id: Ibbc21ae5f853896e0d3e416e33b5ea2a13672f62 Issue-ID: POLICY-246 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java')
-rw-r--r--integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java61
1 files changed, 34 insertions, 27 deletions
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
index d15fc5e7..c9a2ce80 100644
--- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
+++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -86,35 +87,41 @@ public final class JmxAgentConnection {
/**
* Get a connection to the jmxAgent MBeanServer.
* @return the connection
- * @throws Exception on error
+ * @throws IntegrityMonitorException on error
*/
- public MBeanServerConnection getMBeanConnection() throws Exception {
- JMXServiceURL url;
- if (jmxUrl == null) {
- url = new JMXServiceURL(jmxAgentUrl(host, port));
- }
- else {
- url = new JMXServiceURL(jmxUrl);
- }
- Map<String, Object> env = new HashMap<>();
-
- connector = JMXConnectorFactory.newJMXConnector(url, env);
- connector.connect();
- connector.addConnectionNotificationListener(
- new NotificationListener() {
+ public MBeanServerConnection getMBeanConnection() throws IntegrityMonitorException {
- @Override
- public void handleNotification(
- Notification notification, Object handback) {
- if (notification.getType().equals(
- JMXConnectionNotification.FAILED)) {
- // handle disconnect
- disconnect();
- }
- }
- }, null, null);
+ try {
+ JMXServiceURL url;
+ if (jmxUrl == null) {
+ url = new JMXServiceURL(jmxAgentUrl(host, port));
+ }
+ else {
+ url = new JMXServiceURL(jmxUrl);
+ }
+ Map<String, Object> env = new HashMap<>();
+
+ connector = JMXConnectorFactory.newJMXConnector(url, env);
+ connector.connect();
+ connector.addConnectionNotificationListener(
+ new NotificationListener() {
- return connector.getMBeanServerConnection();
+ @Override
+ public void handleNotification(
+ Notification notification, Object handback) {
+ if (notification.getType().equals(
+ JMXConnectionNotification.FAILED)) {
+ // handle disconnect
+ disconnect();
+ }
+ }
+ }, null, null);
+
+ return connector.getMBeanServerConnection();
+
+ } catch (IOException e) {
+ throw new IntegrityMonitorException(e);
+ }
}
/**