don't do new objectname(string) it is a pig

marcf

|-----Original Message-----
|From: [EMAIL PROTECTED]
|[mailto:[EMAIL PROTECTED]]On Behalf Of Oleg
|Nitz
|Sent: Monday, February 11, 2002 4:54 PM
|To: [EMAIL PROTECTED]
|Subject: [JBoss-dev] CVS update:
|jbossmx/src/main/org/jboss/invocation/jrmp/server JRMPInvokerHA.java
|
|
|  User: olegnitz
|  Date: 02/02/11 16:53:35
|
|  Modified:    src/main/org/jboss/invocation/jrmp/server JRMPInvokerHA.java
|  Log:
|  The bean hashCode was calculated incorrectly: was
|String.hashCode(), should be (new ObjectName(String)).hashCode()
|
|  Revision  Changes    Path
|  1.10      +32 -19
|jbossmx/src/main/org/jboss/invocation/jrmp/server/JRMPInvokerHA.java
|
|  Index: JRMPInvokerHA.java
|  ===================================================================
|  RCS file:
|/cvsroot/jboss/jbossmx/src/main/org/jboss/invocation/jrmp/server/JR
|MPInvokerHA.java,v
|  retrieving revision 1.9
|  retrieving revision 1.10
|  diff -u -r1.9 -r1.10
|  --- JRMPInvokerHA.java       7 Feb 2002 08:56:34 -0000       1.9
|  +++ JRMPInvokerHA.java       12 Feb 2002 00:53:35 -0000      1.10
|  @@ -41,7 +41,7 @@
|   *
|   *  @author <a href="mailto:[EMAIL PROTECTED]>Bill Burke</a>
|   *
|  -*  @version $Revision: 1.9 $
|  +*  @version $Revision: 1.10 $
|   */
|
|   public class JRMPInvokerHA
|  @@ -99,7 +99,7 @@
|         state = STARTED;
|         log.info("Started");
|      }
|  -
|  +
|      public void stop()
|      {
|         if (getState() != STARTED)
|  @@ -125,49 +125,62 @@
|      public void destroy()
|      {
|      }
|  -
|  +
|      public void registerBean(String beanName, HATarget target)
|throws Exception
|      {
|  +      Integer hash = new Integer((new ObjectName(beanName)).hashCode());
|         log.info("77777777777777777777 BEAN NAME IS "+beanName);
|  -      beanMap.put(new Integer(beanName.hashCode()), target);
|  +      if (beanMap.containsKey(hash)) {
|  +         // FIXME [oleg] In theory this is possible!
|  +         throw new IllegalStateException("Trying to register
|bean with the existing hashCode");
|  +      }
|  +      beanMap.put(hash, target);
|      }
|  -
|  +
|      public JRMPInvokerProxy createProxy(String beanName,
|LoadBalancePolicy policy) throws Exception
|      {
|  -      HATarget target = (HATarget)beanMap.get(new
|Integer(beanName.hashCode()));
|  +      Integer hash = new Integer((new ObjectName(beanName)).hashCode());
|  +      HATarget target = (HATarget)beanMap.get(hash);
|  +      if (target == null) {
|  +         throw new IllegalStateException("The bean hashCode not found");
|  +      }
|         return new JRMPInvokerProxyHA(target.getReplicants(), policy);
|      }
|  -
|  +
|      public void unregisterBean(String beanName) throws Exception
|      {
|  -      beanMap.remove(new Integer(beanName.hashCode()));
|  +      Integer hash = new Integer((new ObjectName(beanName)).hashCode());
|  +      beanMap.remove(hash);
|      }
|  -
|  +
|      /**
|      *  Invoke a Remote interface method.
|      */
|      public Object invoke(Invocation invocation)
|      throws Exception
|  -   {
|  -
|  +   {
|  +
|         ClassLoader oldCl =
|Thread.currentThread().getContextClassLoader();
|  -
|  +
|         try
|         {
|  -         // Deserialize the transaction if it is there
|  +         // Deserialize the transaction if it is there
|
|invocation.setTransaction(importTPC(((MarshalledInvocation)
|invocation).getTransactionPropagationContext()));
|  -
|  +
|            // Extract the ObjectName, the rest is still marshalled
|            ObjectName mbean = (ObjectName)
|Registry.lookup((Integer) invocation.getContainer());
|  -
|  +
|            long clientViewId =
|((Long)invocation.getValue("CLUSTER_VIEW_ID")).longValue();
|  -
|  -
|  +
|  +
|            // The cl on the thread should be set in another interceptor
|  -         Object rtn = server.invoke(mbean, "",  new Object[]
|{invocation}, new String[] {"java.lang.Object"});
|  +         Object rtn = server.invoke(mbean, "",  new Object[]
|{invocation}, new String[] {"java.lang.Object"});
|            HARMIResponse rsp = new HARMIResponse();
|  -
|  +
|            HATarget target = (HATarget)beanMap.get((Integer)
|invocation.getContainer());
|  +         if (target == null) {
|  +            throw new IllegalStateException("The bean hashCode
|not found");
|  +         }
|            if (clientViewId != target.getCurrentViewId())
|            {
|               rsp.newReplicants = new ArrayList(target.getReplicants());
|
|
|
|
|_______________________________________________
|Jboss-development mailing list
|[EMAIL PROTECTED]
|https://lists.sourceforge.net/lists/listinfo/jboss-development


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

Reply via email to