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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 24 01:19:54 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-07-24 01:19:54 -0400 (Tue, 24 Jul 2007)
New Revision: 64241

Added:
   trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/
   trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java
   trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java
   trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceRemote.java
Log:
Add missing invokerha dir

Added: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java	2007-07-24 05:19:54 UTC (rev 64241)
@@ -0,0 +1,143 @@
+/*
+  * 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.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
+{
+   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
+   {
+      // 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.debug("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()
+   {
+      log.info("hello() invoked");
+      return "Hello";
+   }
+   
+   public String getClusterNode()
+   {
+      log.info("getClusterNode() invoked");
+      return getHAPartition().getNodeName();
+   }
+
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAService.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java	2007-07-24 05:19:54 UTC (rev 64241)
@@ -0,0 +1,37 @@
+/*
+  * 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.test.cluster.invokerha;
+
+import java.util.Map;
+
+import org.jboss.invocation.Invocation;
+
+public interface HAServiceMBean
+   extends org.jboss.ha.jmx.HAServiceMBean
+{
+   // For remoting
+   Map getMethodMap();
+   Object invoke(Invocation invocation) throws Exception;
+   
+   boolean getSendRemoteLifecycleNotifications();
+   void setSendRemoteLifecycleNotifications(boolean send);
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceMBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceRemote.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceRemote.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceRemote.java	2007-07-24 05:19:54 UTC (rev 64241)
@@ -0,0 +1,31 @@
+/*
+  * 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.test.cluster.invokerha;
+
+import java.io.IOException;
+
+public interface HAServiceRemote
+{
+   String hello() throws IOException;
+   
+   String getClusterNode();
+}


Property changes on: trunk/testsuite/src/main/org/jboss/test/cluster/invokerha/HAServiceRemote.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native




More information about the jboss-cvs-commits mailing list