Package nexj.core.integration

Examples of nexj.core.integration.MessageFormatter


    */
   protected void seed(String sTransformation, final Function enabled, final Function delete, ResourceLoader loader)
   {
      final Metadata metadata = m_context.getMetadata();
      final MessageParser parser = (MessageParser)metadata.getFormat("XML").getParser().getInstance(m_context);
      final MessageFormatter formatter = (MessageFormatter)metadata.getFormat("Object").getFormatter().getInstance(m_context);
      final Transformation transformation = metadata.getTransformation(sTransformation);
      final Transformer transformer = new Transformer(m_context);
      final UnitOfWork uow = m_context.getUnitOfWork();
      final boolean bRawSaved = uow.isRaw();

      try
      {
         uow.setRaw(true);

         final List tobjList = new ArrayList();

         loader.seedResources(((XMLMetadata)metadata).getHelper(), new CharacterStreamHandler()
         {
            public void handleCharacterStream(Reader reader, String sName) throws IOException
            {
               try
               {
                  TransferObject tobj = parser.parse(new ReaderInput(reader), (Message)transformation.getSource());

                  tobj.setValue("name", sName);

                  if (enabled != null && !Intrinsic.isTrue(m_context.getMachine().invoke(enabled, tobj, (Object[])null)))
                  {
                     return;
                  }

                  if (delete != null)
                  {
                     m_context.getMachine().invoke(delete, tobj, (Object[])null);
                  }

                  tobj = transformer.transform(tobj, transformation);
                  tobjList.add(tobj);
               }
               catch (Exception e)
               {
                  s_logger.error("Unable to seed resource \"" + sName + "\"", e);

                  if (e instanceof RuntimeException)
                  {
                     throw (RuntimeException)e;
                  }

                  throw new UncheckedException("err.runtime.seed", new Object[]{sName}, e);
               }
            }
         });

         // Commit the deletes
         uow.commit(false);

         for (Iterator itr = tobjList.iterator(); itr.hasNext();)
         {
            formatter.format((TransferObject)itr.next(), (Message)transformation.getDestination(), new ObjectOutput());
         }

         // Commit the inserts/updates
         uow.commit(false);
      }
View Full Code Here


       */
      StringWriter writer;
      WriterOutput out;
      TransferObject root, ref;
      Format format = m_context.getMetadata().getFormat("XML");
      MessageFormatter formatter = (MessageFormatter)format.getFormatter().getInstance(m_context);

      root = new TransferObject("XML_Inherit_Schema_Reference", 1);
      ref = new TransferObject("XML_Inherit_Schema1", 2);
      root.setValue("s1", ref);
      ref.setValue("a", "aValue");
      ref.setValue("x", "xValue");
      out = new WriterOutput(writer = new StringWriter());
      formatter.format(root, msg, out);

      assertEquals(
         "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
         "<is1:references" +
            " xmlns:is3=\"urn:com.nexjsystems:ns:test:inherit:schema3\"" +
View Full Code Here

               }

               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);
               }
View Full Code Here

TOP

Related Classes of nexj.core.integration.MessageFormatter

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.