Author: aidan
Date: Wed Feb 25 17:49:05 2009
New Revision: 747869

URL: http://svn.apache.org/viewvc?rev=747869&view=rev
Log:
QPID-1568: make isInstanceOf and isRegistered read only methods. Fix code style 
issue with field name.

Patch from Robbie Gemmell <[email protected]>

Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java?rev=747869&r1=747868&r2=747869&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/management/MBeanInvocationHandlerImpl.java
 Wed Feb 25 17:49:05 2009
@@ -53,7 +53,7 @@
     public final static String READWRITE = "readwrite";
     public final static String READONLY = "readonly";
     private final static String DELEGATE = 
"JMImplementation:type=MBeanServerDelegate";
-    private MBeanServer mbs;
+    private MBeanServer _mbs;
     private static Properties _userRoles = new Properties();
 
     public static MBeanServerForwarder newProxyInstance()
@@ -71,7 +71,7 @@
 
         if (methodName.equals("getMBeanServer"))
         {
-            return mbs;
+            return _mbs;
         }
 
         if (methodName.equals("setMBeanServer"))
@@ -80,11 +80,11 @@
             {
                 throw new IllegalArgumentException("Null MBeanServer");
             }
-            if (mbs != null)
+            if (_mbs != null)
             {
                 throw new IllegalArgumentException("MBeanServer object already 
initialized");
             }
-            mbs = (MBeanServer) args[0];
+            _mbs = (MBeanServer) args[0];
             return null;
         }
 
@@ -95,12 +95,12 @@
         // Allow operations performed locally on behalf of the connector 
server itself
         if (subject == null)
         {
-            return method.invoke(mbs, args);
+            return method.invoke(_mbs, args);
         }
 
         if (args == null || DELEGATE.equals(args[0]))
         {
-            return method.invoke(mbs, args);
+            return method.invoke(_mbs, args);
         }
 
         // Restrict access to "createMBean" and "unregisterMBean" to any user
@@ -124,7 +124,7 @@
         {
             if (isAdmin(identity))
             {
-                return method.invoke(mbs, args);
+                return method.invoke(_mbs, args);
             }
             else
             {
@@ -135,14 +135,14 @@
         // Following users can perform any operation other than "createMBean" 
and "unregisterMBean"
         if (isAllowedToModify(identity))
         {
-            return method.invoke(mbs, args);
+            return method.invoke(_mbs, args);
         }
 
         // These users can only call "getAttribute" on the MBeanServerDelegate 
MBean
         // Here we can add other fine grained permissions like specific method 
for a particular mbean
         if (isReadOnlyUser(identity) && isReadOnlyMethod(method, args))
         {
-            return method.invoke(mbs, args);
+            return method.invoke(_mbs, args);
         }
 
         throw new SecurityException("Access denied");
@@ -196,7 +196,10 @@
     private boolean isReadOnlyMethod(Method method, Object[] args)
     {
         String methodName = method.getName();
-        if (methodName.startsWith("query") || methodName.startsWith("get"))
+        
+        //handle standard get/set/query and select 'is' methods from 
MBeanServer
+        if (methodName.startsWith("query") || methodName.startsWith("get")
+            ||methodName.startsWith("isInstanceOf") || 
methodName.startsWith("isRegistered"))
         {
             return true;
         }
@@ -205,8 +208,11 @@
             return false;
         }
 
+        //handle invocation of other methods on mbeans
         if ((args[0] instanceof ObjectName) && (methodName.equals("invoke")))
         {
+
+            //get invoked method name
             String mbeanMethod = (args.length > 1) ? (String) args[1] : null;
             if (mbeanMethod == null)
             {
@@ -215,7 +221,8 @@
 
             try
             {
-                MBeanInfo mbeanInfo = mbs.getMBeanInfo((ObjectName) args[0]);
+                //check if the given method is tagged with an INFO impact 
attribute
+                MBeanInfo mbeanInfo = _mbs.getMBeanInfo((ObjectName) args[0]);
                 if (mbeanInfo != null)
                 {
                     MBeanOperationInfo[] opInfos = mbeanInfo.getOperations();



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to