[jboss-cvs] JBoss Messaging SVN: r3149 - in trunk/src/main/org/jboss: jms/server/connectionfactory and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 27 16:29:57 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-09-27 16:29:57 -0400 (Thu, 27 Sep 2007)
New Revision: 3149

Added:
   trunk/src/main/org/jboss/messaging/util/JMXAccessor.java
Modified:
   trunk/src/main/org/jboss/jms/server/ServerPeer.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
   trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
   trunk/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-1079 - calling resets on redeliveries (fix on ClientConsumer)

Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java	2007-09-27 20:11:36 UTC (rev 3148)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java	2007-09-27 20:29:57 UTC (rev 3149)
@@ -74,6 +74,7 @@
 import org.jboss.messaging.util.ExceptionUtil;
 import org.jboss.messaging.util.Util;
 import org.jboss.messaging.util.Version;
+import org.jboss.messaging.util.JMXAccessor;
 import org.jboss.mx.loading.UnifiedClassLoader3;
 import org.jboss.remoting.marshal.MarshalFactory;
 import org.jboss.system.ServiceCreator;
@@ -225,12 +226,10 @@
          // circumventing the MBeanServer. However, they are installed as services to take advantage
          // of their automatically-creating management interface.
 
-         persistenceManager = (PersistenceManager)mbeanServer.
-            getAttribute(persistenceManagerObjectName, "Instance");
+         persistenceManager = (PersistenceManager)JMXAccessor.getJMXAttributeOverSecurity(mbeanServer, persistenceManagerObjectName, "Instance");
          ((JDBCPersistenceManager)persistenceManager).injectNodeID(serverPeerID);
 
-         jmsUserManager = (JMSUserManager)mbeanServer.
-            getAttribute(jmsUserManagerObjectName, "Instance");
+         jmsUserManager = (JMSUserManager)JMXAccessor.getJMXAttributeOverSecurity(mbeanServer, jmsUserManagerObjectName, "Instance");
 
          // We get references to some plugins lazily to avoid problems with circular MBean
          // dependencies
