[jboss-cvs] JBossAS SVN: r82171 - in branches/Branch_5_0/testsuite/src: resources/cluster/invokerha/META-INF and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 9 21:44:02 EST 2008


Author: bstansberry at jboss.com
Date: 2008-12-09 21:44:02 -0500 (Tue, 09 Dec 2008)
New Revision: 82171

Modified:
   branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java
   branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java
   branches/Branch_5_0/testsuite/src/resources/cluster/invokerha/META-INF/jboss-service.xml
Log:
[JBAS-6284] Change test to ensure invoke() isn't available from target service

Modified: branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java
===================================================================
--- branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java	2008-12-10 02:10:01 UTC (rev 82170)
+++ branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java	2008-12-10 02:44:02 UTC (rev 82171)
@@ -21,113 +21,15 @@
  */
 package org.jboss.test.cluster.invokerha;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.security.Principal;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.jboss.ha.jmx.HAServiceMBeanSupport;
-import org.jboss.invocation.Invocation;
-import org.jboss.invocation.MarshalledInvocation;
 import org.jboss.logging.Logger;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.system.Registry;
 
 public class HAService
    extends HAServiceMBeanSupport
-   implements HAServiceRemote, HAServiceMBean
+   implements HAServiceMBean
 {
    private static final Logger log = Logger.getLogger(HAService.class);
-   
-   private int count = 0;
 
-   private Map marshalledInvocationMapping;
-
-   public void startService()
-      throws Exception
-   {
-      super.startService();
-      
-      // Calulate method hashes for remote invocation
-      Method[] methods = HAServiceRemote.class.getMethods();
-      HashMap tmpMap = new HashMap(methods.length);
-      for(int m = 0; m < methods.length; m ++)
-      {
-         Method method = methods[m];
-         Long hash = new Long(MarshalledInvocation.calculateHash(method));
-         tmpMap.put(hash, method);
-      }
-      marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap);
-
-      // Place our ObjectName hash into the Registry so invokers can resolve it
-      Registry.bind(new Integer(serviceName.hashCode()), serviceName);
-   }
-
-   public void stopService()
-      throws Exception
-   {
-      super.stopService();
-      
-      // No longer available to the invokers
-      Registry.unbind(new Integer(serviceName.hashCode()));
-   }
-
-   /** 
-    * Expose the client mapping
-    */
-   public Map getMethodMap()
-   {
-      return marshalledInvocationMapping;
-   }
-
-   /** 
-    * This is the "remote" entry point
-    */
-   public Object invoke(Invocation invocation)
-      throws Exception
-   {
-      log.info("Invoked");
-      
-      // Invoked remotely, inject method resolution
-      if (invocation instanceof MarshalledInvocation)
-      {
-         MarshalledInvocation mi = (MarshalledInvocation) invocation;
-         mi.setMethodMap(marshalledInvocationMapping);
-      }
-      Method method = invocation.getMethod();
-      Object[] args = invocation.getArguments();
-      
-      log.info("Invocation of " + method);
-
-      // Setup any security context (only useful if something checks it, this impl doesn't)
-      Principal principal = invocation.getPrincipal();
-      Object credential = invocation.getCredential();
-      SecurityAssociation.setPrincipal(principal);
-      SecurityAssociation.setCredential(credential);
-
-      // Dispatch the invocation
-      try
-      {
-         return method.invoke(this, args);
-      }
-      catch(InvocationTargetException e)
-      {
-         Throwable t = e.getTargetException();
-         if( t instanceof Exception )
-            throw (Exception) t;
-         else
-            throw new UndeclaredThrowableException(t, method.toString());
-      }
-      finally
-      {
-         // Clear the security context
-         SecurityAssociation.clear();
-      }
-   }
-
    // Implementation of remote methods
 
    public String hello()

Modified: branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java
===================================================================
--- branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java	2008-12-10 02:10:01 UTC (rev 82170)
+++ branches/Branch_5_0/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java	2008-12-10 02:44:02 UTC (rev 82171)
@@ -21,16 +21,10 @@
  */
 package org.jboss.test.cluster.invokerha;
 
-import java.util.Map;
 
-import org.jboss.invocation.Invocation;
-
 public interface HAServiceMBean
-   extends org.jboss.ha.jmx.HAServiceMBean
+   extends org.jboss.ha.jmx.HAServiceMBean, HAServiceRemote
 {
-   // For remoting
-   Map getMethodMap();
-   Object invoke(Invocation invocation) throws Exception;
    
    boolean getSendRemoteLifecycleNotifications();
    void setSendRemoteLifecycleNotifications(boolean send);

Modified: branches/Branch_5_0/testsuite/src/resources/cluster/invokerha/META-INF/jboss-service.xml
===================================================================
--- branches/Branch_5_0/testsuite/src/resources/cluster/invokerha/META-INF/jboss-service.xml	2008-12-10 02:10:01 UTC (rev 82170)
+++ branches/Branch_5_0/testsuite/src/resources/cluster/invokerha/META-INF/jboss-service.xml	2008-12-10 02:44:02 UTC (rev 82171)
@@ -18,6 +18,9 @@
 
       <!-- The target MBean -->
       <depends optional-attribute-name="TargetName">jboss.test:service=HAService</depends>
+      
+      <!--  Directly invoke the target method, not invoke() -->
+      <attribute name="InvokeTargetMethod">true</attribute>
 
       <!-- Where to bind the proxy -->
       <attribute name="JndiName">jmx/HAService</attribute>
@@ -41,7 +44,7 @@
       <attribute name="SendRemoteLifecycleNotifications">false</attribute>  
       <!-- Use the default partition -->
       <attribute name="HAPartition"><inject bean="HAPartition"/></attribute>
-      <attribute name="ServiceHAName">jboss.test:service=HAService</attribute>
+      <attribute name="ServiceHAName">jboss.test:service=HAService</attribute>     
   </mbean>
   
   <!-- Unified version.  
@@ -60,6 +63,9 @@
       <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</attribute>
 
       <depends optional-attribute-name="TargetName">jboss.test:service=HAService,type=unifiedha</depends>
+      
+      <!--  Directly invoke the target method, not invoke() -->
+      <attribute name="InvokeTargetMethod">true</attribute>
 
       <attribute name="JndiName">jmx/HAServiceUnified</attribute>
 
@@ -98,6 +104,9 @@
       <attribute name="LoadBalancePolicy">org.jboss.ha.framework.interfaces.RoundRobin</attribute>
 
       <depends optional-attribute-name="TargetName">jboss.test:service=HAService,type=pooledha</depends>
+      
+      <!--  Directly invoke the target method, not invoke() -->
+      <attribute name="InvokeTargetMethod">true</attribute>
 
       <attribute name="JndiName">jmx/HAServicePooled</attribute>
 




More information about the jboss-cvs-commits mailing list