User: patriot1burke
  Date: 01/09/17 21:15:10

  Modified:    src/main/org/jboss/ha HAPartitionImpl.java HAPartition.java
                        DistributedReplicantManagerImpl.java
  Log:
  work in progress.  ClusterPartion is finally loadable and working
  
  Revision  Changes    Path
  1.4       +62 -1     jbossmx/src/main/org/jboss/ha/HAPartitionImpl.java
  
  Index: HAPartitionImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HAPartitionImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HAPartitionImpl.java      2001/09/16 15:29:07     1.3
  +++ HAPartitionImpl.java      2001/09/18 04:15:10     1.4
  @@ -9,6 +9,7 @@
   
   import JavaGroups.MethodLookup;
   import JavaGroups.MethodLookupClos;
  +import JavaGroups.MethodLookupJava;
   import JavaGroups.MembershipListener;
   import JavaGroups.MessageListener;
   import JavaGroups.JChannel;
  @@ -27,6 +28,14 @@
   import java.util.Iterator;
   import java.io.Serializable;
   import javax.naming.InitialContext;
  +import javax.naming.Reference;
  +import javax.naming.StringRefAddr;
  +import javax.naming.Name;
  +import javax.naming.Context;
  +import javax.naming.NamingException;
  +import javax.naming.NameNotFoundException;
  +import org.jboss.naming.NonSerializableFactory;
  +import java.lang.reflect.Method;
   
   import org.jboss.logging.Logger;
   
  @@ -42,6 +51,33 @@
      protected DistributedReplicantManagerImpl replicantManager;
      protected String nodeName;
      protected Logger log = null;
  +
  +   /*
  +   protected class PIMethodLookup implements JavaGroups.MethodLookup
  +   {
  +      public Method FindMethod(Class target_class, String method_name, Vector args) 
throws Exception 
  +      {
  +         System.out.println("looking for method: " + method_name + " Class name: " 
+ target_class.getName());
  +         Method     retval=null, method;
  +         Method[]   methods=target_class.getMethods();
  +         int        num_args=args.size();
  +
  +         // FIXME: Get funkier later.
  +         for(int i=0; i < methods.length; i++) {
  +         method=methods[i];
  +            System.out.println("does method match? " + method.getName());
  +         if(method.getName().equals(method_name) && 
  +            method.getParameterTypes().length == num_args) {
  +               return method;
  +         }
  +         }
  +         System.out.println("method not found!");
  +         throw new NoSuchMethodException();
  +      }
  +      
  +   }
  +   */
  +
      final MethodLookup  method_lookup_clos=new MethodLookupClos();
   
      public HAPartitionImpl(String partitionName, JChannel channel,
  @@ -66,7 +102,31 @@
         log.info("init replicant manager");
         this.replicantManager.init();
         log.info("bind replicant manager");
  -      new InitialContext().bind("/HAPartition/" + partitionName, this);
  +
  +      Context ctx = new InitialContext();
  +      String jndiName = "/HAPartition/" + partitionName;
  +      // Ah ! Session isn't serializable, so we use a helper class
  +      NonSerializableFactory.bind(jndiName, this);
  +      Name n = ctx.getNameParser("").parse(jndiName);
  +      while (n.size() > 1)
  +      {
  +         String ctxName = n.get(0);
  +         try
  +         {
  +            ctx = (Context)ctx.lookup(ctxName);
  +         }
  +         catch (NameNotFoundException e)
  +         {
  +            log.info("creating Subcontext" + ctxName);
  +            ctx = ctx.createSubcontext(ctxName);
  +         }
  +         n = n.getSuffix(1);
  +      }
  +      // The helper class NonSerializableFactory uses address type nns, we go on to
  +      // use the helper class to bind the javax.mail.Session object in JNDI
  +      StringRefAddr addr = new StringRefAddr("nns", jndiName);
  +      Reference ref = new Reference(HAPartitionImpl.class.getName(), addr, 
NonSerializableFactory.class.getName(), null);
  +      ctx.bind(n.get(0), ref);
         log.info("done initing..");
      }
   
  @@ -125,6 +185,7 @@
         
         if (!excludeSelf)
         {
  +         m.SetName(methodName);
            Object handler = rpcHandlers.get(objName);
            Object retval=m.Invoke(handler, method_lookup_clos);
            if (retval != null) rtn.add(retval);
  
  
  
  1.2       +3 -2      jbossmx/src/main/org/jboss/ha/HAPartition.java
  
  Index: HAPartition.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmx/src/main/org/jboss/ha/HAPartition.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HAPartition.java  2001/09/14 03:53:29     1.1
  +++ HAPartition.java  2001/09/18 04:15:10     1.2
  @@ -15,7 +15,7 @@
   {
      // General methods
      //
  -   public String getNodeName ();
  +   public String getNodeName();
      public String getPartitionName();
   
      public DistributedReplicantManager getDistributedReplicantManager();
  @@ -47,7 +47,7 @@
         public void setCurrentState(Serializable newState);
      }
      
  -   public void subscribeToStateTransferEvents (String objectName, 
HAPartition.HAPartitionStateTransfer subscriber);
  +   public void subscribeToStateTransferEvents (String objectName, 
HAPartition.HAPartitionStateTransfer subscriber) throws Exception;
      public void unsubscribeFromStateTransferEvents (String objectName, 
HAPartition.HAPartitionStateTransfer subscriber);
   
      // *************************
  @@ -65,3 +65,4 @@
      public void unregisterMembershipListener(HAMembershipListener listener);
   
   }
  +
  
  
  
  1.4       +6 -8      
jbossmx/src/main/org/jboss/ha/DistributedReplicantManagerImpl.java
  
  Index: DistributedReplicantManagerImpl.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/DistributedReplicantManagerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DistributedReplicantManagerImpl.java      2001/09/16 15:29:07     1.3
  +++ DistributedReplicantManagerImpl.java      2001/09/18 04:15:10     1.4
  @@ -5,13 +5,15 @@
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Collection;
  +import java.rmi.server.RemoteStub;
   import java.rmi.server.RemoteServer;
   import java.rmi.server.UnicastRemoteObject;
   import java.io.Serializable;
  +import java.rmi.RemoteException;
   
   import org.jboss.logging.Logger;
   
  -public class DistributedReplicantManagerImpl extends RemoteServer
  +public class DistributedReplicantManagerImpl
      implements DistributedReplicantManager,
                 HAPartition.HAPartitionStateTransfer,
                 HAPartition.HAMembershipListener
  @@ -23,7 +25,7 @@
   
      protected final static String SERVICE_NAME = "DistributedReplicantManager";
   
  -   public DistributedReplicantManagerImpl(HAPartition partition)
  +   public DistributedReplicantManagerImpl(HAPartition partition) throws 
RemoteException
      {
         this.partition = partition;
         this.log = Logger.create(partition.getPartitionName() + ":ReplicantManager");
  @@ -39,14 +41,10 @@
         partition.registerMembershipListener(this);
         log.info("subscribeToStateTransferEvents");
         partition.subscribeToStateTransferEvents(SERVICE_NAME, this);
  -
  -      // Export myself as an RMI server
         log.info("Export myself as an RMI server");
  -      UnicastRemoteObject.exportObject(this, 0);
  -
  -      // Register myself as a replicant of DistributedReplicantManager
  +      RemoteStub stub = UnicastRemoteObject.exportObject(this);
         log.info("Register myself as a replicant of DistributedReplicantManager");
  -      add(SERVICE_NAME, this);
  +      add(SERVICE_NAME, stub);
      }
   
      /////////////////////
  
  
  

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

Reply via email to