summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2009-08-12 18:14:26 +0000
committerMartin Ritchie <ritchiem@apache.org>2009-08-12 18:14:26 +0000
commit20ddeae6df6f62505b11339d049ab36561bd0f04 (patch)
tree4bf0ab2feea87bf17ad1a04d0f23fbe6797640f9 /qpid/java
parent417cf6738b35932b28aea984389988d87eae0477 (diff)
downloadqpid-python-20ddeae6df6f62505b11339d049ab36561bd0f04.tar.gz
QPID-2002 : Added Logging of management console connection open and close events
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@803647 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages.properties3
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties3
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java18
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java33
4 files changed, 56 insertions, 1 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages.properties b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages.properties
index 3380bf2aa6..eafcb43cc0 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages.properties
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages.properties
@@ -46,6 +46,9 @@ MNG-1004 = Ready
MNG-1005 = Stopped
# 0 - Path
MNG-1006 = Using SSL Keystore : {0}
+MNG-1007 = Open : User {0}
+MNG-1008 = Close
+
#VirtualHost
# 0 - name
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties
index 6d358652b8..5ced7cc0b9 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/messages/LogMessages_en_US.properties
@@ -212,6 +212,9 @@ MNG-1004 = Ready
MNG-1005 = Stopped
# 0 - Path
MNG-1006 = Using SSL Keystore : {0}
+MNG-1007 = Open : User {0}
+MNG-1008 = Close
+
#VirtualHost
# 0 - name
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
index 38272db845..5ffcee77f2 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
@@ -34,9 +34,16 @@ import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
+import javax.management.NotificationListener;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationFilterSupport;
+import javax.management.InstanceNotFoundException;
+import javax.management.relation.MBeanServerNotificationFilter;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXServiceURL;
import javax.management.remote.MBeanServerForwarder;
+import javax.management.remote.JMXConnectionNotification;
import javax.management.remote.rmi.RMIConnectorServer;
import javax.management.remote.rmi.RMIJRMPServerImpl;
import javax.management.remote.rmi.RMIServerImpl;
@@ -47,6 +54,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.management.ManagementFactory;
+import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
@@ -275,8 +283,18 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry
//Add the custom invoker as an MBeanServerForwarder, and start the RMIConnectorServer.
MBeanServerForwarder mbsf = MBeanInvocationHandlerImpl.newProxyInstance();
cs.setMBeanServerForwarder(mbsf);
+
+ NotificationFilterSupport filter = new NotificationFilterSupport();
+ filter.enableType(JMXConnectionNotification.OPENED);
+ filter.enableType(JMXConnectionNotification.CLOSED);
+ filter.enableType(JMXConnectionNotification.FAILED);
+ // Get the handler that is used by the above MBInvocationHandler Proxy.
+ // which is the MBeanInvocationHandlerImpl and so also a NotificationListener
+ cs.addNotificationListener((NotificationListener) Proxy.getInvocationHandler(mbsf), filter, null);
+
cs.start();
+
CurrentActor.get().message(ManagementConsoleMessages.MNG_1004());
}
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
index a68934d358..20410ba5ce 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
@@ -23,15 +23,23 @@ package org.apache.qpid.server.management;
import org.apache.qpid.management.common.mbeans.ConfigurationManagement;
import org.apache.qpid.management.common.mbeans.LoggingManagement;
import org.apache.qpid.management.common.mbeans.UserManagement;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.ManagementActor;
+import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
+import org.apache.qpid.server.logging.messages.ConnectionMessages;
+import org.apache.qpid.server.logging.LogActor;
import org.apache.log4j.Logger;
import javax.management.remote.MBeanServerForwarder;
import javax.management.remote.JMXPrincipal;
+import javax.management.remote.JMXConnectionNotification;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.JMException;
+import javax.management.NotificationListener;
+import javax.management.Notification;
import javax.security.auth.Subject;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
@@ -49,7 +57,7 @@ import java.util.Properties;
* the logic for allowing the users to invoke MBean operations and implements the restrictions for readOnly, readWrite
* and admin users.
*/
-public class MBeanInvocationHandlerImpl implements InvocationHandler
+public class MBeanInvocationHandlerImpl implements InvocationHandler, NotificationListener
{
private static final Logger _logger = Logger.getLogger(MBeanInvocationHandlerImpl.class);
@@ -59,6 +67,7 @@ public class MBeanInvocationHandlerImpl implements InvocationHandler
private final static String DELEGATE = "JMImplementation:type=MBeanServerDelegate";
private MBeanServer _mbs;
private static Properties _userRoles = new Properties();
+ private static ManagementActor _logActor;
private static HashSet<String> _adminOnlyMethods = new HashSet<String>();
{
@@ -72,6 +81,9 @@ public class MBeanInvocationHandlerImpl implements InvocationHandler
final InvocationHandler handler = new MBeanInvocationHandlerImpl();
final Class[] interfaces = new Class[]{MBeanServerForwarder.class};
+
+ _logActor = new ManagementActor(CurrentActor.get().getRootMessageLogger());
+
Object proxy = Proxy.newProxyInstance(MBeanServerForwarder.class.getClassLoader(), interfaces, handler);
return MBeanServerForwarder.class.cast(proxy);
}
@@ -254,4 +266,23 @@ public class MBeanInvocationHandlerImpl implements InvocationHandler
return false;
}
+
+ public void handleNotification(Notification notification, Object handback)
+ {
+ // only RMI Connections are serviced here, Local API atta
+ // rmi://169.24.29.116 guest 3
+ String[] connectionData = ((JMXConnectionNotification) notification).getConnectionId().split(" ");
+ String user = connectionData[1];
+
+ if (notification.getType().equals(JMXConnectionNotification.OPENED))
+ {
+ _logActor.message(ManagementConsoleMessages.MNG_1007(user));
+ }
+ else if (notification.getType().equals(JMXConnectionNotification.CLOSED) ||
+ notification.getType().equals(JMXConnectionNotification.FAILED))
+ {
+ _logActor.message(ManagementConsoleMessages.MNG_1008());
+ }
+ }
}
+