KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > server > notification > SimpleSender


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package sync4j.server.notification;
19
20 import java.util.logging.Logger JavaDoc;
21 import java.util.logging.Level JavaDoc;
22
23 import sync4j.framework.logging.Sync4jLogger;
24 import sync4j.framework.notification.Sender;
25 import sync4j.framework.notification.NotificationException;
26
27
28 /**
29  * This is a simple implementation of the Sender interface that simply logs its
30  * activity.
31  *
32  * @author Stefano Fornari @ Funambol
33  *
34  * @version $Id: SimpleSender.java,v 1.1 2005/05/16 17:32:56 nichele Exp $
35  */

36 public class SimpleSender implements Sender {
37
38
39     // ---------------------------------------------------------- Public Methods
40

41     /**
42      * Sends a message
43      * @param messageType the type of the message. See {@link NotificationConstants}
44      * @param phoneNumber the phone number of the target device
45      * @param message the messagge to send
46      * @param info application specific info
47      * @throws NotificationException
48      */

49     public void sendMessage(int messageType,
50                             String JavaDoc phoneNumber,
51                             byte[] message ,
52                             String JavaDoc info )
53     throws NotificationException {
54         Logger JavaDoc log = Sync4jLogger.getLogger();
55
56         if (log.isLoggable(Level.INFO)) {
57             log.info( "Send message(\n\tmessageType: "
58                     + messageType
59                     + "\n\tphoneNumber: "
60                     + phoneNumber
61                     + "\n\tmessage length: "
62                     + ((message != null) ? String.valueOf(message.length) : "unknown")
63                     + "\n\tinfo: "
64                     + info
65             );
66         }
67     }
68
69     /**
70      * Sends messages
71      * @param messageType the type of the message. See {@link NotificationConstants}
72      * @param phoneNumbers the phone numbers list of the target device
73      * @param messages the messages to send
74      * @param info application specific info
75      * @throws NotificationException
76      */

77     public void sendMessages(int messageType,
78                              String JavaDoc[] phoneNumbers,
79                              byte[][] message,
80                              String JavaDoc info) throws NotificationException {
81         Logger JavaDoc log = Sync4jLogger.getLogger();
82
83         if (log.isLoggable(Level.INFO)) {
84             log.info( "Sends messages(\n\tmessageType: "
85                       + messageType
86                       + "\n\tnum. devices: "
87                       + phoneNumbers.length
88                       + "\n\tinfo: "
89                       + info
90                 );
91             log.info("sendMessages with empty implementation");
92         }
93     }
94
95     /**
96      * Sends more messages
97      * @param messageType the type of the message. See {@link NotificationConstants}
98      * @param contentType the contentType
99      * @param macs the macs list
100      * @param authMethods the authentication methods
101      * @param phoneNumbers the phone number list
102      * @param messages the messages to send
103      * @param info application specific info
104      * @throws NotificationException
105      */

106     public void sendMessages(int messageType,
107                              String JavaDoc contentType,
108                              String JavaDoc[] digest,
109                              int[] authMethods,
110                              String JavaDoc[] phoneNumbers,
111                              byte[][] messages,
112                              String JavaDoc info) throws NotificationException {
113
114     }
115
116
117
118 }
Popular Tags