User: patriot1burke
  Date: 01/09/24 17:45:34

  Modified:    src/main/org/jboss/ha HARMIServerImpl.java
  Log:
  more cleanup
  
  Revision  Changes    Path
  1.4       +47 -15    jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java
  
  Index: HARMIServerImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HARMIServerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HARMIServerImpl.java      2001/09/21 21:58:47     1.3
  +++ HARMIServerImpl.java      2001/09/25 00:45:34     1.4
  @@ -7,8 +7,13 @@
   import java.util.Collection;
   import java.rmi.Remote;
   import java.rmi.server.RemoteStub;
  +import java.rmi.server.RemoteServer;
   import java.rmi.server.UnicastRemoteObject;
   import java.io.Serializable;
  +import java.io.Externalizable;
  +import java.io.ObjectInput;
  +import java.io.ObjectOutput;
  +import java.io.IOException;
   import java.rmi.RemoteException;
   
   import org.jboss.logging.Logger;
  @@ -16,11 +21,12 @@
   import java.rmi.MarshalledObject;
   import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Proxy;
   
   public class HARMIServerImpl
  -
  -implements HARMIServer, DistributedReplicantManager.ReplicantListener
  -
  +   implements HARMIServer, 
  +              DistributedReplicantManager.ReplicantListener, 
  +              java.lang.reflect.InvocationHandler
   {
      protected String replicantName;
      protected long lastSet = System.currentTimeMillis();
  @@ -28,10 +34,13 @@
      protected Object handler;
      protected HashMap invokerMap = new HashMap ();
      protected HAPartition partition = null;
  -   protected RemoteStub myStub = null;
      protected Logger log;
  -   
  -   public HARMIServerImpl (HAPartition partition, String replicantName, Object 
handler) throws Exception
  +   protected HARMIClient client;
  +   protected RemoteStub rmistub;
  +   protected Object stub;
  +   protected Object proxy;
  +
  +   public HARMIServerImpl (HAPartition partition, String replicantName, Class intf, 
Object handler, LoadBalancePolicy policy) throws Exception
      {
         this.replicantName = replicantName;
         this.partition = partition;
  @@ -41,13 +50,26 @@
         
         for (int i = 0; i < methods.length; i++)
            invokerMap.put (new Long (RemoteMethodInvocation.calculateHash 
(methods[i])), methods[i]);
  -      
  -      this.myStub = UnicastRemoteObject.exportObject (this);
         
  +      this.rmistub = UnicastRemoteObject.exportObject (this);
  +      this.client = new HARMIClient(new Object[0], policy);
  +      this.stub = Proxy.newProxyInstance(
  +         intf.getClassLoader(),
  +         new Class[] { intf },
  +         this.client);
  +      this.proxy = Proxy.newProxyInstance(
  +         intf.getClassLoader(),
  +         new Class[] { intf },
  +         this);
         partition.getDistributedReplicantManager ().registerListener (replicantName, 
this);
  -      partition.getDistributedReplicantManager ().add (replicantName, this.myStub);
  +      partition.getDistributedReplicantManager ().add (replicantName, rmistub);
      }
      
  +   public Object getHAStub()
  +   {
  +      return stub;
  +   }
  +
      public void destroy ()
      {
         try
  @@ -60,11 +82,6 @@
         {e.printStackTrace ();}
      }
      
  -   public RemoteStub getStub ()
  -   {
  -      return this.myStub;
  -   }
  -   
      public long getTag ()
      {
         return lastSet;
  @@ -74,9 +91,10 @@
      {
         log.info("replicantsChanged" + key + " to " + newReplicants.size());
         replicants = newReplicants;
  +      client.setTargets(replicants.toArray());
         lastSet = System.currentTimeMillis ();
      }
  -   
  +
      public HARMIResponse invoke (long tag, MarshalledObject mimo) throws Exception
      {
         RemoteMethodInvocation rmi = (RemoteMethodInvocation)mimo.get ();
  @@ -108,4 +126,18 @@
            throw (Exception)ite.getTargetException ();
         }
      }
  +
  +   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
  +   {
  +      try
  +      {
  +         log.info("collocated call");
  +         return method.invoke(handler, args);
  +      }
  +      catch (InvocationTargetException ite)
  +      {
  +         throw ite.getTargetException ();
  +      }
  +   }
  + 
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to