[jboss-cvs] JBossAS SVN: r83728 - in branches/Branch_5_0: 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
Sat Jan 31 12:14:46 EST 2009
Author: pferraro
Date: 2009-01-31 12:14:46 -0500 (Sat, 31 Jan 2009)
New Revision: 83728
Modified:
branches/Branch_5_0/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java
branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java
Log:
[JBAS-6435] Moved setting of default serviceHAName from getter to startService()
Modified: branches/Branch_5_0/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java
===================================================================
--- branches/Branch_5_0/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java 2009-01-31 16:00:10 UTC (rev 83727)
+++ branches/Branch_5_0/cluster/src/main/org/jboss/ha/jmx/AbstractHAServiceMBeanSupport.java 2009-01-31 17:14:46 UTC (rev 83728)
@@ -178,7 +178,23 @@
this.setupPartition();
// Ensure serviceHAName is set
- this.getServiceHAName();
+ 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();
}
@@ -375,28 +391,7 @@
*/
public String getServiceHAName()
{
- String name = this.service.getServiceHAName();
-
- if (name == null)
- {
- ObjectName on = this.getServiceName();
-
- if (on != null)
- {
- this.setServiceHAName(on.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");
- }
- }
-
- return name;
+ return this.service.getServiceHAName();
}
@Inject(fromContext = FromContext.NAME)
Modified: branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java
===================================================================
--- branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java 2009-01-31 16:00:10 UTC (rev 83727)
+++ branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceMBeanSupportUnitTestCase.java 2009-01-31 17:14:46 UTC (rev 83728)
@@ -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