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);