Package nexj.core.integration.io

Examples of nexj.core.integration.io.ObjectOutput


                     new Object[]{message.getName(), (format == null) ? "" : message.getFormat().getName()});
               }

               context.getUnitOfWork().checkTransaction();

               ObjectOutput out = new ObjectOutput();
               MessageFormatter messageFormatter = (MessageFormatter)format.getFormatter().getInstance(context);

               cleanupToken = configureFormatter(messageFormatter, nArgCount, machine);

               if (messageFormatter instanceof ObjectMessageFormatter)
               {
                  ObjectMessageFormatter objMsgFmt = (ObjectMessageFormatter)messageFormatter;

                  logger = objMsgFmt.getLinkLogger();

                  if (logger != null && logger.isDumpEnabled())
                  {
                     logger.log(Logger.DUMP, "ids.sync.collectionFormattingStarted",
                        new Object[] {message.getName()}, null);
                  }
               }

               if (m_nOnError == FAIL_ON_ERROR)
               {
                  messageFormatter.format(tobj, message, out);
               }
               else
               {
                  ((ObjectMessageFormatter)messageFormatter).formatFailSafe(tobj, message, out, m_nOnError == COMMIT_ON_ERROR);
               }

               if (logger != null && logger.isDumpEnabled())
               {
                  logger.log(Logger.DUMP, "ids.sync.collectionFormattingCompleted",
                     new Object[] {message.getName()}, null);
               }

               Object obj = out.getObject();

               if (m_bRespond)
               {
                  Message response = message.getResponse();
View Full Code Here


               value = parser.parse(in, message);
            }
            else
            {
               ObjectOutput out = new ObjectOutput();
               MessageFormatter formatter;

               if (m_formatterMap == null)
               {
                  m_formatterMap = new HashTab(m_context.getMetadata().getFormatCount());
               }

               formatter = (MessageFormatter)m_formatterMap.get(message.getFormat());

               if (formatter == null)
               {
                  formatter = (MessageFormatter)message.getFormat().getFormatter().getInstance(m_context);
                  m_formatterMap.put(message.getFormat(), formatter);
               }

               formatter.format((TransferObject)value, message, out);
               value = out.getObject();
            }
         }
      }

      return value;
View Full Code Here

      if (message.getFormat() == null)
      {
         return tobj;
      }

      ObjectOutput output = sender.createOutput();
      ((MessageFormatter)message.getFormat().getFormatter().getInstance(context)).format(tobj, message, output);

      TransferObject raw = new TransferObject(1);

      raw.setValue(Sender.BODY, output.getObject());
      sender.prepare(raw, tobj, message);

      return raw;
   }
