source: contrib/funambol/trunk/modules/psync/src/main/java/br/com/prognus/psync/MySynclet.java @ 2082

Revision 2082, 5.8 KB checked in by emersonfaria, 14 years ago (diff)

Ticket #927 - Reestruturacao dos diretorios do Funambol

Line 
1/*
2 * Funambol is a mobile platform developed by Funambol, Inc.
3 * Copyright (C) 2008 Funambol, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by
7 * the Free Software Foundation with the addition of the following permission
8 * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
9 * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
10 * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program; if not, see http://www.gnu.org/licenses or write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301 USA.
21 *
22 * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite
23 * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
24 *
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
28 *
29 * In accordance with Section 7(b) of the GNU Affero General Public License
30 * version 3, these Appropriate Legal Notices must retain the display of the
31 * "Powered by Funambol" logo. If the display of the logo is not reasonably
32 * feasible for technical reasons, the Appropriate Legal Notices must display
33 * the words "Powered by Funambol".
34 */
35
36package br.com.prognus;
37
38
39import com.funambol.framework.core.SyncML;
40import com.funambol.framework.core.Sync4jException;
41import com.funambol.framework.engine.pipeline.InputMessageProcessor;
42import com.funambol.framework.engine.pipeline.OutputMessageProcessor;
43import com.funambol.framework.engine.pipeline.MessageProcessingContext;
44import com.funambol.framework.logging.FunambolLogger;
45import com.funambol.framework.logging.FunambolLoggerFactory;
46import com.funambol.framework.tools.SyncMLUtil;
47
48/**
49 * This class just logs input and output messages. This synclet can then be
50 * inserted in any position in a pipeline in order to trace how a message is
51 * changed during the pipeline processing. It is at the same time an input and
52 * an output pipeline component.<br>
53 * Logging is done at INFO level
54 */
55public class MySynclet implements InputMessageProcessor, OutputMessageProcessor {
56   
57    // --------------------------------------------------------------- Constants
58
59    public static final String LOG_NAME = "myconnector";
60
61    // ------------------------------------------------------------ Private data
62
63    private static final FunambolLogger log = FunambolLoggerFactory.getLogger(LOG_NAME);
64
65    // ---------------------------------------------------------- Public methods
66
67    /**
68     * Logs the input message and context
69     *
70     * @param processingContext the message processing context
71     * @param message the message to be processed
72     *
73     * @throws Sync4jException
74     */
75    public void preProcessMessage(MessageProcessingContext processingContext,
76                                  SyncML                   message)
77    throws Sync4jException {
78        if (log.isInfoEnabled()) {
79            log.info("--------------------------------------------------------------------------------");
80            log.info("Input message processing context"                                                );
81            log.info("                                                                                ");
82            log.info(processingContext.toString()                                                      );
83            log.info("--------------------------------------------------------------------------------");
84            log.info("Input message"                                                                   );
85            log.info("                                                                                ");
86            log.info(SyncMLUtil.toXML(message)                                                               );
87            log.info("--------------------------------------------------------------------------------");
88        }
89    }
90
91    /**
92     * Logs the output message and context
93     *
94     * @param processingContext the message processing context
95     * @param message the message to be processed
96     *
97     * @throws Sync4jException
98     */
99    public void postProcessMessage(MessageProcessingContext processingContext,
100                                   SyncML                   message)
101    throws Sync4jException {
102        if (log.isInfoEnabled()) {
103            log.info("--------------------------------------------------------------------------------");
104            log.info("Output message processing context"                                               );
105            log.info("                                                                                ");
106            log.info(processingContext.toString()                                                      );
107            log.info("--------------------------------------------------------------------------------");
108            log.info("Output message"                                                                  );
109            log.info("                                                                                ");
110            log.info(SyncMLUtil.toXML(message)                                                               );
111            log.info("--------------------------------------------------------------------------------");
112        }
113    }
114
115
116}
Note: See TracBrowser for help on using the repository browser.