1 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 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 29 public Provider getProvider() { 30 return _provider; 31 } 32 33 36 public void clear() { 37 _request = null; 38 _response = null; 39 } 40 41 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 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 |