[jboss-cvs] JBossAS SVN: r87467 - in branches/Branch_5_x: cluster/src/main/org/jboss/ha/singleton and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 16 20:18:53 EDT 2009


Author: pferraro
Date: 2009-04-16 20:18:53 -0400 (Thu, 16 Apr 2009)
New Revision: 87467

Added:
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java
   branches/Branch_5_x/testsuite/src/resources/cluster/haservice/
   branches/Branch_5_x/testsuite/src/resources/cluster/haservice/jboss-beans.xml
Modified:
   branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
   branches/Branch_5_x/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
   branches/Branch_5_x/testsuite/imports/sections/cluster.xml
Log:
[JBAS-6792] Override HAService rpc handler so that public methods on subclasses are exposed to rpc mechanism.

Modified: branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java	2009-04-17 00:13:52 UTC (rev 87466)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/jmx/HAServiceMBeanSupport.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -25,6 +25,7 @@
 
 import org.jboss.ha.framework.interfaces.HAService;
 import org.jboss.ha.framework.server.HAServiceImpl;
+import org.jboss.ha.framework.server.HAServiceRpcHandler;
 
 /**
  * Management Bean for an HA-Service.
@@ -47,6 +48,7 @@
  */
 public class HAServiceMBeanSupport
    extends AbstractHAServiceMBeanSupport<HAService<Notification>>
+   implements HAServiceRpcHandler<Notification>
 {
    /**
     * @see org.jboss.ha.jmx.AbstractHAServiceMBeanSupport#createHAService()
@@ -54,7 +56,18 @@
    @Override
    protected HAService<Notification> createHAService()
    {
-      return new HAServiceImpl<Notification>(this, this);
+      return new HAServiceImpl<Notification>(this, this)
+      {
+         /**
+          * Expose HAServiceMBeanSupport subclass methods to rpc handler
+          * @see org.jboss.ha.framework.server.HAServiceImpl#getRpcHandler()
+          */
+         @Override
+         protected HAServiceRpcHandler<Notification> getRpcHandler()
+         {
+            return HAServiceMBeanSupport.this;
+         }
+      };
    }
 }
 

Modified: branches/Branch_5_x/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java
===================================================================
--- branches/Branch_5_x/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java	2009-04-17 00:13:52 UTC (rev 87466)
+++ branches/Branch_5_x/cluster/src/main/org/jboss/ha/singleton/HASingletonSupport.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -26,7 +26,9 @@
 import org.jboss.ha.framework.interfaces.HASingleton;
 import org.jboss.ha.framework.interfaces.HASingletonElectionPolicy;
 import org.jboss.ha.framework.interfaces.HASingletonLifecycle;
+import org.jboss.ha.framework.server.HAServiceRpcHandler;
 import org.jboss.ha.framework.server.HASingletonImpl;
+import org.jboss.ha.framework.server.HASingletonRpcHandler;
 import org.jboss.ha.jmx.AbstractHAServiceMBeanSupport;
 
 
@@ -42,7 +44,7 @@
  */
 public class HASingletonSupport
    extends AbstractHAServiceMBeanSupport<HASingleton<Notification>>
-   implements HASingleton<Notification>
+   implements HASingleton<Notification>, HASingletonRpcHandler<Notification>
 {
    /**
     * @see org.jboss.ha.framework.interfaces.HASingletonMBean#isMasterNode()
@@ -125,6 +127,25 @@
    @Override
    protected HASingleton<Notification> createHAService()
    {
-      return new HASingletonImpl<Notification>(this, this, this);
+      return new HASingletonImpl<Notification>(this, this, this)
+      {
+         /**
+          * Expose HASingletonSupport subclass methods to rpc handler
+          * @see org.jboss.ha.framework.server.HASingletonImpl#getRpcHandler()
+          */
+         @Override
+         protected HAServiceRpcHandler<Notification> getRpcHandler()
+         {
+            return HASingletonSupport.this;
+         }         
+      };
    }
+
+   /**
+    * @see org.jboss.ha.framework.server.HASingletonRpcHandler#stopOldMaster()
+    */
+   public void stopOldMaster() throws Exception
+   {
+      ((HASingletonImpl<Notification>) this.getHAService()).stopOldMaster();
+   }
 }

Modified: branches/Branch_5_x/testsuite/imports/sections/cluster.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/cluster.xml	2009-04-17 00:13:52 UTC (rev 87466)
+++ branches/Branch_5_x/testsuite/imports/sections/cluster.xml	2009-04-17 00:18:53 UTC (rev 87467)
@@ -100,6 +100,16 @@
    	     file="${build.resources}/cluster/hasingleton/ha-singleton-jboss-beans.xml"
    	     overwrite="true"/>
       
