Clover coverage report - JFox Service-Oriented Application Framework - 1.0-RC1 Coverage timestamp: 星期五 八月 19 2005 13:21:55 CST FRAMES NO FRAMES |
file stats: | LOC: | 92 |  | Methods: | 4
| NCLOC: | 40 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
MailServiceImpl.java | - | 0% | 0% | 0% |

1 |  |
     /**
2 |  |
      * @(#)MailServiceImpl.java
3 |  |
      *
4 |  |
      * JFoxSOAF, Service-Oriented Application Framework
5 |  |
      *
6 |  |
      * Copyright(c) JFoxSOAF Team
7 |  |
      *
8 |  |
      * Licensed under the GNU LGPL, Version 2.1 (the "License");
9 |  |
      * you may not use this file except in compliance with the License.
10 |  |
      * You may obtain a copy of the License at
11 |  |
      *
12 |  |
      * http://www.gnu.org/copyleft/lesser.html
13 |  |
      *
14 |  |
      * Unless required by applicable law or agreed to in writing, software
15 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
16 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 |  |
      * See the License for the specific language governing permissions and
18 |  |
      * limitations under the License.
19 |  |
      *
20 |  |
      * For more information, please visit:
21 |  |
      * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22 |  |
      * http://www.huihoo.org/jfox/jfoxsoaf
23 |  |
      */
24 |  |
25 |  |
     package org.huihoo.jfox.soaf.services.mail;
26 |  |
27 |  |
     import javax.mail.MessagingException;
28 |  |
     import javax.mail.Session;
29 |  |
     import javax.mail.Transport;
30 |  |
31 |  |
     import org.apache.commons.mail.Email;
32 |  |
     import org.apache.commons.mail.EmailException;
33 |  |
     import org.huihoo.jfox.soaf.exception.MailException;
34 |  |
     import org.huihoo.jfox.soaf.exception.ServiceLocatorException;
35 |  |
     import org.huihoo.jfox.soaf.services.ejb.ServiceLocator;
36 |  |
37 |  |
     /**
38 |  |
      * <p>
39 |  |
      * Mail service implementation.
40 |  |
      * </p>
41 |  |
      *
42 |  |
      * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
43 |  |
      * @version $Revision: 1.1 $ $Date: 2005/05/22 06:50:11 $
44 |  |
      * @version Revision: 1.0
45 |  |
      */
46 |  |
47 |  |
     public class MailServiceImpl implements MailService {
48 |  |
49 |  |
         private ServiceLocator serviceLocator;
50 |  |
51 | 0 |
         public MailServiceImpl(ServiceLocator serviceLocator) {
52 | 0 |
             this.serviceLocator = serviceLocator;
53 |  |
         }
54 |  |
55 |  |
         /**
56 |  |
          * @see org.huihoo.jfox.soaf.services.mail.MailService#sendMail(org.apache.commons.mail.Email)
57 |  |
          */
58 | 0 |
         public void sendMail(Email email) throws MailException {
59 | 0 |
             try {
60 | 0 |
                 email.send();
61 |  |
             } catch (EmailException e) {
62 | 0 |
                 throw new MailException("Send mail failed " + e);
63 |  |
             }
64 |  |
         }
65 |  |
66 |  |
         /**
67 |  |
          * @see org.huihoo.jfox.soaf.services.mail.MailService#sendMailWithSession(org.apache.commons.mail.Email)
68 |  |
          */
69 | 0 |
         public void sendMailWithSession(Email email, String mailSessionName)
70 |  |
                 throws MailException {
71 | 0 |
             try {
72 | 0 |
                 Session session = serviceLocator.getMailSession(mailSessionName);
73 | 0 |
                 email.setMailSession(session);
74 | 0 |
                 email.send();
75 |  |
             } catch (ServiceLocatorException e) {
76 | 0 |
                 throw new MailException("Lookup mail session failed ", e);
77 |  |
             } catch (EmailException e) {
78 | 0 |
                 throw new MailException("Send mail failed ", e);
79 |  |
             }
80 |  |
         }
81 |  |
82 |  |
         /**
83 |  |
          * @see org.huihoo.jfox.soaf.services.mail.MailService#sendMail(org.huihoo.jfox.soaf.services.mail.MailMessage)
84 |  |
          */
85 | 0 |
         public void sendMail(MailMessage mailMessage) throws MailException {
86 | 0 |
             try {
87 | 0 |
                 Transport.send(mailMessage.getMimeMessage());
88 |  |
             } catch (MessagingException e) {
89 | 0 |
                 throw new MailException(e);
90 |  |
             }
91 |  |
         }
92 |  |
     }