incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmatth...@apache.org
Subject svn commit: r1067338 - in /incubator/isis/trunk: alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/ core/runtime/src/main/java/org/apache/isis/core/runtime/system/
Date Fri, 04 Feb 2011 23:12:03 GMT
Author: rmatthews
Date: Fri Feb  4 23:12:03 2011
New Revision: 1067338

URL: http://svn.apache.org/viewvc?rev=1067338&view=rev
Log:
Introducing JMX control to the project.  Registering an MBean with the JmxBeanServer will
make it available to JMX client (such as JConsole).  Have used this here to allow the authorization
file to be reloaded while running.

Added:
    incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizorMBean.java
  (with props)
    incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/core/runtime/system/JmxBeanServer.java
  (with props)
Modified:
    incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizor.java

Modified: incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizor.java?rev=1067338&r1=1067337&r2=1067338&view=diff
==============================================================================
--- incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizor.java
(original)
+++ incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizor.java
Fri Feb  4 23:12:03 2011
@@ -43,10 +43,11 @@ import org.apache.isis.core.commons.ensu
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.commons.resource.ResourceStreamSource;
 import org.apache.isis.core.runtime.authorization.standard.AuthorizorAbstract;
+import org.apache.isis.core.runtime.system.JmxBeanServer;
 import org.apache.log4j.Logger;
 
 
-public class FileAuthorizor extends AuthorizorAbstract {
+public class FileAuthorizor extends AuthorizorAbstract implements FileAuthorizorMBean {
 
     private static final Logger LOG = Logger.getLogger(FileAuthorizor.class);
 
@@ -81,6 +82,9 @@ public class FileAuthorizor extends Auth
         blackListResourceName = getConfiguration().getString(FileAuthorizationConstants.BLACKLIST_RESOURCE,
FileAuthorizationConstants.BLACKLIST_RESOURCE_DEFAULT);
         
         findResources();
+        
+                
+        JmxBeanServer.getInstance().register("FileAuthorizor", this);
     }
 
 

Added: incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizorMBean.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizorMBean.java?rev=1067338&view=auto
==============================================================================
--- incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizorMBean.java
(added)
+++ incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizorMBean.java
Fri Feb  4 23:12:03 2011
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.isis.alternatives.security.file.authorization;
+
+public interface FileAuthorizorMBean {
+
+    void reload();
+    
+}
+

Propchange: incubator/isis/trunk/alternatives/security/file/src/main/java/org/apache/isis/alternatives/security/file/authorization/FileAuthorizorMBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/core/runtime/system/JmxBeanServer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/core/runtime/system/JmxBeanServer.java?rev=1067338&view=auto
==============================================================================
--- incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/core/runtime/system/JmxBeanServer.java
(added)
+++ incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/core/runtime/system/JmxBeanServer.java
Fri Feb  4 23:12:03 2011
@@ -0,0 +1,49 @@
+package org.apache.isis.core.runtime.system;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+
+
+public class JmxBeanServer {
+
+    private static JmxBeanServer instance;
+    private final MBeanServer server;
+
+    private JmxBeanServer() {
+        server = ManagementFactory.getPlatformMBeanServer();
+        instance = this;
+    }
+    
+    public static JmxBeanServer getInstance() {
+        if (instance == null) {
+            instance = new JmxBeanServer();
+        }
+        return instance;
+    }
+
+    public void register(String name, Object object) {
+        try {
+            ObjectName objectName = new ObjectName("Isis:name=" + name);
+            server.registerMBean(object, objectName);
+        } catch (MalformedObjectNameException e) {
+            throw new RuntimeException(e);
+        } catch (NullPointerException e) {
+            throw new RuntimeException(e);
+        } catch (InstanceAlreadyExistsException e) {
+            throw new RuntimeException(e);
+        } catch (MBeanRegistrationException e) {
+            throw new RuntimeException(e);
+        } catch (NotCompliantMBeanException e) {
+            throw new RuntimeException(e);
+        }
+
+    }
+}
+
+// Copyright (c) Naked Objects Group Ltd.

Propchange: incubator/isis/trunk/core/runtime/src/main/java/org/apache/isis/core/runtime/system/JmxBeanServer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message