View Full Code Here

      m_surgeon = null;
   }

   public void testFormatRootInheritance()
   {
      ObjectOutput out;
      TransferObject root;
      Instance result;


      // Format the super-message (no polymorphism)
      root = new TransferObject("Object_Inherit_Contact", 3);
      root.setValue("firstName", "Simon");
      root.setValue("lastName", "Lee");
      root.setValue("middleName", "K");

      out = new ObjectOutput();
      m_formatter.format(root, m_contactMsg, out);
      result = (Instance)out.getObject();
      assertEquals("Contact", result.getMetaclass().getName());
      assertEquals("Simon", result.getValue("firstName"));
      assertNull(result.findValue("lastName"));
      assertNull(result.findValue("middleName"));
      assertEquals(Instance.NEW, result.getState());
      rollback();


      // Format the sub-message (no polymorphism)
      root = new TransferObject("Object_Inherit_Patient", 3);
      root.setValue("firstName", "Simon");
      root.setValue("lastName", "Lee");
      root.setValue("middleName", "K");

      out = new ObjectOutput();
      m_formatter.format(root, m_patientMsg, out);
      result = (Instance)out.getObject();
      assertEquals("Patient", result.getMetaclass().getName());
      assertEquals("Simon", result.getValue("firstName"));
      assertEquals("Lee", result.getValue("lastName"));
      assertEquals("K", result.getValue("middleName"));
      assertEquals(Instance.NEW, result.getState());
      rollback();


      // Format the sub-message polymorphically
      root = new TransferObject("Object_Inherit_Patient", 3);
      root.setValue("firstName", "Simon");
      root.setValue("lastName", "Lee");
      root.setValue("middleName", "K");

      out = new ObjectOutput();
      m_formatter.format(root, m_contactMsg, out);
      result = (Instance)out.getObject();
      assertEquals("Patient", result.getMetaclass().getName());
      assertEquals("Simon", result.getValue("firstName"));
      assertEquals("Lee", result.getValue("lastName"));
      assertEquals("K", result.getValue("middleName"));
      assertEquals(Instance.NEW, result.getState());
      rollback();


      // Format Patient2 with Contact_NonPoly (should fail polymorphic check)
      root = new TransferObject("Object_Inherit_Patient2", 3);
      root.setValue("firstName", "Simon");
      root.setValue("lastName", "Lee");
      root.setValue("middleName", "K");

      out = new ObjectOutput();

      try
      {
         m_formatter.format(root, m_contactNonPolyMsg, out);
         fail("Expected IntegrationException");
View Full Code Here

      }
   }

   public void testFormatReferenceInheritance()
   {
      ObjectOutput out;
      TransferObject phoneRoot, contactRoot;
      Instance result;


      // Format reference with super-message (no polymorphism)
      contactRoot = new TransferObject("Object_Inherit_Contact", 3);
      contactRoot.setValue("firstName", "Simon");
      contactRoot.setValue("lastName", "Lee");
      contactRoot.setValue("middleName", "K");
      phoneRoot = new TransferObject("Object_Inherit_Phone", 3);
      phoneRoot.setValue("type", "cell");
      phoneRoot.setValue("number", "967-1111");
      phoneRoot.setValue("CONTACT", contactRoot);

      out = new ObjectOutput();
      m_formatter.format(phoneRoot, m_phoneMsg, out);
      result = (Instance)out.getObject();
      assertEquals("Phone", result.getMetaclass().getName());
      assertEquals("cell", result.getValue("type"));
      assertEquals("967-1111", result.getValue("number"));
      assertEquals(Instance.NEW, result.getState());
      result = (Instance)result.getValue("contact");

      assertEquals("Contact", result.getMetaclass().getName());
      assertEquals("Simon", result.getValue("firstName"));
      assertNull(result.findValue("lastName"));
      assertNull(result.findValue("middleName"));
      assertEquals(Instance.NEW, result.getState());
      rollback();


      // Format the reference with sub-message (polymorphic!)
      contactRoot = new TransferObject("Object_Inherit_Patient", 3);
      contactRoot.setValue("firstName", "Simon");
      contactRoot.setValue("lastName", "Lee");
      contactRoot.setValue("middleName", "K");
      phoneRoot = new TransferObject("Object_Inherit_Phone", 3);
      phoneRoot.setValue("type", "cell");
      phoneRoot.setValue("number", "967-1111");
      phoneRoot.setValue("CONTACT", contactRoot);

      out = new ObjectOutput();
      m_formatter.format(phoneRoot, m_phoneMsg, out);
      result = (Instance)out.getObject();
      assertEquals("Phone", result.getMetaclass().getName());
      assertEquals("cell", result.getValue("type"));
      assertEquals("967-1111", result.getValue("number"));
      assertEquals(Instance.NEW, result.getState());
      result = (Instance)result.getValue("contact");
View Full Code Here

      groupTobj.setValue("participants", participantTobjList);
      groupTobj.setValue("name", "Updated");
      participantTobjList.add(doctorTobj);
      doctorTobj.setValue("licenseNumber", "license for Doctor");
      m_formatter.format(groupTobj, getMessage("Object_SupportGroup"), new ObjectOutput());
      commit();
  
      group = Query.createRead(supportGroupMetaclass, null, null, null, -1, 0, false, Query.SEC_NONE, m_context).read().getInstance(0);
      assertEquals("Updated", group.getValue("name"));
      participants = (InstanceList)group.getValue("participants");
     
      for (Iterator itr = participants.iterator(); itr.hasNext(); )
      {
         Instance participant = (Instance)itr.next();
        
         if (participant.getClassName().equals("Doctor"))
         {
            assertEquals("license for Doctor", participant.getValue("licenseNumber"));
         }
      }

      participantTobjList.add(contactTobj);
      contactTobj.setValue("licenseNumber", "license for Contact");
     
      try
      {
         m_formatter.format(groupTobj, getMessage("Object_SupportGroup"), new ObjectOutput());
         fail();
      }
      catch (IntegrationException e)
      {
         assertTrue(e.getCause().getMessage().contains("err.integration.object.noMatch"));
View Full Code Here

     
      account.setValue("funds", Double.valueOf(123));
      account.setValue("contact", contact);
      contact.setValue("lastName", "Peters");
      contact.setValue("account", account);
      m_formatter.format(account, getMessage("Object_AccountRecursive"), new ObjectOutput());
      commit();
  
      InstanceList instances = Query.createRead(getMetadata().getMetaclass("Account"),
         parse("(funds (contact lastName))"),
         null, null, -1, 0, false, Query.SEC_NONE, m_context).read();
View Full Code Here

TOP

Related Classes of nexj.core.integration.io.ObjectOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.