/** * Copyright (C) 2003-2007 Funambol * * This program is free software; you can redistribute it and/or modify * it under the terms of the Honest Public License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Honest Public License for more details. * * You should have received a copy of the Honest Public License * along with this program; if not, write to Funambol, * 643 Bair Island Road, Suite 305 - Redwood City, CA 94063, USA */ package br.com.prognus.psync.synclet; import com.funambol.framework.core.Sync4jException; import com.funambol.framework.core.SyncML; import com.funambol.framework.engine.pipeline.*; import com.funambol.framework.logging.FunambolLogger; import com.funambol.framework.logging.FunambolLoggerFactory; import com.funambol.framework.tools.SyncMLUtil; /** * This class just logs input and output messages. This synclet can then be * inserted in any position in a pipeline in order to trace how a message is * changed during the pipeline processing. It is at the same time an input and * an output pipeline component.
* Logging is done at INFO level * * @version $Id: LoggingSynclet.java,v 1.4 2007-01-11 19:20:19 nichele Exp $ */ public class LoggingSynclet implements InputMessageProcessor, OutputMessageProcessor { // ------------------------------------------------------------ Private data private static final FunambolLogger log = FunambolLoggerFactory.getLogger("engine.pipeline"); // ---------------------------------------------------------- Public methods /** * Logs the input message and context * * @param processingContext the message processing context * @param message the message to be processed * * @throws Sync4jException */ public void preProcessMessage(MessageProcessingContext processingContext, SyncML message) throws Sync4jException { if (log.isInfoEnabled()) { log.info("--------------------------------------------------------------------------------"); log.info("Input message processing context" ); log.info(" "); log.info(processingContext.toString() ); log.info("--------------------------------------------------------------------------------"); log.info("Input message" ); log.info(" "); log.info(SyncMLUtil.toXML(message) ); log.info("--------------------------------------------------------------------------------"); } } /** * Logs the output message and context * * @param processingContext the message processing context * @param message the message to be processed * * @throws Sync4jException */ public void postProcessMessage(MessageProcessingContext processingContext, SyncML message) throws Sync4jException { if (log.isInfoEnabled()) { log.info("--------------------------------------------------------------------------------"); log.info("Output message processing context" ); log.info(" "); log.info(processingContext.toString() ); log.info("--------------------------------------------------------------------------------"); log.info("Output message" ); log.info(" "); log.info(SyncMLUtil.toXML(message) ); log.info("--------------------------------------------------------------------------------"); } } }