Package nexj.core.util

Examples of nexj.core.util.Logger


    * @return The transformed message.
    * @throws IntegrationException If a transformation error occurs.
    */
   public TransferObject transform(PropertyMap obj, Transformation transformation, Pair arguments) throws IntegrationException
   {
      Logger logger = transformation.getLogger();

      m_output = new TransferObject();
      m_listMap = new HashTab();

      try
      {
         if (logger.isDebugEnabled())
         {
            logger.debug("Transforming a message with transformation " + transformation.getName());
            logger.dump(obj);
         }

         Transformation oldTransformation = transformation;

         if (!StringUtil.isEmpty(obj.getClassName()) && m_bPolymorphic)
         {
            TransformationEndpoint derivedEndpoint = transformation.getSource().getEndpoint(obj.getClassName());
            Transformation derivedTransformation = findDerivedTransformation(transformation, derivedEndpoint);

            if (oldTransformation.getDerivation() == Transformation.DERIVATION_FINAL && derivedTransformation != oldTransformation)
            {
               throw new IntegrationException("err.integration.messageTypeMismatch",
                  new Object[] {oldTransformation.toString(), oldTransformation.getSource().toString(), derivedEndpoint.toString()});
            }

            if (derivedTransformation != null && derivedTransformation != oldTransformation)
            {
               transformation = derivedTransformation;

               if (logger.isDebugEnabled())
               {
                  logger.debug("Using derived transformation \"" + derivedTransformation.getName() + "\"");
               }
            }
         }

         if (oldTransformation.getDerivation() == Transformation.DERIVATION_ABSTRACT)
         {
            if (transformation == oldTransformation)
            {
               throw new IntegrationException("err.integration.abstractTransformation",
                  new Object[]{oldTransformation.getName()});
            }
         }

         m_sourceArray = new Object[SOURCE_SIZE * (transformation.getMaxLevel() + 1)];

         if (transformation.getFunction() != null)
         {
            m_argList.clear();
            m_argList.add(this);
            m_argList.add(m_output);
            m_argList.add(obj);

            Pair head = arguments;
            int nArgCount = transformation.getArgumentCount();

            while (head != null)
            {
               nArgCount--;
               m_argList.add(head.getHead());
               head = head.getNext();
            }

            if (nArgCount != 0)
            {
               throw new IntegrationException("err.meta.transformation.argumentCount",
                  new Object[] {Primitive.createInteger(transformation.getArgumentCount()),
                     Primitive.createInteger(Pair.length(arguments))});
            }

            m_scriptArray = (Object[])m_context.getMachine().invoke(transformation.getFunction(), m_argList);
         }
         else
         {
            m_scriptArray = null;
         }

         transform(obj, transformation.getRoot());

         if (m_scriptArray != null)
         {
            m_output = (TransferObject)m_context.getMachine().invoke((Function)m_scriptArray[0], (Pair)null);
         }

         if (m_output.getClassName() == null)
         {
            m_output.setClassName(transformation.getDestination().getName());
         }
      }
      catch (Exception e)
      {
         throw new IntegrationException("err.integration.transformation",
            new Object[]{transformation.getName()}, e);
      }

      if (logger.isDumpEnabled())
      {
         logger.dump("Transformation result:");
         logger.dump(m_output);
      }

      return m_output;
   }
View Full Code Here


            if (s_logger.isDebugEnabled())
            {
               s_logger.debug("Error processing the composite message on attempt " + nRetry + "; trying again.", e);
            }

            Logger logger = getLinkLogger();

            if (logger != null && logger.isWarnEnabled())
            {
               logger.log(Logger.WARN, "err.sync.recoverableFormatting", new Object[] {tobj.getClassName()}, e);
            }

            tobj.setEventName(sOriginalEvent);
            formatFailSafe(tobj, message, out, bCommit, nRetry + 1);
         }
