KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > sms > provider > SenderImpl


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.services.communication.sms.provider;
6
7 import org.exoplatform.services.communication.sms.adapter.Adapter;
8 import org.exoplatform.services.communication.sms.common.*;
9 import org.exoplatform.services.communication.sms.model.Messages;
10 import org.exoplatform.services.communication.sms.provider.*;
11
12 /**
13  * @author: Ove Ranheim
14  * @email: oranheim@users.sourceforge.net
15  */

16 public class SenderImpl implements Sender {
17     
18     protected Provider _provider;
19     protected SmsRequest _request;
20     protected SmsResponse _response;
21     
22     public SenderImpl(Provider provider) {
23         _provider = provider;
24     }
25
26     /*
27      * @see org.exoplatform.services.communication.sms.provider.Sender#getProvider()
28      */

29     public Provider getProvider() {
30         return _provider;
31     }
32
33     /*
34      * @see org.exoplatform.services.communication.sms.provider.Sender#clear()
35      */

36     public void clear() {
37         _request = null;
38         _response = null;
39     }
40     
41     /*
42      * @see org.exoplatform.services.communication.sms.provider.Sender#prepare(org.exoplatform.services.communication.sms.model.Messages)
43      */

44     public void prepare(Messages messages) throws RequestException, ConvertException {
45         Adapter adapter = _provider.getAdapter();
46         _request = adapter.getRequest();
47         _response = adapter.getResponse();
48         _request.setMessages(messages);
49         _response.setMessages(messages);
50         _request.prepare();
51     }
52
53     /*
54      * @see org.exoplatform.services.communication.sms.provider.Sender#send()
55      */

56     public Messages send() throws CommunicationError, ResponseException {
57         Messenger messenger = _provider.getMessenger();
58         messenger.service(_request, _response);
59         return _response.getMessages();
60     }
61
62 }
63
64
Popular Tags