[jboss-cvs] JBossAS SVN: r83825 - in trunk: testsuite/src/main/org/jboss/test/cluster/defaultcfg/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 3 14:15:42 EST 2009


Author: pferraro
Date: 2009-02-03 14:15:42 -0500 (Tue, 03 Feb 2009)
New Revision: 83825

Modified:
   trunk/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java
Log:
[JBAS-6435] Merge fix from Branch_5_0

Modified: trunk/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java	2009-02-03 18:47:53 UTC (rev 83824)
+++ trunk/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java	2009-02-03 19:15:42 UTC (rev 83825)
@@ -177,6 +177,25 @@
 
       this.setupPartition();
 
+      // Default serviceHAName, if none defined
+      if (this.service.getServiceHAName() == null)
+      {
+         ObjectName name = this.getServiceName();
+         
+         if (name != null)
+         {
+            this.service.setServiceHAName(name.getCanonicalName());
+         }
+         else
+         {
+            // This shouldn't occur as the service name is now injected by the microcontainer.
+            //  If injection fails, the service name should then be used.
+            throw new IllegalStateException("Cannot determine ServiceHAName for " + 
+                    getClass().getName() + "; either set it explicitly " + 
+                    "or register this object in JMX before calling create");
+         }
+      }
+
       this.service.start();
    }
    
@@ -295,6 +314,7 @@
     * @see javax.management.NotificationBroadcasterSupport#sendNotification(Notification)
     * @see org.jboss.mx.util.JBossNotificationBroadcasterSupport#sendNotification(javax.management.Notification)
     */
+   @Override
    public void sendNotification(Notification notification)
    {
       boolean stateChange = (notification instanceof AttributeChangeNotification) ? "State".equals(((AttributeChangeNotification) notification).getAttributeName()) : false;
@@ -372,30 +392,7 @@
     */
    public String getServiceHAName()
    {
-      String name = this.service.getServiceHAName();
-      
-      if (name == null)
-      {
-         ObjectName on = this.getServiceName();
-         
-         if (on != null)
-         {
-            name = on.getCanonicalName();
-            
-            this.service.setServiceHAName(name);
-         }
-         else
-         {
-            // This shouldn't occur as the service name is now injected by the microcontainer.
-            //  If injection fails, the service name should then be used.
-            throw new IllegalStateException("Cannot determine ServiceHAName for " + 
-                    getClass().getName() + "; " +
-                    "either set it explicitly or register this object in JMX " +
-                    "before calling create");
-         }
-      }
-      
-      return name;
+      return this.service.getServiceHAName();
    }
    
    @Inject(fromContext = FromContext.NAME)

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java	2009-02-03 18:47:53 UTC (rev 83824)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java	2009-02-03 19:15:42 UTC (rev 83825)
@@ -29,6 +29,7 @@
 import junit.framework.TestCase;
 
 import org.jboss.test.cluster.haservice.HAServiceMBeanSupportTester;
+import org.jboss.test.cluster.testutil.MockHAPartition;
 
 /**
  * 
@@ -133,6 +134,11 @@
    
    public void testServiceHAName() throws Exception
    {
+      assertNull("Initial name correct", this.haServiceMBeanSupportTester.getServiceHAName());
+
+      this.haServiceMBeanSupportTester.setHAPartition(new MockHAPartition());
+      this.haServiceMBeanSupportTester.start();
+      
       assertEquals("Default name correct", HAServiceMBeanSupportTester.SERVICE_NAME, this.haServiceMBeanSupportTester.getServiceHAName());
        
       this.haServiceMBeanSupportTester.setServiceHAName("Test");




More information about the jboss-cvs-commits mailing list