geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r231404 - in /geronimo/trunk: modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/ plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/ plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deploym...
Date Thu, 11 Aug 2005 05:54:10 GMT
Author: djencks
Date: Wed Aug 10 22:54:05 2005
New Revision: 231404

URL: http://svn.apache.org/viewcvs?rev=231404&view=rev
Log:
GERONIMO-484.  Missed a couple proxy cleanups.  Make jmx connection logout when connection
is closed.

Modified:
    geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java
    geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
    geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
    geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java

Modified: geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java?rev=231404&r1=231403&r2=231404&view=diff
==============================================================================
--- geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java
(original)
+++ geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/Authenticator.java
Wed Aug 10 22:54:05 2005
@@ -16,7 +16,13 @@
  */
 package org.apache.geronimo.jmxremoting;
 
+import java.util.Map;
+import java.util.Collections;
+import java.util.HashMap;
 import javax.management.remote.JMXAuthenticator;
+import javax.management.remote.JMXConnectionNotification;
+import javax.management.NotificationListener;
+import javax.management.Notification;
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
@@ -26,9 +32,11 @@
  *
  * @version $Rev$ $Date$
  */
-public class Authenticator implements JMXAuthenticator {
+public class Authenticator implements JMXAuthenticator, NotificationListener {
     private final String configName;
     private final ClassLoader cl;
+    private ThreadLocal threadContext = new ThreadLocal();
+    private Map contextMap = Collections.synchronizedMap(new HashMap());
 
     /**
      * Constructor indicating which JAAS Application Configuration Entry to use.
@@ -55,6 +63,7 @@
             thread.setContextClassLoader(cl);
             LoginContext context = new LoginContext(configName, credentials);
             context.login();
+            threadContext.set(context);
             return context.getSubject();
         } catch (LoginException e) {
             // do not propogate cause - we don't know what information is may contain
@@ -62,6 +71,28 @@
         } finally {
             credentials.clear();
             thread.setContextClassLoader(oldCL);
+        }
+    }
+
+    public void handleNotification(Notification notification, Object o) {
+        if (notification instanceof JMXConnectionNotification) {
+            JMXConnectionNotification cxNotification = (JMXConnectionNotification) notification;
+            String type = cxNotification.getType();
+            String connectionId = cxNotification.getConnectionId();
+            if (JMXConnectionNotification.OPENED.equals(type)) {
+                LoginContext context = (LoginContext) threadContext.get();
+                threadContext.set(null);
+                contextMap.put(connectionId, context);
+            } else {
+                LoginContext context = (LoginContext) contextMap.remove(connectionId);
+                if (context != null) {
+                    try {
+                        context.logout();
+                    } catch (LoginException e) {
+                        //nothing we can do here...
+                    }
+                }
+            }
         }
     }
 }

Modified: geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java?rev=231404&r1=231403&r2=231404&view=diff
==============================================================================
--- geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
(original)
+++ geronimo/trunk/modules/jmx-remoting/src/java/org/apache/geronimo/jmxremoting/JMXConnector.java
Wed Aug 10 22:54:05 2005
@@ -21,7 +21,10 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
+import javax.management.remote.JMXConnectionNotification;
 import javax.management.MBeanServer;
+import javax.management.NotificationFilter;
+import javax.management.NotificationFilterSupport;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,6 +45,7 @@
     private final ClassLoader classLoader;
     private String url;
     private String applicationConfigName;
+    private Authenticator authenticator;
 
     private JMXConnectorServer server;
 
@@ -103,12 +107,18 @@
         JMXServiceURL serviceURL = new JMXServiceURL(url);
         Map env = new HashMap();
         if (applicationConfigName != null) {
-            env.put(JMXConnectorServer.AUTHENTICATOR, new Authenticator(applicationConfigName,
classLoader));
+            authenticator = new Authenticator(applicationConfigName, classLoader);
+            env.put(JMXConnectorServer.AUTHENTICATOR, authenticator);
         } else {
             log.warn("Starting unauthenticating JMXConnector for " + serviceURL);
         }
         MBeanServer mbeanServer = new MBeanServerDelegate(kernel);
         server = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, env, mbeanServer);
+        NotificationFilterSupport filter = new NotificationFilterSupport();
+        filter.enableType(JMXConnectionNotification.OPENED);
+        filter.enableType(JMXConnectionNotification.CLOSED);
+        filter.enableType(JMXConnectionNotification.FAILED);
+        server.addNotificationListener(authenticator, filter, null);
         server.start();
         log.info("Started JMXConnector " + server.getAddress());
     }

Modified: geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java?rev=231404&r1=231403&r2=231404&view=diff
==============================================================================
--- geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
(original)
+++ geronimo/trunk/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PackageBuilder.java
Wed Aug 10 22:54:05 2005
@@ -193,13 +193,17 @@
         Kernel kernel = createKernel();
 
         // start the Configuration we're going to use for this deployment
-        ConfigurationManager configMgr = ConfigurationUtil.getConfigurationManager(kernel);
-        if (!configMgr.isLoaded(deploymentConfig)) {
-            List configs = configMgr.loadRecursive(deploymentConfig);
-            for (int i = 0; i < configs.size(); i++) {
-                ObjectName configName = (ObjectName) configs.get(i);
-                kernel.startRecursiveGBean(configName);
+        ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+        try {
+            if (!configurationManager.isLoaded(deploymentConfig)) {
+                List configs = configurationManager.loadRecursive(deploymentConfig);
+                for (int i = 0; i < configs.size(); i++) {
+                    ObjectName configName = (ObjectName) configs.get(i);
+                    kernel.startRecursiveGBean(configName);
+                }
             }
+        } finally {
+            ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
         }
 
         ObjectName deployer = locateDeployer(kernel);

Modified: geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java?rev=231404&r1=231403&r2=231404&view=diff
==============================================================================
--- geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
(original)
+++ geronimo/trunk/plugins/maven-geronimo-plugin/src/java/org/apache/geronimo/deployment/mavenplugin/StartServer.java
Wed Aug 10 22:54:05 2005
@@ -121,14 +121,18 @@
 
         // load the rest of the configuration listed on the command line
         ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
-        for (Iterator i = configList.iterator(); i.hasNext();) {
-            URI configID = (URI) i.next();
-            List list = configurationManager.loadRecursive(configID);
-            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
-                ObjectName name = (ObjectName) iterator.next();
-                kernel.startRecursiveGBean(name);
-                System.out.println("started gbean: " + name);
+        try {
+            for (Iterator i = configList.iterator(); i.hasNext();) {
+                URI configID = (URI) i.next();
+                List list = configurationManager.loadRecursive(configID);
+                for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+                    ObjectName name = (ObjectName) iterator.next();
+                    kernel.startRecursiveGBean(name);
+                    System.out.println("started gbean: " + name);
+                }
             }
+        } finally {
+            ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
         }
 
 



Mime
View raw message