@@ -1122,16 +1121,10 @@
       if (defaultDLQObjectName != null)
       { 
          ManagedQueue dest = null;
-         
-         try
-         {         
-            dest = (ManagedQueue)getServer().getAttribute(defaultDLQObjectName, "Instance");
-         }
-         catch (InstanceNotFoundException e)
-         {
-            //Ok
-         }
-         
+
+         // This can be null... JMXAccessor will return null if InstanceNotFoundException is caught
+         dest = (ManagedQueue) JMXAccessor.getJMXAttributeOverSecurity(getServer(), defaultDLQObjectName, "Instance");
+
          if (dest != null && dest.getName() != null)
          {            
             Binding binding = postOffice.getBindingForQueueName(dest.getName());
@@ -1162,8 +1155,9 @@
          ManagedQueue dest = null;
          
          try
-         {         
-            dest = (ManagedQueue)getServer().getAttribute(defaultExpiryQueueObjectName, "Instance");
+         {
+
+            dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(getServer(), defaultExpiryQueueObjectName, "Instance");
          }
          catch (InstanceNotFoundException e)
          {
@@ -1260,8 +1254,7 @@
       // We get the reference lazily to avoid problems with MBean circular dependencies
       if (postOffice == null)
       {
-         postOffice = (PostOffice)getServer().getAttribute(postOfficeObjectName, "Instance");
-
+         postOffice = (PostOffice)JMXAccessor.getJMXAttributeOverSecurity(getServer(), postOfficeObjectName, "Instance");
          // We also inject the replicator dependency into the ConnectionFactoryJNDIMapper. This is
          // a bit messy but we have a circular dependency POJOContainer should be able to help us
          // here. Yes, this is nasty.
@@ -1462,7 +1455,7 @@
       mbeanServer.invoke(on, "create", new Object[0], new String[0]);
       mbeanServer.invoke(on, "start", new Object[0], new String[0]);
 
-      return (String)mbeanServer.getAttribute(on, "JNDIName");
+      return (String)JMXAccessor.getJMXAttributeOverSecurity(mbeanServer, on, "JNDIName");
    }
 
    
@@ -1483,7 +1476,7 @@
       {
          return false;
       }
-      Boolean b = (Boolean)mbeanServer.getAttribute(on, "CreatedProgrammatically");
+      Boolean b = (Boolean)JMXAccessor.getJMXAttributeOverSecurity(mbeanServer, on, "CreatedProgrammatically");
       if (!b.booleanValue())
       {
          log.warn("Cannot undeploy a destination that has not been created programatically");

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2007-09-27 20:11:36 UTC (rev 3148)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactory.java	2007-09-27 20:29:57 UTC (rev 3149)
@@ -14,6 +14,7 @@
 import org.jboss.jms.server.ConnectorManager;
 import org.jboss.jms.server.ServerPeer;
 import org.jboss.messaging.util.ExceptionUtil;
+import org.jboss.messaging.util.JMXAccessor;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.system.ServiceMBeanSupport;
 import org.w3c.dom.Element;
@@ -112,9 +113,10 @@
                                                "each Connection Factory");
          }
       
-         String locatorURI = (String)server.getAttribute(connectorObjectName, "InvokerLocator");
-         ServerPeer serverPeer = (ServerPeer)server.getAttribute(serverPeerObjectName, "Instance");
+         String locatorURI = (String)JMXAccessor.getJMXAttributeOverSecurity(server, connectorObjectName, "InvokerLocator");
 
+         ServerPeer serverPeer = (ServerPeer)JMXAccessor.getJMXAttributeOverSecurity(server, serverPeerObjectName, "Instance");
+
          if (!serverPeer.isSupportsFailover())
          {
             this.supportsFailover = false;
@@ -126,8 +128,7 @@
 
          int refCount = connectorManager.registerConnector(connectorObjectName.getCanonicalName());
 
-         long leasePeriod =
-            ((Long)server.getAttribute(connectorObjectName, "LeasePeriod")).longValue();
+         long leasePeriod = (Long)JMXAccessor.getJMXAttributeOverSecurity(server, connectorObjectName, "LeasePeriod");
 
          // if leasePeriod <= 0, disable pinging altogether
 

Modified: trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java	2007-09-27 20:11:36 UTC (rev 3148)
+++ trunk/src/main/org/jboss/jms/server/destination/DestinationServiceSupport.java	2007-09-27 20:29:57 UTC (rev 3149)
@@ -21,6 +21,7 @@
 import org.jboss.messaging.core.contract.PostOffice;
 import org.jboss.messaging.core.contract.Queue;
 import org.jboss.messaging.util.ExceptionUtil;
+import org.jboss.messaging.util.JMXAccessor;
 import org.jboss.system.ServiceMBeanSupport;
 import org.w3c.dom.Element;
 
@@ -87,7 +88,7 @@
       
       try
       {
-         serverPeer = (ServerPeer)server.getAttribute(serverPeerObjectName, "Instance");
+         serverPeer = (ServerPeer)JMXAccessor.getJMXAttributeOverSecurity(server, serverPeerObjectName, "Instance");
                	      
          destination.setServerPeer(serverPeer);
                	
@@ -191,8 +192,8 @@
          
          try
          {         
-            dest = (ManagedQueue)getServer().
-               getAttribute(dlqObjectName, "Instance");
+            dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(server,dlqObjectName, "Instance" );
+
          }
          catch (InstanceNotFoundException e)
          {
@@ -222,8 +223,7 @@
       {         
          try
          {         
-            dest = (ManagedQueue)getServer().
-               getAttribute(expiryQueueObjectName, "Instance");
+            dest = (ManagedQueue)JMXAccessor.getJMXAttributeOverSecurity(server,expiryQueueObjectName, "Instance" );
          }
          catch (InstanceNotFoundException e)
          {

Modified: trunk/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java	2007-09-27 20:11:36 UTC (rev 3148)
+++ trunk/src/main/org/jboss/messaging/core/jmx/MessagingPostOfficeService.java	2007-09-27 20:29:57 UTC (rev 3149)
@@ -46,6 +46,7 @@
 import org.jboss.messaging.core.impl.postoffice.MessagingPostOffice;
 import org.jboss.messaging.core.impl.tx.TransactionRepository;
 import org.jboss.messaging.util.ExceptionUtil;
+import org.jboss.messaging.util.JMXAccessor;
 import org.w3c.dom.Element;
 
 /**
@@ -333,8 +334,8 @@
       {
          TransactionManager tm = getTransactionManagerReference();
 
-         ServerPeer serverPeer = (ServerPeer)server.getAttribute(serverPeerObjectName, "Instance");
-         
+         ServerPeer serverPeer = (ServerPeer) JMXAccessor.getJMXAttributeOverSecurity(server, serverPeerObjectName, "Instance");
+
          MessageStore ms = serverPeer.getMessageStore();
          
          PersistenceManager pm = serverPeer.getPersistenceManagerInstance();

Added: trunk/src/main/org/jboss/messaging/util/JMXAccessor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/util/JMXAccessor.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/util/JMXAccessor.java	2007-09-27 20:29:57 UTC (rev 3149)
@@ -0,0 +1,79 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+
+package org.jboss.messaging.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.InstanceNotFoundException;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ *          $Id$
+ */
+public class JMXAccessor
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   // Static ---------------------------------------------------------------------------------------
+
+   public static Object getJMXAttributeOverSecurity(final MBeanServer server, final ObjectName name, final String attributeName) throws Exception
+   {
+
+      //Do a privileged Action to connecto to JMX
+      return AccessController.doPrivileged( new PrivilegedExceptionAction()
+      {
+         public Object run() throws Exception
+         {
+            try
+            {
+               return server.getAttribute(name, attributeName);
+            }
+            catch(InstanceNotFoundException e)
+            {
+               return null;
+            }
+         }
+      });
+
+
+   }
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   // Public ---------------------------------------------------------------------------------------
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}


Property changes on: trunk/src/main/org/jboss/messaging/util/JMXAccessor.java
___________________________________________________________________
Name: svn:keywords
   + Id LastChangedDate Author Revision




More information about the jboss-cvs-commits mailing list