+   	<!--beans for testing EchoHAServiceUnitTestCase, EchoHASingletonUnitTestCase -->
+    <jar destfile="${build.lib}/ha-service.sar">
+       <metainf dir="${build.resources}/cluster/haservice">
+          <include name="*.xml"/>
+       </metainf>
+       <fileset dir="${build.classes}">
+          <include name="org/jboss/test/cluster/haservice/**"/>
+       </fileset>
+    </jar>
+      
       <!-- ha-invoker adaptor sar -->
       <jar destfile="${build.lib}/ha-invoker.sar">
          <fileset dir="${build.classes}">

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HAServiceUnitTestCase.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.defaultcfg.test;
+
+import java.util.List;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Verifies that public methods of an HAServiceMBeanSupport subclass are accessible via the HAService's rpc mechanism.
+ * 
+ * @author Paul Ferraro
+ */
+public class HAServiceUnitTestCase extends JBossClusteredTestCase
+{
+   public HAServiceUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return JBossClusteredTestCase.getDeploySetup(HAServiceUnitTestCase.class, "ha-service.sar");
+   }
+
+   public void testTrueEcho() throws Exception
+   {
+      MBeanServerConnection[] adaptors = this.getAdaptors();
+      ObjectName on = new ObjectName("jboss.ha:service=EchoHAService");
+      Object[] args = new Object[] {"echo", new Object[] {true}, new Class[] {boolean.class}};
+      String[] signature = new String[] {String.class.getName(), Object[].class.getName(), Class[].class.getName()};
+      List<?> responses = (List<?>) adaptors[0].invoke(on, "callMethodOnPartition", args, signature);
+      log.debug("Response list: " + responses);
+      assertEquals(1, responses.size());
+      
+      if (responses.get(0) instanceof Exception)
+      {
+         throw (Exception) responses.get(0);
+      }
+      
+      assertTrue(((Boolean) responses.get(0)).booleanValue());
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/defaultcfg/test/HASingletonUnitTestCase.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.defaultcfg.test;
+
+import java.util.List;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossClusteredTestCase;
+
+/**
+ * Verifies that public methods of an HASingletonSupport subclass are accessible via the HASingleton's rpc mechanism.
+ * 
+ * @author Paul Ferraro
+ */
+public class HASingletonUnitTestCase extends JBossClusteredTestCase
+{
+   public HASingletonUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return JBossClusteredTestCase.getDeploySetup(HASingletonUnitTestCase.class, "ha-service.sar");
+   }
+
+   public void testEcho() throws Exception
+   {
+      Boolean result = this.testMethod("echo", new Object[] { true }, new Class[] { Boolean.TYPE }, Boolean.class);
+      
+      assertTrue(result.booleanValue());
+   }
+
+   public void testStopOldMaster() throws Exception
+   {
+      Void result = this.testMethod("stopOldMaster", null, null, Void.class);
+      
+      assertNull(result);
+   }
+   
+   private <T> T testMethod(String method, Object[] parameters, Class<?>[] types, Class<T> resultType) throws Exception
+   {
+      MBeanServerConnection[] adaptors = this.getAdaptors();
+      ObjectName on = ObjectName.getInstance("jboss.ha:service=EchoHASingleton");
+      Object[] args = new Object[] { method, parameters, types };
+      String[] signature = new String[] { String.class.getName(), Object[].class.getName(), Class[].class.getName() };
+      List<?> responses = (List<?>) adaptors[0].invoke(on, "callMethodOnPartition", args, signature);
+      
+      log.debug("Response list: " + responses);
+      
+      assertEquals(1, responses.size());
+      
+      if (responses.get(0) instanceof Exception)
+      {
+         throw (Exception) responses.get(0);
+      }
+
+      return resultType.cast(responses.get(0));
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAService.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.haservice;
+
+import org.jboss.ha.jmx.HAServiceMBeanSupport;
+
+/**
+ * A TestHAService.
+ * 
+ * @author Paul Ferraro
+ */
+public class EchoHAService extends HAServiceMBeanSupport implements EchoHAServiceMBean
+{
+   /**
+    * @see org.jboss.test.cluster.haservice.EchoHAServiceMBean#echo(boolean)
+    */
+   public boolean echo(boolean echo)
+   {
+      return echo;
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHAServiceMBean.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.haservice;
+
+import org.jboss.ha.jmx.HAServiceMBean;
+
+/**
+ * A TestHAServiceMBean.
+ * 
+ * @author Paul Ferraro
+ */
+public interface EchoHAServiceMBean extends HAServiceMBean
+{
+   boolean echo(boolean echo);
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingleton.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.haservice;
+
+import org.jboss.ha.singleton.HASingletonSupport;
+
+/**
+ * A EchoHASingleton.
+ * 
+ * @author Paul Ferraro
+ */
+public class EchoHASingleton extends HASingletonSupport implements EchoHASingletonMBean
+{
+   /**
+    * @see org.jboss.test.cluster.haservice.EchoHAServiceMBean#echo(boolean)
+    */
+   public boolean echo(boolean echo)
+   {
+      return echo;
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/cluster/haservice/EchoHASingletonMBean.java	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.cluster.haservice;
+
+import org.jboss.ha.framework.interfaces.HASingletonMBean;
+
+/**
+ * A EchoHASingletonMBean.
+ * 
+ * @author Paul Ferraro
+ */
+public interface EchoHASingletonMBean extends EchoHAServiceMBean, HASingletonMBean
+{
+
+}

Added: branches/Branch_5_x/testsuite/src/resources/cluster/haservice/jboss-beans.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/cluster/haservice/jboss-beans.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/cluster/haservice/jboss-beans.xml	2009-04-17 00:18:53 UTC (rev 87467)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="EchoHAService" class="org.jboss.test.cluster.haservice.EchoHAService">
+      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=EchoHAService", exposedInterface=org.jboss.test.cluster.haservice.EchoHAServiceMBean.class, registerDirectly=true)</annotation>
+      <property name="clusterPartition"><inject bean="HAPartition"/></property>
+   </bean>
+
+   <bean name="EchoHASingleton" class="org.jboss.test.cluster.haservice.EchoHASingleton">
+      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.ha:service=EchoHASingleton", exposedInterface=org.jboss.test.cluster.haservice.EchoHASingletonMBean.class, registerDirectly=true)</annotation>
+      <property name="clusterPartition"><inject bean="HAPartition"/></property>
+   </bean>
+   
+</deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list