View Full Code Here

      return new Function()
      {
         public boolean invoke(int nArgCount, Machine machine)
         {
            Object cleanupToken = null;
            Logger logger = null;

            try
            {
               assert nArgCount == Pair.length(getArguments());

               InvocationContext context = (InvocationContext)machine.getContext();
               TransferObject tobj = (TransferObject)machine.getArg(0, nArgCount);
               Message message = context.getMetadata().getMessage(tobj.getClassName());
               Format format = message.getFormat();

               if (format == null || !format.getName().equals("Object"))
               {
                  throw new IntegrationException("err.integration.persistFormat",
                     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();

                  if (response == null)
                  {
                     tobj = null;
                  }
                  else
                  {
                     tobj = ((MessageParser)format.getParser().getInstance(context))
                        .parse(new ObjectInput(obj), response);
                  }
               }

               machine.returnValue(tobj, nArgCount);

               return false;
            }
            catch (Throwable t)
            {
               if (logger != null)
               {
                  logger.log(Logger.DEBUG, "err.sync.nonRecoverableFormatting",
                     new Object[] {((TransferObject)machine.getArg(0, nArgCount)).getClassName()}, t);
               }

               ObjUtil.rethrow(t);
View Full Code Here

      if (ctx instanceof InvocationContext && ((InvocationContext)ctx).isStealth())
      {
         return;
      }

      Logger logger = m_metaclass.getLogger();

      logger.debug("Invoking " + this);
           
      if (logger.isDumpEnabled())
      {
         int nOfs = (obj == EMPTY_CLOSURE) ? 1 : 0;
        
         if (args == null)
         {
            args = EMPTY_SYMBOL_ARRAY;
         }

         logger.dump("this = " + Intrinsic.toString((nOfs == 0) ? obj : args[0]));

         for (int i = 0, n = getArgumentCount() - ((m_bVarArg) ? 1 : 0); i < n; ++i)
         {
            if (i + nOfs >= args.length)
            {
               break;
            }

            logger.dump(getArgument(i).getName() + " = " + Intrinsic.toString(args[i + nOfs]));
         }

         if (m_bVarArg)
         {
            StringBuffer buf = new StringBuffer(128);

            buf.append(getArgument(getArgumentCount() - 1).getName());
            buf.append(" = (");

            for (int i = getArgumentCount() - 1, n = args.length - nOfs; i < n; ++i)
            {
               if (i >= getArgumentCount())
               {
                  buf.append(' ');
               }

               buf.append(Intrinsic.toString(args[i + nOfs]));
            }

            buf.append(')');

            logger.dump(buf.toString());
         }
      }
   }
View Full Code Here

      col.add(new Integer(5));
      msg1.setValue("primitiveCollection", col);
     
      msg.setValue("message", msg1);
     
      Logger logger = Logger.getLogger("TransformerTest");
     
      logger.info("source: " + msg.toString());
     
      // transform message
      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("MapMessage"));

      logger.info("result: " + res.toString());
     
      // validate result message
      assertEquals("TransformTestMsg", res.getClassName());
      assertEquals(2, res.getValueCount());
     
View Full Code Here

      msg1.setValue("messageCollection", col1);
      col.add(msg1);
     
      msg.setValue("messageCollection", col);
     
      Logger logger = Logger.getLogger("TransformerTest");
     
      logger.info("source: " + msg.toString());
     
      // transform message
      TransferObject res = m_tf.transform(msg, m_metadata.getTransformation("MapMessageCollection"));

      logger.info("result: " + res.toString());
     
      // validate result message
      assertEquals("TransformTestMsg", res.getClassName());
      assertEquals(2, res.getValueCount());
     
View Full Code Here

      StringWriter writer = new StringWriter();
      Message msg = Repository.getMetadata().getMessage(sMessageName);

      m_formatter.format(formatRoot, msg, new WriterOutput(writer));

      Logger logger = Logger.getLogger("FixedMessageParserTest");

      String s = writer.toString();

      logger.info("size of formatted string is (" + s.length() + ") chars");

      // Parse the formatted string
      TransferObject parseRoot = m_parser.parse(new StringInput(s), msg);

      // Test it
      assertEquals(sMessageName, parseRoot.getClassName());

      List parseRecList = (List)parseRoot.getValue("record");

      assertTrue(parseRecList instanceof PagedArrayList);

      assertEquals(NUM_MESSAGES, parseRecList.size());

      for(int i=0; i < parseRecList.size(); i++)
      {
         TransferObject record = (TransferObject)formatRecList.get(i);
         assertEquals(sRecName + i, record.getValue("name"));
         assertEquals(record.getValue("recNum"), new Long(i));
         if (i % DIVISOR == MODULO)
         {
            logger.info("record: <<" + record.toString() + ">>");
         }
      }

      ((PagedArrayList)parseRecList).dispose();
   }
View Full Code Here

TOP

Related Classes of nexj.core.util.Logger

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.