0 Replies Latest reply on Sep 20, 2004 1:37 PM by 421621

    Synchronous request problem with a custom adapter

    421621
      Hi,

      I am writing a custom adapter for a Java application. The scenario is like this: application A sends a synchronous request via the custom Java adapter A to the hub and this is routed to the application B, via the custom Java adapter B. It is a methos like getCustomers(companyId). It is only one in parameter, that is a String, and an array of Customer objects as a response. The Customer class I defined in iStudio contains two String fields, id and name.

      The communication is done via "Procedure" call, with the following calls on the client adapter side:

      MessageObject response = myAgent.getReply(request);

      The message arrives ok at App B, and the App B tries to build the message object for sending to the App A.

      public void messageReceived(MessageObject messageObject,
      AttributeObject outAttributeObject)
      throws MessageReceiverException {

      AttributeInfo attInfo = outAttributeObject.getAttributeInfo("persons");

      String employee = (String)messageObject.get("ident");

      MyAdapterConnector connector = MyAdapterConnector.getAdapter();
      Vector data = new Vector();
      Vector clients = connector.getCustomers(employee);

      for(int i=0; i < clients.size(); i++)
      {
      CustomerBO custBO = (CustomerBO)clients.get(i);
      Hashtable hash = new Hashtable();
      hash.put("id", custBO.getPartyNumber());
      hash.put("name", custBO.getPhoneticName());
      data.add(hash);
      }

      MyMessageData msgData = new MyMessageData(data);
      msgData.setObjectName("Person");
      MessageObject msgObj = myAgent.createMessageObject(msgData);

      outAttributeObject.set(attInfo, msgObj);

      System.out.println("done with the message!");

      }

      The get method in the MessageData class contains the following:

      public class MyMessageData extends MessageData
      {
      Hashtable objectTable;

      public MyMessageData(Hashtable data)
      {
      objectTable = data;
      }

      public Object get(Object parent, String name,
      AttributeInfo attributeInfo) {
      Object result;

      if (parent == null) {
      result = objectTable.get(name);
      }
      else {
      Hashtable table = (Hashtable)parent;
      result = table.get(name);
      }
      return result;

      }
      }

      The problem is that after setting of the message as the value of the outAttributeObject, with outAttributeObject.set() method, I received an exception due to the LogManager:

      java.lang.ClassCastException
      at oracle.oai.agent.common.AttributeObjectImpl.toString(AttributeObjectI
      mpl.java:540)
      at oracle.oai.agent.common.AttributeObjectImpl.toString(AttributeObjectI
      mpl.java:513)
      at oracle.oai.agent.common.MessageObjectImpl.toString(MessageObjectImpl.
      java:456)
      at oracle.oai.agent.common.logger.LogManager.writeToLogFile(LogManager.j
      ava:515)
      at oracle.oai.agent.common.logger.LogManager.log(LogManager.java:404)
      at oracle.oai.agent.common.logger.LogManager.log(LogManager.java:374)
      at oracle.oai.agent.client.AgentImpl.logStatusMessage(AgentImpl.java:542
      )
      at oracle.oai.agent.client.SmartQueueDispatcher.doPostMessageReceivedPro
      cessing(SmartQueueDispatcher.java:623)
      at oracle.oai.agent.client.SmartQueueDispatcher.run(SmartQueueDispatcher
      .java:510)
      at java.lang.Thread.run(Thread.java:534)

      Please, do you have any hints about this? I am really stucked and no idea about it... :(

      Thanks a lot in advance!

      Best regards,
      Marinel Alangiu