if (isLocalAgent (MessageUtils.getTargetAgent(msg))) MessageUtils.setMessageTypeToLocal (msg);
MessageUtils.setLocalMessage(msg, (isLocalAgent(MessageUtils.getTargetAgent(msg))));
    public synchronized void registerClient (MessageTransportClient client)    {      super.registerClient (client);      //  At this point we may now access the AgentState of the agent.      //  Extract any sent-but-not-acked messages he has and send them.      MessageAddress myAddress = getAddress();      AgentState myState = getRegistry().getAgentState (myAddress);      Vector v = null;      synchronized (myState)       {        v = (Vector) myState.getAttribute (SENT_BUT_NOT_ACKED_MSGS);        if (v != null) myState.setAttribute (SENT_BUT_NOT_ACKED_MSGS, null);      }      if (v == null)       {        if (log.isDebugEnabled()) log.debug ("AgentArrivals: agentState is null for " +myAddress);        return;  // no messages      }      if (log.isDebugEnabled()) log.debug ("AgentArrivals: agentState has " +v.size()+        " message" +(v.size()==1? "" : "s")+ " for " +myAddress);      //  Process and send each message in the agent state      for (Enumeration e=v.elements(); e.hasMoreElements(); )      {        AttributedMessage msg = (AttributedMessage) e.nextElement();        if (MessageUtils.isRegularMessage (msg))        {          //  Ensure message attributes ok          if (!MessageIntegrity.areMessageAttributesOK (msg, log))          {            if (log.isDebugEnabled()) log.debug ("AgentArrivals: dropping message " +              "that failed attributes integrity check: " +MessageUtils.toString(msg));          }          //  Fix up the message state for its new sending node          MessageUtils.getFromAgent(msg).setNodeName (thisNode);          MessageUtils.setAck (msg, null);          MessageUtils.setSendProtocolLink (msg, null);          //  Reclassify message as local if needed          if (isLocalAgent (MessageUtils.getTargetAgent(msg))) MessageUtils.setMessageTypeToLocal (msg);          //  Send the message          if (log.isDebugEnabled()) log.debug ("AgentArrivals: sending " +MessageUtils.toString(msg));          sendMessage (msg);        }        else        {          if (log.isDebugEnabled()) log.debug ("AgentArrivals: dropping non-regular message " +            "that somehow got on agent state: " +MessageUtils.toString(msg));        }      }    }